ANSI escapes in ErrorList

50 views
Skip to first unread message

Paul K

unread,
Oct 10, 2017, 11:35:00 AM10/10/17
to scintilla-interest
Hi Neil,

I'm trying to use ANSI escapes that were added back in 3.6.1 and can't figure out why they are not working in my case. I'm using 3.6.6 version (as part of wxwidgets) and since the escape handling was added in 3.6.1 and updated in 3.6.3, I'd expect the following fragment to work:

e:SetText("some text \027[1;31mXYZ\027[0m and more")
e:SetLexer(wxstc.wxSTC_LEX_ERRORLIST)
e:SetProperty("lexer.errorlist.escape.sequences","1")

However, the editor only shows the text as is: `some text [1;31mXYZ [0m and more` (with ESC marked in bold as a special character). Am I missing some additional call to turn it on? I also tried adding Colourise(0, -1), but it hasn't changed the result.

Paul.

Colomban Wendling

unread,
Oct 10, 2017, 2:46:38 PM10/10/17
to scintilla...@googlegroups.com
Hi Paul,

Le 10/10/2017 à 08:35, Paul K a écrit :
> Hi Neil,
>
> I'm trying to use ANSI escapes that were added back in 3.6.1 and can't
> figure out why they are not working in my case. I'm using 3.6.6 version
> (as part of wxwidgets) and since the escape handling was added in 3.6.1
> and updated in 3.6.3, I'd expect the following fragment to work:
>
> e:SetText("some text \027[1;31mXYZ\027[0m and more")
> e:SetLexer(wxstc.wxSTC_LEX_ERRORLIST)
> e:SetProperty("lexer.errorlist.escape.sequences","1")
>
> However, the editor only shows the text as is: `some text [1;31mXYZ [0m
> and more` (with ESC marked in bold as a special character).

You're not using the correct escape sequence. "\027" is the octal
representation of decimal 23 or hex 0x17, which is ASCII ETB, not ESC.
ESC is octal 33, decimal 27 or hex 0x1B, so write it either as "\033" or
"\x1B" (I guess the octal version is more common, so I'd go for "\033").

Regards,
Colomban

Paul K

unread,
Oct 10, 2017, 4:21:54 PM10/10/17
to scintilla-interest
Hi Colomban,

> You're not using the correct escape sequence.  "\027" is the octal 
> representation of decimal 23 or hex 0x17, which is ASCII ETB, not ESC. 

Thank you for checking, but in this case the code is correct. This is a snippet from a Lua code and both \027 and \27 represent the same decimal code for \0x1B, so it shouldn't be the reason (and I confirmed that the resulting code looks like a special character [ESC] in Scintilla.

Paul.

Lex Trotman

unread,
Oct 10, 2017, 7:11:31 PM10/10/17
to scintilla...@googlegroups.com
Try setting the property to the number 1 not the string "1".
> --
> You received this message because you are subscribed to the Google Groups
> "scintilla-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scintilla-inter...@googlegroups.com.
> To post to this group, send email to scintilla...@googlegroups.com.
> Visit this group at https://groups.google.com/group/scintilla-interest.
> For more options, visit https://groups.google.com/d/optout.

Paul K

unread,
Oct 10, 2017, 9:12:53 PM10/10/17
to scintilla-interest
Hi Lex,

> Try setting the property to the number 1 not the string "1". 

The API I'm using (wxlua) expects a string parameter there ("wxStyledTextCtrl::SetProperty(wxStyledTextCtrl(self), string, string)"), so it doesn't accept a number. I've tested other properties and they all work fine when passing "1" (for example, `editor:SetProperty("fold", "1")`).

Paul.

Neil Hodgson

unread,
Oct 14, 2017, 2:40:34 AM10/14/17
to scintilla...@googlegroups.com
Paul K:

> e:SetText("some text \027[1;31mXYZ\027[0m and more")
> e:SetLexer(wxstc.wxSTC_LEX_ERRORLIST)
> e:SetProperty("lexer.errorlist.escape.sequences","1")
>
> However, the editor only shows the text as is: `some text [1;31mXYZ [0m and more` (with ESC marked in bold as a special character). Am I missing some additional call to turn it on? I also tried adding Colourise(0, -1), but it hasn't changed the result.

Print out the values of the style bytes to check.

Neil

Paul K

unread,
Oct 14, 2017, 8:23:33 PM10/14/17
to scintilla-interest
Neil:
I would have tried that, but unfortunately wxlua doesn't provide GetStyledText method (it's not implemented). Are there any other options for me to check?

Paul.

Colomban Wendling

unread,
Oct 14, 2017, 11:35:25 PM10/14/17
to scintilla...@googlegroups.com
Le 14/10/2017 à 17:23, Paul K a écrit :
>>> Print out the values of the style bytes to check.
>
> I would have tried that, but unfortunately wxlua doesn't provide
> GetStyledText method (it's not implemented). Are there any other options
> for me to check?

SCI_GETSTYLEAT (http://scintilla.org/ScintillaDoc.html#SCI_GETSTYLEAT)

Paul K

unread,
Oct 15, 2017, 12:35:30 AM10/15/17
to scintilla-interest
Hi Colomban,


Indeed; I forgot about GetStyleAt method. I got the styles and it looks like everything is styled as it's supposed to, but I misunderstood how it works. Here is the output for the simply fragment I have (position, character, style-in-hex, style-in-dec):

0 t 0x0 0
1 e 0x0 0
2 x 0x0 0
3 t 0x0 0
4 0x0 0
5 0x17 23
6 [ 0x17 23
7 1 0x17 23
8 ; 0x17 23
9 3 0x17 23
10 1 0x17 23
11 m 0x17 23
12 X 0x31 49
13 Y 0x31 49
14 Z 0x31 49
15 0x17 23
16 [ 0x17 23
17 0 0x17 23
18 m 0x17 23
19 0x28 40
20 m 0x28 40
21 o 0x28 40
22 r 0x28 40
23 e 0x28 40

It looks like to get the desired I result, I need to hide the text with style #23 and use the right colors for styles #40-55 and everything will be good.

Thanks everyone for the suggestions!

Paul.
Reply all
Reply to author
Forward
0 new messages