<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 3.9.2014 17:19, Phil Thompson wrote:<br>
</div>
<blockquote
cite="mid:b9087b8e38961b4e39d417d361708cab@www.riverbankcomputing.com"
type="cite">On 25/08/2014 10:50 am, Matic Kukovec wrote: <br>
<blockquote type="cite">As for the hotspot API, I think something
like the indicators use <br>
would be the best and the most consistent. <br>
Scintilla uses only a single hotspot, so if adding multiple
styles is <br>
not an option, scratch that idea. <br>
<br>
Setting up a hotspot style: <br>
<br>
int setHotspotForeColor(QColor color, int
hotspotNumber) <br>
QColor hotspotForeColor(int hotspotNumber) <br>
int sethotspotForeColorEnabled(bool
useForegroundColor, int <br>
hotspotNumber) <br>
bool hotspotForeColorEnabled(int hotspotNumber) <br>
<br>
int setHotspotBackColor(bool useBackgroundColor,
QColor <br>
color, int hotspotNumber) <br>
QColor hotspotBackColor(int hotspotNumber) <br>
int sethotspotBackColorEnabled(bool
useBackgroundColor, int <br>
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>
<br>
I've added setHotspotForegroundColor(),
resetHotspotForegroundColor(), setHotspotBackgroundColor() and
resetHotspotBackgroundColor() which are similar to how the
selection foreground and background are handled. <br>
<br>
I've also added setHotspotUnderline() and setHotspotWrap(). Note
that these are all global - Scintilla doesn't support different
values for different styles. <br>
<br>
<blockquote type="cite">Styling with a hotspot: <br>
<br>
fillHotspotRange(int lineFrom, int indexFrom, int lineTo, int
<br>
indexTo, int hotspotNumber) <br>
clearHotspotRange(int lineFrom, int indexFrom, int lineTo,
int <br>
indexTo, int hotspotNumber) <br>
</blockquote>
<br>
Hotspots are implemented as styles and the normal way to apply a
style is via a lexer. If you use calls like the above and you have
a lexer installed then they are going to fight about what the
style of individual characters should be. If you don't have a
lexer installed than you can write a QsciLexerCustom sub-class
that will apply a QsciStyle with hotspot enabled wherever you
want. Using the custom lexer also has the advantage that Scintilla
decides what needs styling and when according to how the user is
moving around and updating the document. <br>
<br>
Given that, do you still need something like fillHotspotRange()? <br>
<br>
Phil <br>
</blockquote>
<br>
That is brilliant Phil, thanks!<br>
Using styles to set the hotspot is already good enough, no need for
fillHotspotRange/clearHotspotRange.<br>
Will try it out. <br>
<br>
Also, is there an efficient way of opening large binary files (up to
1Gb) without any styling?<br>
Example:<br>
<blockquote>binary_text = open(file,'rb').read()<br>
decoded_text = binary.decode("utf-8", errors="replace")<br>
scintilla.setLexer(None)<br>
scintilla.setText(decoded_text)<br>
</blockquote>
I tried opening a 600MB file with the above example and the setText
method spikes RAM usage<br>
to around 5GB and then returns to a normal 1.8GB.<br>
Is there a more efficient way of reading large files, maybe in
chunks or something similar?<br>
<br>
Matic<br>
</body>
</html>