<html><body><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #000000"><div><style style="display: none;" data-mce-style="display: none;"><!-- P {margin-top:0;margin-bottom:0;} --></style></div><div>Hi Phil and Matic,</div><div><br data-mce-bogus="1"></div><div>I have adapted the "MyLexer" code according to your mails. I've added the "blockStart" and "blockEnd" functions:</div><div><br data-mce-bogus="1"></div><div><pre style="background-color: #ffffff; color: #000000; font-family: 'Consolas'; font-size: 11.3pt;" data-mce-style="background-color: #ffffff; color: #000000; font-family: 'Consolas'; font-size: 11.3pt;"><span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">--------------------------------------------------------------------------------------<br>class </span>MyLexer(QsciLexerCustom):<br><br>    <span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">def </span><span style="color: #b200b2;" data-mce-style="color: #b200b2;">__init__</span>(<span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>, parent):<br>        <span style="color: #000080;" data-mce-style="color: #000080;">super</span>(MyLexer, <span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>).<span style="color: #b200b2;" data-mce-style="color: #b200b2;">__init__</span>(parent)<br><br>        <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Initialize styles<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        # ----------------------------<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.setColor(QColor(<span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"#ff000000"</span>), <span style="color: #0000ff;" data-mce-style="color: #0000ff;">0</span>)   <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Style 0: black<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.setColor(QColor(<span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"#ff7f0000"</span>), <span style="color: #0000ff;" data-mce-style="color: #0000ff;">1</span>)   <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Style 1: red<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.setColor(QColor(<span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"#ff0000bf"</span>), <span style="color: #0000ff;" data-mce-style="color: #0000ff;">2</span>)   <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Style 2: blue<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.setColor(QColor(<span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"#ff007f00"</span>), <span style="color: #0000ff;" data-mce-style="color: #0000ff;">3</span>)   <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Style 3: green<br></span><span style="color: rgb(64, 159, 71);" data-mce-style="color: #409f47;">        </span><span style="color: rgb(0, 0, 0);" data-mce-style="color: #000000;"><strong>[...]</strong></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"><br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"><br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        # Auto indent<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        # ------------<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        #self.setAutoIndentStyle(QsciScintilla.AiOpening | QsciScintilla.AiClosing)<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.setAutoIndentStyle(QsciScintilla.AiMaintain)<br><br>    <span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">''''''<br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;"><br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">    </span><span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">def </span>blockStart(<span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>):<br>        <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Define space separated string of indentation symbols<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">return </span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"{ ( :"<br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">    ''''''<br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;"><br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">    </span><span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">def </span>blockEnd(<span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>):<br>        <span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;"># Define space separated string of indentation symbols<br></span><span style="color: #409f47; font-style: italic;" data-mce-style="color: #409f47; font-style: italic;">        </span><span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">return </span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">"} )"<br></span><span style="color: #008080; font-weight: bold;" data-mce-style="color: #008080; font-weight: bold;">    ''''''<br><br>    <span style="color: rgb(0, 0, 0);" data-mce-style="color: #000000;">[...]</span><br><br>''' End class '''<br><!--StartFragment--></span></pre><pre data-mce-style="background-color: #ffffff; color: #000000; font-family: 'Consolas'; font-size: 11.3pt;" style="color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; background-color: rgb(255, 255, 255); font-family: Consolas; font-size: 11.3pt;"><span data-mce-style="color: #000080; font-weight: bold;" style="color: rgb(0, 0, 128); font-weight: bold;">--------------------------------------------------------------------------------------</span></pre></div><div><br></div><div>Unfortunately, it still doesn't work. Do you have any idea why?</div><div>Thank you very much for your help. Please feel free to post your answers on the StackOverflow question: </div><div><br data-mce-bogus="1"></div><div>http://stackoverflow.com/questions/43962669/setautoindentstyle-on-the-qscintilla-lexer-doesnt-work<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>In this way, many more people can benefit from it ;-)</div><div><br data-mce-bogus="1"></div><div>Kind greetings,</div><div><br data-mce-bogus="1"></div><div>Kristof Mulier</div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>Van: </b>"kukovecmatic" <kukovecmatic@hotmail.com><br><b>Aan: </b>"QScintilla" <qscintilla@riverbankcomputing.com><br><b>Verzonden: </b>Maandag 15 mei 2017 00:24:01<br><b>Onderwerp: </b>[QScintilla] Fw:  setAutoIndentStyle doesn't work<br></div><div><br></div><div data-marker="__QUOTED_TEXT__">


<div id="divtagdefaultwrapper" style="font-size: 12pt; color: #000000; font-family: Calibri,Arial,Helvetica,sans-serif;" dir="ltr" data-mce-style="font-size: 12pt; color: #000000; font-family: Calibri,Arial,Helvetica,sans-serif;">
<p><br>
</p>
<div style="color: #000000;" data-mce-style="color: #000000;">
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: #000000; font-family: Calibri,Arial,Helvetica,sans-serif;" data-mce-style="font-size: 12pt; color: #000000; font-family: Calibri,Arial,Helvetica,sans-serif;">
> On 14 May 2017, at 11:26 am, kristof.mulier@telenet.be wrote:<br>
<div>> > <br>
> > Dear QScintilla users,<br>
> > <br>
> > 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.<br>
> > <br>
> > The first option works. The second doesn't. For full details on the problem, please take a look at the following StackOverflow question:<br>
> > <br>
> > http://stackoverflow.com/questions/43962669/setautoindentstyle-on-the-qscintilla-lexer-doesnt-work<br>
> > <br>
> > Do you know the answer?<br>
> <br>
> You have to implement the various block method (blockStart(), blockEnd() etc).<br>
> <br>
> Phil</div>
<br>
<p>Hey Phil,</p>
<p><br>
</p>
<p>Tried implementing <span>blockStart() and blockEnd()</span>, but it throws a TypeError if using for example:</p>
<div style="color: #000000;" data-mce-style="color: #000000;"><span size="2" data-mce-style="font-size: small;" style="font-size: small;"><span style="font-size: 10pt;" data-mce-style="font-size: 10pt;">
<div class="PlainText"><a href="https://www.riverbankcomputing.com/mailman/listinfo/qscintilla" target="_blank"></a>
<blockquote>
<div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">def blockStart(self):</span><br>
<span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">        return "{"<br>
<br>
<span size="2" data-mce-style="font-size: small;" style="font-size: small;"><span style="font-size: 10pt;" data-mce-style="font-size: 10pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">def blockEnd(self):</span><br>
<span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">        return "}"</span></span></span><br>
</span></div>
</blockquote>
<span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"></span>
<div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">With a bit of trial&error I found that the methods need to return a tuple of (bytes, int). Why?<br>
<br>
Thanks,<br>
Matic<br>
</span></div>
<blockquote>

</blockquote>
</div>
</span></span></div>
</div>
</div>
</div>
</div>


<br>_______________________________________________<br>QScintilla mailing list<br>QScintilla@riverbankcomputing.com<br>https://www.riverbankcomputing.com/mailman/listinfo/qscintilla<br></div></div></body></html>