<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 14.8.2014 11:05, Phil Thompson
wrote:<br>
</div>
<blockquote
cite="mid:96f6c2e32adbb5c38d7f7015b3134449@www.riverbankcomputing.com"
type="cite">On 08/08/2014 11:25 pm, Matic Kukovec wrote: <br>
<blockquote type="cite">The last 5 lines of the function are at
the same indentation level as <br>
the others, <br>
Thunderbird just messed up the indentation. <br>
Sorry. <br>
<br>
On 9.8.2014 0:19, Matic Kukovec wrote: <br>
<blockquote type="cite">Hi guys, <br>
<br>
I have a PyQt4 application with a QScintilla2 editor with
Python3 and the following function: <br>
def create_hotspot(node_tab): <br>
#Create the hotspot boundaries <br>
hotspot_line = node_tab.lines()-2 <br>
hotspot_first_ch =
node_tab.text(hotspot_line).index("-") <br>
hotspot_length =
node_tab.lineLength(hotspot_line) <br>
hotspot_start =
node_tab.positionFromLineIndex(hotspot_line, hotspot_first_ch)
<br>
hotspot_end =
node_tab.positionFromLineIndex(hotspot_line, hotspot_length) <br>
#Style the hotspot <br>
node_tab.SendScintilla(PyQt4.Qsci.QsciScintillaBase.SCI_STYLESETHOTSPOT,
2, True) <br>
node_tab.SendScintilla(PyQt4.Qsci.QsciScintillaBase.SCI_SETHOTSPOTACTIVEFORE,
True, 0xff0000) <br>
node_tab.SendScintilla(PyQt4.Qsci.QsciScintillaBase.SCI_SETHOTSPOTACTIVEUNDERLINE,
True) <br>
node_tab.SendScintilla(PyQt4.Qsci.QsciScintillaBase.SCI_STARTSTYLING,
hotspot_start, 31) <br>
node_tab.SendScintilla(PyQt4.Qsci.QsciScintillaBase.SCI_SETSTYLING,
hotspot_end, 2) <- ERROR <br>
<br>
<br>
On Windows this works great, but on Ubuntu this gives me the
error at the last line with the message: <br>
Assertion [lengthStyle == 0 || (lengthStyle > 0 &&
lengthStyle + position <= style.Length())] <br>
failed at ../src/CellBuffer.cpp 426 <br>
</blockquote>
</blockquote>
<br>
I'd need a short complete example that demonstrates the problem. <br>
<br>
However a better solution would be to add a decent hotspot API so
you wouldn't need to fiddle with things like this. Do you want to
propose such an API? <br>
<br>
Phil <br>
</blockquote>
<br>
Hi Phil,<br>
<br>
Just figured out that when calling SendScintilla with
SCI_SETSTYLING, I used indexes that went out of the document scope.
<br>
That doesn't seem to raise an error on Windows, only on Linux.<br>
<br>
As for the hotspot API, I think something like the indicators use
would be the best and the most consistent.<br>
Scintilla uses only a single hotspot, so if adding multiple styles
is not an option, scratch that idea.<br>
<br>
Setting up a hotspot style:<br>
<blockquote>int setHotspotForeColor(QColor color, int
hotspotNumber)<br>
QColor hotspotForeColor(int hotspotNumber)<br>
int sethotspotForeColorEnabled(bool useForegroundColor, int
hotspotNumber)<br>
bool hotspotForeColorEnabled(int hotspotNumber)<br>
<br>
int setHotspotBackColor(bool useBackgroundColor, QColor
color, int hotspotNumber)<br>
QColor hotspotBackColor(int hotspotNumber)<br>
int sethotspotBackColorEnabled(bool useBackgroundColor, int
hotspotNumber)<br>
bool hotspotBackColorEnabled(int hotspotNumber)<br>
<br>
int setHotspotUnderline(bool underline, int hotspotNumber)<br>
bool hotspotUnderline(int hotspotNumber)<br>
<br>
int setHotspotSingleLine(bool singleLine, int
hotspotNumber)<br>
bool hotspotSingleLine(int hotspotNumber)<br>
</blockquote>
Styling with a hotspot:<br>
<blockquote>fillHotspotRange(int lineFrom, int indexFrom, int
lineTo, int indexTo, int hotspotNumber)<br>
clearHotspotRange(int lineFrom, int indexFrom, int lineTo, int
indexTo, int hotspotNumber)<br>
</blockquote>
<br>
I hope I understood you correctly about the API proposal.<br>
<br>
Matic<br>
</body>
</html>