It shows the annotation for line 1 (Boo), but nothing for line 2 (Hoo). No errors in appear in the console, but the annotationSetStyles() statement has no effect.
Can anyone explain what I'm missing?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
David,
I don't think that Cell can be used in such a case as the Cell class seems not to provide any
functions which could convert the input and in addition scintilla documentation states,
that setting the text must be prior to setting styles. Let's see what Dave thinks.
My strategy is the following
ERROR_MSG_ID=20WARNING_MSG=21INFO_MSG=22editor.styleSetFore(ERROR_MSG_ID,(255,0,0))editor.styleSetBack(ERROR_MSG_ID,(0,0,0))editor.styleSetFore(WARNING_MSG,(255,255,0))editor.styleSetBack(WARNING_MSG,(0,0,0))editor.styleSetFore(INFO_MSG,(128,255,0))editor.styleSetBack(INFO_MSG,(0,0,0))defSetAnnotation(text,line):_text=u''styles=u''forl,sinsorted(text,key=lambdatup:tup[1]):_text+=lstyles+='{}'.format(chr(s))*len(l)editor.annotationSetText(line,_text[:-1])editor.annotationSetStyles(line,styles)editor.annotationSetVisible(2)annotation_text=[(u'error line\n',ERROR_MSG_ID),(u'warning line\n',WARNING_MSG),(u'info line\n',INFO_MSG),(u'another error line\n',ERROR_MSG_ID),(u'and another warning line\n',WARNING_MSG),]editor.annotationClearAll()editor.annotationSetVisible(0)SetAnnotation(annotation_text,20)#exampleannotationmessageatline19
Of course annotation_text gets created by a message parser automatically.
Cheers
Claudia
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yep, you're right, from the Scintilla Docs : "The text must be set first as it specifies how long the annotation is so how many bytes of styling to read."
And a big "thank you" for sharing your example Claudia, I hadn't been able to find any for annotationSetStyles.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to use annotationSetStyles() to create annotations using different styles, e.g. http://www.scintilla.org/annotations.png
I thought it would be similar to adding styled text to the console, but the following is not working:
It shows the annotation for line 1 (Boo), but nothing for line 2 (Hoo). No errors in appear in the console, but the annotationSetStyles() statement has no effect.
Can anyone explain what I'm missing?
I haven't used Cell class (to be honest wasn't even aware that it exists) but I use it
like this
Hope this is helpful for you.
Be aware that the document needs to get the focus to make it work.
Cheers
Claudia
Last edit: CFrank 2017-07-12
Claudia,
Thank you for your prompt reply, and putting me on the right path. I've got my demo working now with your help. :D
BTW, here is the thread detailing how to add styled text to the console using Cell().
I'm still curious though whether its possible to use Cell() with annotationSetStyles()... Perhaps Mr Brotherstone might chime in?
David,
I don't think that Cell can be used in such a case as the Cell class seems not to provide any
functions which could convert the input and in addition scintilla documentation states,
that setting the text must be prior to setting styles. Let's see what Dave thinks.
My strategy is the following
Of course annotation_text gets created by a message parser automatically.
Cheers
Claudia
Yep, you're right, from the Scintilla Docs : "The text must be set first as it specifies how long the annotation is so how many bytes of styling to read."
And a big "thank you" for sharing your example Claudia, I hadn't been able to find any for annotationSetStyles.