aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html22
-rw-r--r--doc/ScintillaHistory.html9
-rw-r--r--include/Scintilla.h6
-rw-r--r--include/Scintilla.iface13
-rw-r--r--src/EditView.cxx41
-rw-r--r--src/Editor.cxx10
-rw-r--r--src/Indicator.cxx10
-rw-r--r--src/Indicator.h14
-rw-r--r--src/PositionCache.cxx14
-rw-r--r--src/PositionCache.h2
-rw-r--r--src/ViewStyle.cxx7
-rw-r--r--src/ViewStyle.h1
12 files changed, 130 insertions, 19 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 86db4be09..46039ed54 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -82,7 +82,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 10 February 2015 NH</p>
+ <p>Last edited 13 February 2015 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -3943,6 +3943,8 @@ struct Sci_TextToFind {
<a class="message" href="#SCI_INDICSETHOVERFORE">SCI_INDICSETHOVERFORE(int indicatorNumber, int
colour)</a><br />
<a class="message" href="#SCI_INDICGETHOVERFORE">SCI_INDICGETHOVERFORE(int indicatorNumber)</a><br />
+ <a class="message" href="#SCI_INDICSETFLAGS">SCI_INDICSETFLAGS(int indicatorNumber, int flags)</a><br />
+ <a class="message" href="#SCI_INDICGETFLAGS">SCI_INDICGETFLAGS(int indicatorNumber)</a><br />
<br />
<a class="message" href="#SCI_SETINDICATORCURRENT">SCI_SETINDICATORCURRENT(int indicator)</a><br />
@@ -4141,6 +4143,14 @@ struct Sci_TextToFind {
This is similar to an appearance used for non-target ranges in Asian language input composition.</td>
</tr>
+ <tr>
+ <td align="left"><code>INDIC_TEXTFORE</code></td>
+
+ <td align="center">17</td>
+
+ <td>Change the colour of the text to the indicator's fore colour.</td>
+ </tr>
+
</tbody>
</table>
@@ -4189,6 +4199,16 @@ struct Sci_TextToFind {
<a class="message" href="#SCI_INDICSETSTYLE">SCI_INDICSETSTYLE</a> will
also reset the hover attribute.</p>
+ <p><b id="SCI_INDICSETFLAGS">SCI_INDICSETFLAGS(int indicatorNumber, int flags)</b><br />
+ <b id="SCI_INDICGETFLAGS">SCI_INDICGETFLAGS(int indicatorNumber)</b><br />
+ These messages set and get the flags associated with an indicator.
+ There is currently one flag defined, <code>SC_INDICFLAG_VALUEFORE</code>: when this flag is set
+ the colour used by the indicator is not from the indicator's fore setting but instead from the value of the indicator at
+ that point in the file. This allows many colours to be displayed for a single indicator. The value is an <a class="jump"
+ href="#colour">RGB integer colour</a> that has been ored with <code>SC_INDICVALUEBIT</code>(0x1000000)
+ when calling <a class="message" href="#SCI_SETINDICATORVALUE">SCI_SETINDICATORVALUE</a>.
+ </p>
+
<p>
<b id="SCI_SETINDICATORCURRENT">SCI_SETINDICATORCURRENT(int indicator)</b><br />
<b id="SCI_GETINDICATORCURRENT">SCI_GETINDICATORCURRENT</b><br />
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index fd9617bd1..e4e91c219 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -489,6 +489,11 @@
Indicators may have a different colour and style when the mouse is over them or the caret is moved into them.
</li>
<li>
+ An indicator may display in a large variety of colours with the SC_INDICFLAG_VALUEFORE
+ flag taking the colour from the indicator's value, which may differ for every character, instead of its
+ foreground colour attribute.
+ </li>
+ <li>
Minimum version of Qt supported is now 4.8 due to the use of QElapsedTimer::nsecsElapsed.
</li>
<li>
@@ -507,10 +512,10 @@
VHDL folder fixes hang in folding when document starts with "entity".
</li>
<li>
- Add new indicators INDIC_COMPOSITIONTHIN and INDIC_FULLBOX.
+ Add new indicators INDIC_COMPOSITIONTHIN, INDIC_FULLBOX, and INDIC_TEXTFORE.
INDIC_COMPOSITIONTHIN is a thin underline that mimics the appearance of non-target segments in OS X IME.
INDIC_FULLBOX is similar to INDIC_STRAIGHTBOX but covers the entire character area which means that
- indicators with this style on contiguous lines may touch.
+ indicators with this style on contiguous lines may touch. INDIC_TEXTFORE changes the text foreground colour.
</li>
<li>
Fix adaptive scrolling speed for GTK+ on OS X with GTK Quartz backend (as opposed to X11 backend).
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 9668e7fb6..199986c25 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -276,6 +276,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_COMPOSITIONTHICK 14
#define INDIC_COMPOSITIONTHIN 15
#define INDIC_FULLBOX 16
+#define INDIC_TEXTFORE 17
#define INDIC_IME 32
#define INDIC_IME_MAX 35
#define INDIC_MAX 35
@@ -294,6 +295,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_INDICGETHOVERSTYLE 2681
#define SCI_INDICSETHOVERFORE 2682
#define SCI_INDICGETHOVERFORE 2683
+#define SC_INDICVALUEBIT 0x1000000
+#define SC_INDICVALUEMASK 0xFFFFFF
+#define SC_INDICFLAG_VALUEFORE 1
+#define SCI_INDICSETFLAGS 2684
+#define SCI_INDICGETFLAGS 2685
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 4a405d9d3..c540639da 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -607,6 +607,7 @@ val INDIC_SQUIGGLEPIXMAP=13
val INDIC_COMPOSITIONTHICK=14
val INDIC_COMPOSITIONTHIN=15
val INDIC_FULLBOX=16
+val INDIC_TEXTFORE=17
val INDIC_IME=32
val INDIC_IME_MAX=35
val INDIC_MAX=35
@@ -646,6 +647,18 @@ set void IndicSetHoverFore=2682(int indic, colour fore)
# Retrieve the foreground hover colour of an indicator.
get colour IndicGetHoverFore=2683(int indic,)
+val SC_INDICVALUEBIT=0x1000000
+val SC_INDICVALUEMASK=0xFFFFFF
+
+enu IndicFlag=SC_INDICFLAG_
+val SC_INDICFLAG_VALUEFORE=1
+
+# Set the attributes of an indicator.
+set void IndicSetFlags=2684(int indic, int flags)
+
+# Retrieve the attributes of an indicator.
+get int IndicGetFlags=2685(int indic,)
+
# Set the foreground colour of all whitespace and whether to use this setting.
fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 2c8979f8c..9d940f701 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -445,7 +445,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
ll->positions[0] = 0;
bool lastSegItalics = false;
- BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs);
+ BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL);
while (bfLayout.More()) {
const TextSegment ts = bfLayout.Next();
@@ -940,14 +940,14 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw,
- const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState) {
+ const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) {
const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
PRectangle rcIndic(
ll->positions[startPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent,
ll->positions[endPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent + 3);
- vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState);
+ vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value);
}
static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
@@ -969,9 +969,10 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
endPos = posLineEnd;
const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() &&
((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos));
+ const int value = deco->rs.ValueAt(startPos);
Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart,
- surface, vsDraw, ll, xStart, rcLine, subLine, drawState);
+ surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value);
startPos = endPos;
if (!deco->rs.ValueAt(startPos)) {
startPos = deco->rs.EndRun(startPos);
@@ -989,13 +990,13 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
if (rangeLine.ContainsCharacter(model.braces[0])) {
int braceOffset = model.braces[0] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
- DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal);
+ DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1);
}
}
if (rangeLine.ContainsCharacter(model.braces[1])) {
int braceOffset = model.braces[1] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
- DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal);
+ DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1);
}
}
}
@@ -1250,7 +1251,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
// Does not take margin into account but not significant
const int xStartVisible = static_cast<int>(subLineStart)-xStart;
- BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs);
+ BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, NULL);
const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background.isSet;
@@ -1427,7 +1428,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Foreground drawing loop
BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible,
- (((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs);
+ (((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs, &vsDraw);
while (bfFore.More()) {
@@ -1450,6 +1451,30 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.hotspotColours.fore.isSet)
textFore = vsDraw.hotspotColours.fore;
}
+ if (vsDraw.indicatorsSetFore > 0) {
+ // At least one indicator sets the text colour so see if it applies to this segment
+ for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) {
+ const int indicatorValue = deco->rs.ValueAt(ts.start + posLineStart);
+ if (indicatorValue) {
+ const Indicator &indicator = vsDraw.indicators[deco->indicator];
+ const bool hover = indicator.IsDynamic() &&
+ ((model.hoverIndicatorPos >= ts.start + posLineStart) &&
+ (model.hoverIndicatorPos <= ts.end() + posLineStart));
+ if (hover) {
+ if (indicator.sacHover.style == INDIC_TEXTFORE) {
+ textFore = indicator.sacHover.fore;
+ }
+ } else {
+ if (indicator.sacNormal.style == INDIC_TEXTFORE) {
+ if (indicator.Flags() & SC_INDICFLAG_VALUEFORE)
+ textFore = indicatorValue & SC_INDICVALUEMASK;
+ else
+ textFore = indicator.sacNormal.fore;
+ }
+ }
+ }
+ }
+ }
const int inSelection = hideSelection ? 0 : model.sel.CharacterInSelection(iDoc);
if (inSelection && (vsDraw.selColours.fore.isSet)) {
textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 85fab6e70..382e173c3 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6855,6 +6855,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICGETHOVERFORE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0;
+ case SCI_INDICSETFLAGS:
+ if (wParam <= INDIC_MAX) {
+ vs.indicators[wParam].SetFlags(static_cast<int>(lParam));
+ InvalidateStyleRedraw();
+ }
+ break;
+
+ case SCI_INDICGETFLAGS:
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].Flags() : 0;
+
case SCI_INDICSETUNDER:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].under = lParam != 0;
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index eea5877bb..62df0b716 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -23,8 +23,11 @@ static PRectangle PixelGridAlign(const PRectangle &rc) {
return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
}
-void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState) const {
+void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const {
StyleAndColour sacDraw = sacNormal;
+ if (Flags() & SC_INDICFLAG_VALUEFORE) {
+ sacDraw.fore = value & SC_INDICVALUEMASK;
+ }
if (drawState == drawHover) {
sacDraw = sacHover;
}
@@ -108,7 +111,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
} else if (sacDraw.style == INDIC_STRIKE) {
surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top) - 4);
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) - 4);
- } else if (sacDraw.style == INDIC_HIDDEN) {
+ } else if ((sacDraw.style == INDIC_HIDDEN) || (sacDraw.style == INDIC_TEXTFORE)) {
// Draw nothing
} else if (sacDraw.style == INDIC_BOX) {
surface->MoveTo(static_cast<int>(rc.left), ymid + 1);
@@ -172,3 +175,6 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
}
+void Indicator::SetFlags(int attributes_) {
+ attributes = attributes_;
+}
diff --git a/src/Indicator.h b/src/Indicator.h
index 56777e93e..c22ec71c6 100644
--- a/src/Indicator.h
+++ b/src/Indicator.h
@@ -34,15 +34,23 @@ public:
bool under;
int fillAlpha;
int outlineAlpha;
- Indicator() : under(false), fillAlpha(30), outlineAlpha(50) {
+ int attributes;
+ Indicator() : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) {
}
Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) :
- sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_) {
+ sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) {
}
- void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState) const;
+ void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const;
bool IsDynamic() const {
return !(sacNormal == sacHover);
}
+ bool OverridesTextFore() const {
+ return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE;
+ }
+ int Flags() const {
+ return attributes;
+ }
+ void SetFlags(int attributes_);
};
#ifdef SCI_NAMESPACE
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 666399503..860a780d9 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -440,7 +440,7 @@ void BreakFinder::Insert(int val) {
}
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
- int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) :
+ int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) :
ll(ll_),
lineRange(lineRange_),
posLineStart(posLineStart_),
@@ -475,7 +475,17 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
}
}
}
-
+ if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
+ for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
+ if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
+ int startPos = deco->rs.EndRun(posLineStart);
+ while (startPos < (posLineStart + lineRange.end)) {
+ Insert(startPos - posLineStart);
+ startPos = deco->rs.EndRun(startPos);
+ }
+ }
+ }
+ }
Insert(ll->edgeColumn);
Insert(lineRange.end);
saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 9d9821f8f..edc0a5ddb 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -168,7 +168,7 @@ public:
// Try to make each subdivided run lengthEachSubdivision or shorter.
enum { lengthEachSubdivision = 100 };
BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
- int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_);
+ int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw);
~BreakFinder();
TextSegment Next();
bool More() const;
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 864356bc1..e56c8f375 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -102,10 +102,13 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
}
CalcLargestMarkerHeight();
indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
for (int ind=0; ind<=INDIC_MAX; ind++) {
indicators[ind] = source.indicators[ind];
if (indicators[ind].IsDynamic())
indicatorsDynamic++;
+ if (indicators[ind].OverridesTextFore())
+ indicatorsSetFore++;
}
selColours = source.selColours;
@@ -201,6 +204,7 @@ void ViewStyle::Init(size_t stylesSize_) {
technology = SC_TECHNOLOGY_DEFAULT;
indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
lineHeight = 1;
lineOverlap = 0;
maxAscent = 1;
@@ -323,9 +327,12 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
styles[k].Copy(fr->font, *fr);
}
indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
for (int ind = 0; ind <= INDIC_MAX; ind++) {
if (indicators[ind].IsDynamic())
indicatorsDynamic++;
+ if (indicators[ind].OverridesTextFore())
+ indicatorsSetFore++;
}
maxAscent = 1;
maxDescent = 1;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 08afebaa5..930ad104c 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -84,6 +84,7 @@ public:
int largestMarkerHeight;
Indicator indicators[INDIC_MAX + 1];
unsigned int indicatorsDynamic;
+ unsigned int indicatorsSetFore;
int technology;
int lineHeight;
int lineOverlap;