[Eric] Help about the code of Eric

Detlev Offenbach detlev at die-offenbachs.de
Sun Jul 12 11:00:12 BST 2009


Hi,

it looks as if you copied the code from eric4 without adjusting it to 
QsciLexerCustom. Please note that eric's LexerPygment  was written before 
QsciLexerCustom was introduced and uses routines of my QScintilla 
compatibility class, that were written by and are now included in the custom 
lexer class. You should study the API description and change your code 
accordingly.

Regards,
Detlev

On Samstag, 11. Juli 2009, projetmbc wrote:
> Hello,
> I finally decide to try understand your code about LexerPygment so as to
> define a custom lexer via Qsci.QsciLexerCustom. Here is the code I've made.
>
> The problem with that lexer is that it doesn't colorize in red the line
> which begins by #. Do you see why ?
>
> =====================================================
> class myLexer(Qsci.QsciLexerCustom):
>     def description(self, style):
>         if style == 0:
>             return 'ID_DEFAULT'
>         if style == 1:
>             return 'ID_COMMENT'
>         return ''
>
>     def defaultColor(self, style):
>         if style==ID_DEFAULT:
>             return QtGui.QColor(0,0,255)
>         if style==ID_COMMENT:
>             return QtGui.QColor(255,0,0)
>         return QtGui.QColor(0,0,0)
>
>     def styleText(self, start, end):
> # Taken from the source code of Eric.
>         self.editor.startStyling(start)
>         if self.editor.text()[0] == '#':
>             self.editor.setStyling(end, ID_COMMENT)
>             self.editor.startStyling(start+end)
>         else:
>             self.editor.setStyling(end+1, ID_DEFAULT)
> =====================================================
>
> Can you help to find the mistakes I've made ?
>
> Best regards.
> Christophe.



-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the Eric mailing list