Re StyledTextCtrl Syntax Highlighting

Thanks Josiah,

I really did some web-research before I wrote my question. And I am stuck.
If you could only let me know about some clear description of how the whole
highlighting mechanism works. What is the relation between
the lexer and the style bits? What are the preconditions for .Colourise(...)
to work? Why would I need to provide 'keywords' if the lexer is
language specific?
Is there something like a 'lexer-run'. Does it need special events before it
gets working?

There are a lot of things that I cannot find a rhyme or reason for it.

Regards

Frank.

Be careful when you reply to a message, email address spelling counts :wink:

Thanks Josiah,

I really did some web-research before I wrote my question. And I am stuck.
If you could only let me know about some clear description of how the whole
highlighting mechanism works. What is the relation between
the lexer and the style bits? What are the preconditions for .Colourise(...)
to work? Why would I need to provide 'keywords' if the lexer is
language specific?
Is there something like a 'lexer-run'. Does it need special events before it
gets working?

There are a lot of things that I cannot find a rhyme or reason for it.

There is source available for editors that use the stc for styling.
In my case, I use the following set of operations...

    stc.StyleResetDefault()
    stc.ClearDocumentStyle()
    stc.SetLexer(lexer)
    stc.SetKeyWords(0, KEYWORDS)
    stc.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, BASE_STYLE)
    stc.StyleClearAll()
    stc.SetBackgroundColour(BACKGROUNDCOLOR)
    stc.Colourise(0, stc.GetTextLength())

That block of code (along with a few other bits and pieces for setting
styles) handles the full switching of styling from any one language to
any other language that the stc supports. It's not necessarily
minimal, but it works for me.

- Josiah

···

On Thu, Jul 3, 2008 at 1:11 AM, Frank-Rene Schäfer <fschaef@googlemail.com> wrote:

I really did some web-research before I wrote my question. And I am stuck.
If you could only let me know about some clear description of how the whole
highlighting mechanism works. What is the relation between
the lexer and the style bits? What are the preconditions for .Colourise(...)
to work? Why would I need to provide 'keywords' if the lexer is
language specific?
Is there something like a 'lexer-run'. Does it need special events before it
gets working?
There are a lot of things that I cannot find a rhyme or reason for it.

Did your research find the Yellowbrain guide to wxPython that
is at http://www.yellowbrain.com/stc
? It has a lot of information but has not been updated for several
years.
Lists of keywords and other styling information are available for the
Scite editor that is a demonstration of the Scintilla Text Control. For
example, Google for cpp.properties.
My IDE, that supports 15 languages, might be of interest as it has some
advanced features, such as smart paste, and the coding deals
with some problems that I encountered. The drag-and-drop feature within
STC was not working but has now been fixed. I do not know when it will
be released in wxPython. My IDE can be found at:

http://luke-sdk.berlios.de

Christopher Thoday

Software Engineer

···

fschaef@googlemail.com

Frank-Rene Schäfer wrote:

Why would I need to provide 'keywords' if the lexer is language specific?

There are a lot of things that I cannot find a rhyme or reason for it.

It is a good thing that STC separates the lexer from the keyword list. This means that languages with the same syntax but different keywords can share the same lexer. The lexer does not have to be modified if the keyword list for a language is extended.

Christopher Thoday
Software Engineer