[QScintilla] setAutoIndentStyle doesn't work

Phil Thompson phil at riverbankcomputing.com
Mon May 15 08:47:00 BST 2017


On 14 May 2017, at 11:24 pm, Matic Kukovec <kukovecmatic at hotmail.com> wrote:
> 
> 
> > 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:
> 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?

http://pyqt.sourceforge.net/Docs/QScintilla2/classQsciLexer.html#a7c99eb2877dc6a9762815bc0471f0c36

Phil


More information about the QScintilla mailing list