[QScintilla] Fw: setAutoIndentStyle doesn't work
kristof.mulier at telenet.be
kristof.mulier at telenet.be
Mon May 15 09:38:55 BST 2017
Hi Phil and Matic,
I have adapted the "MyLexer" code according to your mails. I've added the "blockStart" and "blockEnd" functions:
--------------------------------------------------------------------------------------
class MyLexer(QsciLexerCustom):
def __init__ ( self , parent):
super (MyLexer, self ). __init__ (parent)
# Initialize styles
# ----------------------------
self .setColor(QColor( "#ff000000" ), 0 ) # Style 0: black
self .setColor(QColor( "#ff7f0000" ), 1 ) # Style 1: red
self .setColor(QColor( "#ff0000bf" ), 2 ) # Style 2: blue
self .setColor(QColor( "#ff007f00" ), 3 ) # Style 3: green
[...]
# Auto indent
# ------------
#self.setAutoIndentStyle(QsciScintilla.AiOpening | QsciScintilla.AiClosing)
self .setAutoIndentStyle(QsciScintilla.AiMaintain)
''''''
def blockStart( self ):
# Define space separated string of indentation symbols
return "{ ( :"
''''''
def blockEnd( self ):
# Define space separated string of indentation symbols
return "} )"
''''''
[...]
''' End class '''
--------------------------------------------------------------------------------------
Unfortunately, it still doesn't work. Do you have any idea why?
Thank you very much for your help. Please feel free to post your answers on the StackOverflow question:
http://stackoverflow.com/questions/43962669/setautoindentstyle-on-the-qscintilla-lexer-doesnt-work
In this way, many more people can benefit from it ;-)
Kind greetings,
Kristof Mulier
Van: "kukovecmatic" <kukovecmatic at hotmail.com>
Aan: "QScintilla" <qscintilla at riverbankcomputing.com>
Verzonden: Maandag 15 mei 2017 00:24:01
Onderwerp: [QScintilla] Fw: setAutoIndentStyle doesn't work
> On 14 May 2017, at 11:26 am, kristof.mulier at telenet.be wrote:
> >
> > Dear QScintilla users,
> >
> > Automatic indentation is a very nice feature offered by QScintilla. When inserting a new line, automatic indentation pushes the cursor to the same indentation level as the previous one. You have two options to switch on this feature: (1) call the function setAutoIndent(True) on the QsciScintilla editor or (2) call the function setAutoIndentStyle(..) on the lexer.
> >
> > The first option works. The second doesn't. For full details on the problem, please take a look at the following StackOverflow question:
> >
> > http://stackoverflow.com/questions/43962669/setautoindentstyle-on-the-qscintilla-lexer-doesnt-work
> >
> > Do you know the answer?
>
> You have to implement the various block method (blockStart(), blockEnd() etc).
>
> Phil
Hey Phil,
Tried implementing blockStart() and blockEnd() , but it throws a TypeError if using for example:
[ https://www.riverbankcomputing.com/mailman/listinfo/qscintilla ]
def blockStart(self):
return "{"
def blockEnd(self):
return "}"
With a bit of trial&error I found that the methods need to return a tuple of (bytes, int). Why?
Thanks,
Matic
BQ_BEGIN
BQ_END
_______________________________________________
QScintilla mailing list
QScintilla at riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/qscintilla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20170515/f4ae7566/attachment-0001.html>
More information about the QScintilla
mailing list