diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2011-04-29 11:56:33 +0000 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2011-04-29 11:56:33 +0000 |
commit | 035f453065caea1a6cebb5f7f5175efbd45ab025 (patch) | |
tree | 07ddb67195ecb68608538b7d8defd348958a8995 /scintilla | |
parent | cd5e8de3bb4146e13768dc6642f16a7be8f98cc5 (diff) | |
download | notepad2-mod-035f453065caea1a6cebb5f7f5175efbd45ab025.zip notepad2-mod-035f453065caea1a6cebb5f7f5175efbd45ab025.tar.gz notepad2-mod-035f453065caea1a6cebb5f7f5175efbd45ab025.tar.bz2 |
update scintilla
git-svn-id: https://notepad2-mod.googlecode.com/svn/trunk@480 28bd50df-7adb-d945-0439-6e466c6a13cc
Diffstat (limited to 'scintilla')
-rw-r--r-- | scintilla/include/Scintilla.h | 2 | ||||
-rw-r--r-- | scintilla/include/Scintilla.iface | 6 | ||||
-rw-r--r-- | scintilla/src/Editor.cxx | 77 | ||||
-rw-r--r-- | scintilla/src/Editor.h | 2 | ||||
-rw-r--r-- | scintilla/src/PositionCache.cxx | 12 | ||||
-rw-r--r-- | scintilla/src/PositionCache.h | 4 | ||||
-rw-r--r-- | scintilla/src/ViewStyle.cxx | 8 | ||||
-rw-r--r-- | scintilla/src/ViewStyle.h | 4 |
8 files changed, 91 insertions, 24 deletions
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index a4ccd40..32123e0 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -556,7 +556,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
+#define SCI_BRACEHIGHLIGHTINDICATOR 2498
#define SCI_BRACEBADLIGHT 2352
+#define SCI_BRACEBADLIGHTINDICATOR 2499
#define SCI_BRACEMATCH 2353
#define SCI_GETVIEWEOL 2355
#define SCI_SETVIEWEOL 2356
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 5f900d0..9d87e20 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -1446,9 +1446,15 @@ fun int LineLength=2350(int line,) # Highlight the characters at two positions.
fun void BraceHighlight=2351(position pos1, position pos2)
+# Use specified indicator to highlight matching braces instead of changing their style.
+fun void BraceHighlightIndicator=2498(bool useBraceHighlightIndicator, int indicator)
+
# Highlight the character at a position indicating there is no matching brace.
fun void BraceBadLight=2352(position pos,)
+# Use specified indicator to highlight non matching brace instead of changing its style.
+fun void BraceBadLightIndicator=2499(bool useBraceBadLightIndicator, int indicator)
+
# Find the position of a matching brace or INVALID_POSITION if no match.
fun position BraceMatch=2353(position pos,)
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 95fb7cf..92c1e6a 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -2530,12 +2530,22 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin }
}
+void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
+ int xStart, PRectangle rcLine, LineLayout *ll, int subLine) {
+ const int 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);
+}
+
void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) {
// Draw decorators
const int posLineStart = pdoc->LineStart(line);
const int lineStart = ll->LineStart(subLine);
- const int subLineStart = ll->positions[lineStart];
const int posLineEnd = posLineStart + lineEnd;
if (!under) {
@@ -2560,12 +2570,7 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x // IN indicator run, looking for END
if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) {
// AT end of indicator run, DRAW it!
- PRectangle rcIndic(
- ll->positions[startPos] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent,
- ll->positions[indicPos] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent + 3);
- vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine);
+ DrawIndicator(indicnum, startPos, indicPos, surface, vsDraw, xStart, rcLine, ll, subLine);
// RESET control var
startPos = -1;
}
@@ -2585,16 +2590,33 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x int endPos = deco->rs.EndRun(startPos);
if (endPos > posLineEnd)
endPos = posLineEnd;
- PRectangle rcIndic(
- ll->positions[startPos - posLineStart] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent,
- ll->positions[endPos - posLineStart] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent + 3);
- vsDraw.indicators[deco->indicator].Draw(surface, rcIndic, rcLine);
+ DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart,
+ surface, vsDraw, xStart, rcLine, ll, subLine);
startPos = deco->rs.EndRun(endPos);
}
}
}
+
+ // Use indicators to highlight matching braces
+ if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) ||
+ (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) {
+ int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vs.braceHighlightIndicator : vs.braceBadLightIndicator;
+ if (under == vsDraw.indicators[braceIndicator].under) {
+ Range rangeLine(posLineStart + lineStart, posLineEnd);
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - posLineStart;
+ if (braceOffset < ll->numCharsInLine) {
+ DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, xStart, rcLine, ll, subLine);
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - posLineStart;
+ if (braceOffset < ll->numCharsInLine) {
+ DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, xStart, rcLine, ll, subLine);
+ }
+ }
+ }
+ }
}
void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
@@ -3050,7 +3072,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis lineNextWithText++;
}
if (lineNextWithText > line) {
- // This line is empty, so use indentation of last line with text
+ xStartText = 100000; // Don't limit to visible indentation on empty line
+ // This line is empty, so use indentation of first next line with text
indentSpace = Platform::Maximum(indentSpace,
pdoc->GetLineIndentation(lineNextWithText));
}
@@ -3482,17 +3505,22 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { rcLine.top = ypos;
rcLine.bottom = ypos + vs.lineHeight;
+ bool bracesIgnoreStyle = false;
+ if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) ||
+ (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) {
+ bracesIgnoreStyle = true;
+ }
Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
// Highlight the current braces if any
ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
- highlightGuideColumn * vs.spaceWidth);
+ highlightGuideColumn * vs.spaceWidth, bracesIgnoreStyle);
// Draw the line
DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine);
//durPaint += et.Duration(true);
// Restore the previous styles for the brace highlights in case layout is in cache.
- ll->RestoreBracesHighlight(rangeLine, braces);
+ ll->RestoreBracesHighlight(rangeLine, braces, bracesIgnoreStyle);
bool expanded = cs.GetExpanded(lineDoc);
const int level = pdoc->GetLevel(lineDoc);
@@ -3624,6 +3652,9 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { vsPrint.whitespaceBackgroundSet = false;
vsPrint.whitespaceForegroundSet = false;
vsPrint.showCaretLineBackground = false;
+ // Don't highlight matching braces using indicators
+ vsPrint.braceHighlightIndicatorSet = false;
+ vsPrint.braceBadLightIndicatorSet = false;
// Set colours for printing according to users settings
for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) {
@@ -8379,10 +8410,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { SetBraceHighlight(static_cast<int>(wParam), lParam, STYLE_BRACELIGHT);
break;
+ case SCI_BRACEHIGHLIGHTINDICATOR:
+ if (lParam >= 0 && lParam <= INDIC_MAX) {
+ vs.braceHighlightIndicatorSet = wParam != 0;
+ vs.braceHighlightIndicator = lParam;
+ }
+ break;
+
case SCI_BRACEBADLIGHT:
SetBraceHighlight(static_cast<int>(wParam), -1, STYLE_BRACEBAD);
break;
+ case SCI_BRACEBADLIGHTINDICATOR:
+ if (lParam >= 0 && lParam <= INDIC_MAX) {
+ vs.braceBadLightIndicatorSet = wParam != 0;
+ vs.braceBadLightIndicator = lParam;
+ }
+ break;
+
case SCI_BRACEMATCH:
// wParam is position of char to find brace for,
// lParam is maximum amount of text to restyle to find it
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 7c2b8b9..d1ef87c 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -370,6 +370,8 @@ protected: // ScintillaBase subclass needs access to much of Editor int line, int lineEnd, int xStart, int subLine, int subLineStart,
bool overrideBackground, ColourAllocated background,
bool drawWrapMark, ColourAllocated wrapColour);
+ void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
+ int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index 34b2219..2e3d260 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -151,15 +151,15 @@ void LineLayout::SetLineStart(int line, int start) { }
void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
- char bracesMatchStyle, int xHighlight) {
- if (rangeLine.ContainsCharacter(braces[0])) {
+ char bracesMatchStyle, int xHighlight, bool ignoreStyle) {
+ if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
int braceOffset = braces[0] - rangeLine.start;
if (braceOffset < numCharsInLine) {
bracePreviousStyles[0] = styles[braceOffset];
styles[braceOffset] = bracesMatchStyle;
}
}
- if (rangeLine.ContainsCharacter(braces[1])) {
+ if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) {
int braceOffset = braces[1] - rangeLine.start;
if (braceOffset < numCharsInLine) {
bracePreviousStyles[1] = styles[braceOffset];
@@ -172,14 +172,14 @@ void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], }
}
-void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
- if (rangeLine.ContainsCharacter(braces[0])) {
+void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle) {
+ if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
int braceOffset = braces[0] - rangeLine.start;
if (braceOffset < numCharsInLine) {
styles[braceOffset] = bracePreviousStyles[0];
}
}
- if (rangeLine.ContainsCharacter(braces[1])) {
+ if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) {
int braceOffset = braces[1] - rangeLine.start;
if (braceOffset < numCharsInLine) {
styles[braceOffset] = bracePreviousStyles[1];
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index 12273f5..76116c0 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -63,8 +63,8 @@ public: bool InLine(int offset, int line) const;
void SetLineStart(int line, int start);
void SetBracesHighlight(Range rangeLine, Position braces[],
- char bracesMatchStyle, int xHighlight);
- void RestoreBracesHighlight(Range rangeLine, Position braces[]);
+ char bracesMatchStyle, int xHighlight, bool ignoreStyle);
+ void RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle);
int FindBefore(int x, int lower, int upper) const;
int EndLineStyle() const;
};
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index e95b819..e043f25 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -204,6 +204,10 @@ ViewStyle::ViewStyle(const ViewStyle &source) { marginStyleOffset = source.marginStyleOffset;
annotationVisible = source.annotationVisible;
annotationStyleOffset = source.annotationStyleOffset;
+ braceHighlightIndicatorSet = source.braceHighlightIndicatorSet;
+ braceHighlightIndicator = source.braceHighlightIndicator;
+ braceBadLightIndicatorSet = source.braceBadLightIndicatorSet;
+ braceBadLightIndicator = source.braceBadLightIndicator;
}
ViewStyle::~ViewStyle() {
@@ -312,6 +316,10 @@ void ViewStyle::Init(size_t stylesSize_) { marginStyleOffset = 0;
annotationVisible = ANNOTATION_HIDDEN;
annotationStyleOffset = 0;
+ braceHighlightIndicatorSet = false;
+ braceHighlightIndicator = 0;
+ braceBadLightIndicatorSet = false;
+ braceBadLightIndicator = 0;
}
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 4742faa..feaa9eb 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -129,6 +129,10 @@ public: int marginStyleOffset;
int annotationVisible;
int annotationStyleOffset;
+ bool braceHighlightIndicatorSet;
+ int braceHighlightIndicator;
+ bool braceBadLightIndicatorSet;
+ int braceBadLightIndicator;
ViewStyle();
ViewStyle(const ViewStyle &source);
|