Question for understanding about SCI_ANNOTATIONSETSTYLEOFFSET usage

67 views
Skip to first unread message

cfran...@gmail.com

unread,
Mar 18, 2018, 9:57:49 PM3/18/18
to scintilla-interest
Hello,

I'm trying to get the SCI_ANNOTATIONSETSTYLEOFFSET call working
but looks like I have a misunderstanding here.

From the documentation I get that prior to the call
SCI_ANNOTATIONSETSTYLEOFFSET one should use SCI_ALLOCATEEXTENDEDSTYLES
with the number of styles to allocate. It then will return the offset
which should be used as parameter to ANNOTATIONSETSTYLEOFFSET.

That's it - nothing more to do.
The style ids then, I assume, need to start with 0

So something like

offset = SCI_ALLOCATEEXTENDEDSTYLES(3) //offset is set to 256
SCI_ANNOTATIONSETSTYLEOFFSET(offset)

anon_style1 = 0
anon_style2 = 1
anon_style3 = 2

SCI_ANNOTATIONSETSTYLE(line_number, anon_style1)

and under the hood anon_style1 is treated as 256, anon_style2 = 257 and
the third one as 258.

Is that correct?

Thank you
Claudia

Neil Hodgson

unread,
Mar 19, 2018, 7:10:09 AM3/19/18
to Scintilla mailing list
Hi Claudia,

> The style ids then, I assume, need to start with 0

Yes.

> So something like
>
> offset = SCI_ALLOCATEEXTENDEDSTYLES(3) //offset is set to 256
> SCI_ANNOTATIONSETSTYLEOFFSET(offset)
>
> anon_style1 = 0
> anon_style2 = 1
> anon_style3 = 2
>
> SCI_ANNOTATIONSETSTYLE(line_number, anon_style1)
>
> and under the hood anon_style1 is treated as 256, anon_style2 = 257 and
> the third one as 258.

Yes. Search for SCI_ANNOTATIONSETSTYLEOFFSET in SciTE and there’ll be similar code although SciTE sets styles for each annotation byte instead of for lines.

Neil

cfran...@gmail.com

unread,
Mar 19, 2018, 8:18:05 AM3/19/18
to scintilla-interest
Hello Neil,

thank you very much for your quick response and for the hint about SciTE,
which I checked and unfortunately this means something
is wrong with my code which I have to figure out. :-)

Btw. thank you for this awesome piece of software.
Claudia

cfran...@gmail.com

unread,
Apr 10, 2018, 10:32:20 AM4/10/18
to scintilla-interest

Hi Neil,

as I can't find an obvious error in my code I tried to do the same with lua and SciTE and it
seems that the result is the same so I assume I still have a understanding problem.
From my point of view I do, more or less, the same as what you do in SciTE C++ code.

The lua script I use is the following

-- Test annotation set with ... SetStyle

use_offset
= true
if use_offset == true then
    editor
:ReleaseAllExtendedStyles()
    style_offset
= editor:AllocateExtendedStyles(10)
    editor
.AnnotationStyleOffset = style_offset
    ERROR_MSG_ID
= 0
else
    ERROR_MSG_ID
= 60
end

print('style_offset:' .. editor.AnnotationStyleOffset)

editor
.StyleFore[ERROR_MSG_ID] = 0xaf
editor
.StyleBack[ERROR_MSG_ID] = 0xc1c1c1

editor
.AnnotationVisible = ANNOTATION_BOXED
editor
:AnnotationClearAll()
editor
.AnnotationText[0] = 'Just one line of info'
editor
.AnnotationStyle[0] = ERROR_MSG_ID
print('Done')

which works as long as I'm not using the offset functionality.

without_offset_test

But when I set use_offset = true then it styles id 0 instead of offset+0, like seen here

with_offset_test

May I ask you what I've misunderstood?

Thank you
Claudia



Neil Hodgson

unread,
Apr 10, 2018, 8:35:19 PM4/10/18
to scintilla...@googlegroups.com
Hi Claudia,

> style_offset = editor:AllocateExtendedStyles(10)
> editor.AnnotationStyleOffset = style_offset
> ERROR_MSG_ID = 0
> …
> editor.StyleFore[ERROR_MSG_ID] = 0xaf
> editor.StyleBack[ERROR_MSG_ID] = 0xc1c1c1

The first extended style is numbered style_offset so that is the style that should be set:

editor.StyleFore[style_offset] = 0xaf
editor.StyleBack[style_offset] = 0xc1c1c1

Neil

cfran...@gmail.com

unread,
Apr 11, 2018, 7:07:06 AM4/11/18
to scintilla-interest
Hi Neil,

yes, that solves it.
Thank you very much for all your help and advises very much appreciated.

Cheers
Claudia


Reply all
Reply to author
Forward
0 new messages