Style of annotation text

129 views
Skip to first unread message

mozers

unread,
Jun 1, 2009, 12:49:40 PM6/1/09
to scite-i...@googlegroups.com
Hello Scite-interest,

I want to set the annotation text's style of the second line but it does not work.
Please, correct my script:

scite.SendEditor(SCI_ANNOTATIONSETTEXT, 68, 'aaaa\nbbbbb\ncccccc')
scite.SendEditor(SCI_ANNOTATIONSETSTYLES, 3, "fore:#FFFF00,back:#FF0000")
scite.SendEditor(SCI_ANNOTATIONSETSTYLE, 2, 3)
scite.SendEditor(SCI_ANNOTATIONSETVISIBLE, 2)

--
mozers
<http://scite.net.ru>

Neil Hodgson

unread,
Jun 1, 2009, 7:22:02 PM6/1/09
to scite-i...@googlegroups.com
mozers :

> I want to set the annotation text's style of the second line but it does not work.
> Please, correct my script:
>
> scite.SendEditor(SCI_ANNOTATIONSETTEXT, 68, 'aaaa\nbbbbb\ncccccc')
> scite.SendEditor(SCI_ANNOTATIONSETSTYLES, 3, "fore:#FFFF00,back:#FF0000")

You can't send property strings - use an array of style bytes like
in SetStylingEx. You also need to use the same line number in your
calls.

> scite.SendEditor(SCI_ANNOTATIONSETSTYLE, 2, 3)
> scite.SendEditor(SCI_ANNOTATIONSETVISIBLE, 2)

Neil

Neil Hodgson

unread,
Jun 1, 2009, 7:54:36 PM6/1/09
to scite-i...@googlegroups.com
There is also bug #2789430 in 1.78 that is fixed in CVS that means
that SCI_ANNOTATIONSETSTYLE doesn't work with multi-line annotations.
For 1.78 you will only be able to use SCI_ANNOTATIONSETSTYLES.

Neil

mozers

unread,
Jun 2, 2009, 1:30:18 PM6/2/09
to Neil Hodgson
Tuesday, June 2, 2009, 3:22:02 AM, Neil wrote:

>> scite.SendEditor(SCI_ANNOTATIONSETSTYLES, 3, "fore:#FFFF00,back:#FF0000")
> You can't send property strings - use an array of style bytes like
> in SetStylingEx. You also need to use the same line number in your
> calls.

> There is also bug #2789430 in 1.78 that is fixed in CVS that means
> that SCI_ANNOTATIONSETSTYLE doesn't work with multi-line annotations.

Thanks for advice.
I compiled last version from CVS.
Now this script shows the annotation (all lines) in the set style (used style 12 lua):
--------------------------------------------
annotation_line = 5
annotation_text = 'line one\nline two\nline three'
annotation_style = 12

scite.SendEditor(SCI_ANNOTATIONSETTEXT, annotation_line, annotation_text)
scite.SendEditor(SCI_ANNOTATIONSETSTYLE, annotation_line, annotation_style)
scite.SendEditor(SCI_ANNOTATIONSETVISIBLE, ANNOTATION_BOXED)
--------------------------------------------

What is the way to show the second line of the annotation in the other style (e.g. 3) I do not understand :(

--
mozers

Neil Hodgson

unread,
Jun 2, 2009, 6:35:53 PM6/2/09
to scite-i...@googlegroups.com
mozers:

> What is the way to show the second line of the annotation in the other style (e.g. 3) I do not understand :(

If there are multiple styles within one annotation then set every
style byte with SCI_ANNOTATIONSETSTYLES:

scite.SendEditor(SCI_ANNOTATIONSETTEXT, annotation_line, "ab\ncd")
scite.SendEditor(SCI_ANNOTATIONSETSTYLES, annotation_line,
"\001\001\001\002\002")

Neil

mozers

unread,
Jun 3, 2009, 1:46:46 AM6/3/09
to Neil Hodgson
Wednesday, June 3, 2009, 2:35:53 AM, Neil wrote:

> If there are multiple styles within one annotation then set every
> style byte with SCI_ANNOTATIONSETSTYLES:
> scite.SendEditor(SCI_ANNOTATIONSETTEXT, annotation_line, "ab\ncd")
> scite.SendEditor(SCI_ANNOTATIONSETSTYLES, annotation_line,
> "\001\001\001\002\002")

Thank you very much.
Everything works fine.

---------------------------------------------------------------------------
local function SetAnnotation (text, line)
local str = ''
local style = ''
for i = 1, #text, 2 do
str = str..text[i]
style = style..string.char(text[i+1]):rep(#text[i])
end
scite.SendEditor(SCI_ANNOTATIONSETTEXT, line, str)
scite.SendEditor(SCI_ANNOTATIONSETSTYLES, line, style)
scite.SendEditor(SCI_ANNOTATIONSETVISIBLE, ANNOTATION_BOXED)
end

local annot_line = 5
local annot_text = { -- text_line, style_line
'annotation line one\n', 4,
'annotation line two\n', 3,
'annotation line three', 12
}

SetAnnotation (annot_text, annot_line)
---------------------------------------------------------------------------

--
mozers

Reply all
Reply to author
Forward
0 new messages