[QScintilla] Re: QScintilla feature request (minor change)
Detlev Offenbach
detlev at die-offenbachs.de
Mon Nov 17 21:29:09 GMT 2008
On Montag, 17. November 2008, Phil Thompson wrote:
> On Mon, 17 Nov 2008 22:07:40 +0100, Detlev Offenbach
>
> <detlev at die-offenbachs.de> wrote:
> > Hi,
> >
> > that would be fine with me. When can I get this because I am currently in
> > the
> > process of writing a custom lexer for Django template highlighting (got a
> > few
> > requests for that and didn't find a suitable way until last weekend).
>
> Even
>
> > an
> > oldie like me has to learn new stuff ;-)
>
> I don't plan on a new QScintilla release for a while. What I'd prefer is
> that you go through the pain of working out what a good API for writing
> custom lexers would be. I can then use that as a basis for
> QsciLexerContainer.
>
> Phil
Currently my custom lexer (for Django) is a standard Lexer (derived from
QsciLexer) that has one additional method called "styleText(start, end)".
That method is called from within the editor component by the following code
def __styleNeeded(self, position):
"""
Private slot to handle the need for more styling.
@param position end position, that needs styling (integer)
"""
self.lexer_.styleText(self.getEndStyled(), position)
When I set a custom lexer, the responsibility for styling is transfered to the
container and the "SCN_STYLENEEDED(int)" signal is connected to this method.
QsciScintilla would need the following additional methods:
def startStyling(self, pos, mask):
"""
Public method to prepare styling.
@param pos styling positition to start at (integer)
@param mask mask of bits to use for styling (integer)
"""
self.SendScintilla(QsciScintilla.SCI_STARTSTYLING, pos, mask)
def setStyling(self, length, style):
"""
Public method to style some text.
@param length length of text to style (integer)
@param style style to set for text (integer)
"""
self.SendScintilla(QsciScintilla.SCI_SETSTYLING, length, style)
I think thats it. At least that does the trick for me. A new snapshot with the
QsciLexerContainer would be fine for me as well ;-)
Regards,
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the QScintilla
mailing list