On Sun, Oct 25, 2009 at 18:19, Aaron R. Short <[email protected]> wrote:
>
> Well that's disappointing I had hoped for a magic bullet but oh well. maybe 
> you can help me figure it out. From the example I can find
>
> http://editra.org/forum/viewtopic.php?f=3&t=141
>
> it seems that all that's needed is to use the wxSTC_LEX_CONTAINER  as the 
> lexer and then bind the wx.stc.EVT_STC_STYLENEEDED event to a method and then 
> use that method to set the styling.
>
> from what I can see in dabo\ui\uiwx\dEditor.py
>
>
>
>
> The following seems to set the STC_LEX_CONTAINER if the lexer isn't found
> class StyleTimer(dTimer.dTimer):
>    def afterInit(self):
>        # Default timer interval
>        self.styleTimerInterval = 50
>        self.super()
>        self.bindEvent(dEvents.Hit, self.onHit)
>        self.mode = "container"
>
>    def onHit(self, evt):
>        #self.Interval = 0
>        self.stop()
>        if self.mode in LexerDic.keys():
>            if self.Parent:
>                self.Parent.SetLexer(LexerDic[self.mode])
>            self.mode = "container"
>            self.Interval = self.styleTimerInterval
>        else:
>            if self.Parent:
>                self.Parent.SetLexer(stc.STC_LEX_CONTAINER)
>
>    def setSyntaxColoring(self, color=None):
>        """Sets the appropriate lexer for syntax coloring."""
>        lex = self.Language.lower()
>        if color and lex:
>            if lex in LexerDic.keys():
>                self.SetLexer(LexerDic[lex])
>                if lex == "python":
>                    if not self._keyWordsLanguage == lex:
>                        self.SetKeyWords(0, " ".join(keyword.kwlist))
>                        self._keyWordsLanguage = lex
>                else:
>                    # Until we can get other keyword lists, we need to clear 
> this out
>                    self.SetKeyWords(0, "")
>                    self._keyWordsLanguage = ""
>                dabo.ui.callAfter(self.Colourise, 0, 1)
>        else:
>            self.ClearDocumentStyle()
>            self.SetLexer(stc.STC_LEX_CONTAINER)
>
>
>
> And the init binds the event to OnStyleNeeded
>
> def __init__(self, parent, properties=None, attProperties=None, *args, 
> **kwargs):
>     ...
>    self.Bind(stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded)
>    ...
>
> and the OnStyleNeeded method calls the styleTimer Unfortunatly I can't 
> overwrite the OnStyleNeeded method in the dabo ClassDesigner. It's just not 
> available.
>    def OnStyleNeeded(self, evt):
>        if not self._syntaxColoring:
>            return
>        self._styleTimer.mode = self.Language.lower()
>        self._styleTimer.start()
>
> hmmmm. what if I tried binding the EVT_STC_STYLENEEDED to a new OnStyleNeeded 
> method during initialization and then try playing with that? Does that sound 
> right? It seems like you've got a lot of things going on so I wanted to ask 
> about what your intentions were but it sounds like you didn't have any 
> regarding a custom lexer. Any more thoughts?

What I would do is set the style lexer to STC_LEX_CONTAINER and then
set the individual WX Style flags for the various style properties to
what you need.  It's ugly but the only way to do it at the moment.
The Editra source code has good examples of doing this in wx.

I don't have time to get a more detailed explanation at the moment,
but I will see what I can do about getting it to you tonight.

Regards,

Nate


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to