Discussion:
scintilla (wxStyledTextCtrl) XML lexer
(too old to reply)
Francesco Montorsi
2006-11-22 21:05:28 UTC
Permalink
Hi,

I'm trying to use (without great success :() wxStyledTextCtrl: I need to
show to the user (as read-only text) some XML code (and I managed to get here),
and then tell the control to highlight the keywords I want (the XML I need to
display is full of custom keywords parsed by my code).

I have problems telling the wxStyledTextCtrl to colour my keywords with wanted
colours:

StyleSetForeground(1, wxColour (_T("DARK GREY")));
StyleSetForeground(2, wxColour (_T("GREEN")));
StyleSetForeground(3, wxColour (_T("BLUE")));

SetKeyWords(1, g_keywords);
SetKeyWords(2, g_subkeywords);
SetKeyWords(3, g_properties);

only displays the 3rd set of keywords in BLUE. All others are ignored...

Any hint?

Thanks,
Francesco



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-***@lists.wxwidgets.org
For additional commands, e-mail: wx-users-***@lists.wxwidgets.org
Robin Dunn
2006-11-23 00:30:46 UTC
Permalink
Post by Francesco Montorsi
Hi,
I'm trying to use (without great success :() wxStyledTextCtrl: I need
to show to the user (as read-only text) some XML code (and I managed to
get here), and then tell the control to highlight the keywords I want
(the XML I need to display is full of custom keywords parsed by my code).
I have problems telling the wxStyledTextCtrl to colour my keywords with
StyleSetForeground(1, wxColour (_T("DARK GREY")));
StyleSetForeground(2, wxColour (_T("GREEN")));
StyleSetForeground(3, wxColour (_T("BLUE")));
SetKeyWords(1, g_keywords);
SetKeyWords(2, g_subkeywords);
SetKeyWords(3, g_properties);
only displays the 3rd set of keywords in BLUE. All others are ignored...
The keyword list numbers and the style numbers do not equate with each
other. For the styles in the HTML/XML lexer you want to use the
wxSTC_H_* constants. With a quick look at the LexHTML.cxx file it looks
like it uses the wxSTC_H_ATTRIBUTE style for keywords (which has a value
of 3) and the other keyword lists are used for things like embedded
javascript or php.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-***@lists.wxwidgets.org
For additional commands, e-mail: wx-users-***@lists.wxwidgets.org
John Labenski
2006-11-26 19:54:21 UTC
Permalink
Post by Robin Dunn
Post by Francesco Montorsi
Hi,
I'm trying to use (without great success :() wxStyledTextCtrl: I need
to show to the user (as read-only text) some XML code (and I managed to
get here), and then tell the control to highlight the keywords I want
(the XML I need to display is full of custom keywords parsed by my code).
I have problems telling the wxStyledTextCtrl to colour my keywords with
StyleSetForeground(1, wxColour (_T("DARK GREY")));
StyleSetForeground(2, wxColour (_T("GREEN")));
StyleSetForeground(3, wxColour (_T("BLUE")));
SetKeyWords(1, g_keywords);
SetKeyWords(2, g_subkeywords);
SetKeyWords(3, g_properties);
only displays the 3rd set of keywords in BLUE. All others are ignored...
The keyword list numbers and the style numbers do not equate with each
other. For the styles in the HTML/XML lexer you want to use the
wxSTC_H_* constants. With a quick look at the LexHTML.cxx file it looks
like it uses the wxSTC_H_ATTRIBUTE style for keywords (which has a value
of 3) and the other keyword lists are used for things like embedded
javascript or php.
Take a look at this file which is derived from the scite 'properties'
files. Those seem to be the only place to get this information.

Search for STE_LexerStyles_STE_LANG_HTML. Ignore that they're all
#defines, that's just to make it easy to strip out the lexer info you
don't want.
http://wxcode.cvs.sourceforge.net/wxcode/wxCode/components/wxstedit/src/stelangs.cpp?view=markup

If I understand correctly you have to use the HTML lexer and the order
of the struct is the order that you have to define the elements for
StyleSetXXX,

Hope this helps,
John Labenski

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-***@lists.wxwidgets.org
For additional commands, e-mail: wx-users-***@lists.wxwidgets.org
Loading...