> > On 14 May 2017, at 11:24 pm, Matic Kukovec <[email protected]> wrote: > > > > > > > > > > On 14 May 2017, at 11:26 am, [email protected] 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 > > Hey Phil, > > I'm assuming it means that it returns a > tuple(bytesstring_of_block_start_chars, pointer_to_style), because lexers > that implement the blockStart method (like QsciLexerPython) return (None, > some_large_number). But why do they always return the byte_string as None? > > Anyway, I edited the blockStart() and blockEnd() methods of my custom lexer > to: > > def blockStart(self): > return b'{', 0 > > def blockStart(self): > return b'}', 0 > > and set the qscintilla editors setAutoIndent(True) and my custom lexers > setAutoIndentStyle(QsciScintilla.AiOpening | QsciScintilla.AiOpening). Now > the next line after inserting a '{' doesn't indent (like in the QsciLexerCPP, > for example), but it does unindent when inserting a '}'? > Example: > > if (test) > { > |<- doesn't indent > > Then I manually indent: > > if (test) > { > |<- manual indent with the tab key > test line added; > > Inserting the '}' character unindents automatically: > > if (test) > { > > test line added; > } <- automatically unindented from the previous line's indentation level > > I really have no idea if I'm doing something wrong or if I'm misunderstanding > something, could you please help? > > P.S.: > I'm also helping Kristof, so that is why we are both posting separately on > the same topic. > > Matic
Hey Phil, I realize that I have no idea how this autoIndentStyle works. Could you explain step-by-step what and how things need to be implemented for this functionality to work correctly? Thanks, Matic
_______________________________________________ QScintilla mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/qscintilla
