summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2011-04-07 11:49:10 +0000
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-04-07 11:49:10 +0000
commitc48653e2f74a655d0ce03db8942e7071969d0b91 (patch)
tree92b09a8d0a92b8f6662d21d666b8b7359c088c84
parentcb025f715a049c891d295b8b716c248caeaa83c7 (diff)
downloadnotepad2-mod-c48653e2f74a655d0ce03db8942e7071969d0b91.zip
notepad2-mod-c48653e2f74a655d0ce03db8942e7071969d0b91.tar.gz
notepad2-mod-c48653e2f74a655d0ce03db8942e7071969d0b91.tar.bz2
update scintilla
git-svn-id: https://notepad2-mod.googlecode.com/svn/trunk@463 28bd50df-7adb-d945-0439-6e466c6a13cc
-rw-r--r--scintilla/include/Scintilla.h2
-rw-r--r--scintilla/include/Scintilla.iface6
-rw-r--r--scintilla/src/Document.cxx100
-rw-r--r--scintilla/src/Document.h44
-rw-r--r--scintilla/src/Editor.cxx103
-rw-r--r--scintilla/src/Editor.h5
-rw-r--r--scintilla/src/LineMarker.cxx132
-rw-r--r--scintilla/src/LineMarker.h11
8 files changed, 332 insertions, 71 deletions
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h
index 65bbeb8..1f07bbe 100644
--- a/scintilla/include/Scintilla.h
+++ b/scintilla/include/Scintilla.h
@@ -136,6 +136,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042
+#define SCI_MARKERSETBACKSELECTED 2292
+#define SCI_MARKERENABLEHIGHLIGHT 2293
#define SCI_MARKERADD 2043
#define SCI_MARKERDELETE 2044
#define SCI_MARKERDELETEALL 2045
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface
index c3bcc55..805c0ea 100644
--- a/scintilla/include/Scintilla.iface
+++ b/scintilla/include/Scintilla.iface
@@ -292,6 +292,12 @@ fun void MarkerSetFore=2041(int markerNumber, colour fore)
# Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back)
+# Set the background colour used for a particular marker number when its folding block is selected.
+fun void MarkerSetBackSelected=2292(int markerNumber, colour back)
+
+# Enable/disable highlight for current folding bloc (smallest one that contains the caret)
+fun void MarkerEnableHighlight=2293(bool enabled,)
+
# Add a marker to a line, returning an ID which can be used to find or delete the marker.
fun int MarkerAdd=2043(int line, int markerNumber)
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx
index 0efd733..15d1125 100644
--- a/scintilla/src/Document.cxx
+++ b/scintilla/src/Document.cxx
@@ -2,7 +2,7 @@
/** @file Document.cxx
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
@@ -355,6 +355,104 @@ int Document::GetFoldParent(int line) {
}
}
+void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDelimiter) {
+ int endLine = LineFromPosition(Length());
+ int beginFoldBlock = -1;
+ int endFoldBlock = -1;
+ int beginMarginCorrectlyDrawnZone = -1;
+ int endMarginCorrectlyDrawnZone = endLine + 1;
+ int endOfTailOfWhiteFlag = -1; //endOfTailOfWhiteFlag points the last SC_FOLDLEVELWHITEFLAG if follow a fold block. Otherwise endOfTailOfWhiteFlag points end of fold block.
+ int level = GetLevel(line);
+ int levelNumber = -1;
+ int lineLookLevel = -1;
+ int lineLookLevelNumber = -1;
+ int lineLook = line;
+ bool beginFoldBlockFound = false;
+ bool endFoldBlockFound = false;
+ bool beginMarginCorrectlyDrawnZoneFound = false;
+ bool endMarginCorrectlyDrawnZoneFound = false;
+
+ /*******************************************************************************/
+ /* search backward (beginFoldBlock & beginMarginCorrectlyDrawnZone) */
+ /*******************************************************************************/
+ for (endOfTailOfWhiteFlag = line; lineLook >= 0 && (!beginFoldBlockFound || !beginMarginCorrectlyDrawnZoneFound); --lineLook) {
+ lineLookLevel = GetLevel(lineLook);
+ if (levelNumber != -1) {
+ lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
+ if (!beginMarginCorrectlyDrawnZoneFound && (lineLookLevelNumber > levelNumber)) {
+ beginMarginCorrectlyDrawnZoneFound = true;
+ beginMarginCorrectlyDrawnZone = endOfTailOfWhiteFlag;
+ }
+ //find the last space line (SC_FOLDLEVELWHITEFLAG).
+ if (!beginMarginCorrectlyDrawnZoneFound && !(lineLookLevel & SC_FOLDLEVELWHITEFLAG)) {
+ endOfTailOfWhiteFlag = lineLook - 1;
+ }
+ if (!beginFoldBlockFound && (lineLookLevelNumber < levelNumber)) {
+ beginFoldBlockFound = true;
+ beginFoldBlock = lineLook;
+ if (!beginMarginCorrectlyDrawnZoneFound) {
+ beginMarginCorrectlyDrawnZoneFound = true;
+ beginMarginCorrectlyDrawnZone = lineLook - 1;
+ }
+ } else if (!beginFoldBlockFound && lineLookLevelNumber == SC_FOLDLEVELBASE) {
+ beginFoldBlockFound = true; //beginFoldBlock already set to -1.
+ }
+ } else if (!(lineLookLevel & SC_FOLDLEVELWHITEFLAG)) {
+ endOfTailOfWhiteFlag = lineLook - 1;
+ if (lineLookLevel & SC_FOLDLEVELHEADERFLAG) {
+ beginFoldBlockFound = true;
+ beginFoldBlock = lineLook;
+ beginMarginCorrectlyDrawnZoneFound = true;
+ beginMarginCorrectlyDrawnZone = endOfTailOfWhiteFlag;
+ levelNumber = GetLevel(lineLook + 1) & SC_FOLDLEVELNUMBERMASK;;
+ } else {
+ levelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
+ }
+ }
+ }
+
+ /****************************************************************************/
+ /* search forward (endStartBlock & endMarginCorrectlyDrawnZone) */
+ /****************************************************************************/
+ if (level & SC_FOLDLEVELHEADERFLAG) {
+ //ignore this line because this line is on first one of block.
+ lineLook = line + 1;
+ } else {
+ lineLook = line;
+ }
+ for (; lineLook <= endLine && (!endFoldBlockFound || !endMarginCorrectlyDrawnZoneFound); ++lineLook) {
+ lineLookLevel = GetLevel(lineLook);
+ lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
+ if (!endFoldBlockFound && !(lineLookLevel & SC_FOLDLEVELWHITEFLAG) && lineLookLevelNumber < levelNumber) {
+ endFoldBlockFound = true;
+ endFoldBlock = lineLook - 1;
+ if (!endMarginCorrectlyDrawnZoneFound) {
+ endMarginCorrectlyDrawnZoneFound = true;
+ endMarginCorrectlyDrawnZone = lineLook;
+ }
+ } else if (!endFoldBlockFound && lineLookLevel == SC_FOLDLEVELBASE) {
+ endFoldBlockFound = true;
+ endFoldBlock = -1;
+ }
+ if (!endMarginCorrectlyDrawnZoneFound && (lineLookLevel & SC_FOLDLEVELHEADERFLAG)) {
+ endMarginCorrectlyDrawnZoneFound = true;
+ endMarginCorrectlyDrawnZone = lineLook;
+ }
+ }
+ if (!endFoldBlockFound && ((lineLook > endLine && lineLookLevelNumber < levelNumber) ||
+ (levelNumber > SC_FOLDLEVELBASE))) {
+ //manage when endfold is incorrect or on last line.
+ endFoldBlock = lineLook - 1;
+ //useless to set endMarginCorrectlyDrawnZone.
+ //if endMarginCorrectlyDrawnZoneFound equals false then endMarginCorrectlyDrawnZone already equals to endLine + 1.
+ }
+
+ highlightDelimiter.beginFoldBlock = beginFoldBlock;
+ highlightDelimiter.endFoldBlock = endFoldBlock;
+ highlightDelimiter.beginMarginCorrectlyDrawnZone = beginMarginCorrectlyDrawnZone;
+ highlightDelimiter.endMarginCorrectlyDrawnZone = endMarginCorrectlyDrawnZone;
+}
+
int Document::ClampPositionIntoDocument(int pos) {
return Platform::Clamp(pos, 0, Length());
}
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h
index f0d6687..c25c0d5 100644
--- a/scintilla/src/Document.h
+++ b/scintilla/src/Document.h
@@ -2,7 +2,7 @@
/** @file Document.h
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H
@@ -115,6 +115,47 @@ struct StyledText {
}
};
+class HighlightDelimiter {
+public:
+ HighlightDelimiter() {
+ beginFoldBlock = -1;
+ endFoldBlock = -1;
+ beginMarginCorrectlyDrawnZone = -1;
+ endMarginCorrectlyDrawnZone = -1;
+ isEnabled = false;
+ }
+
+ bool NeedsDrawing(int line) {
+ return isEnabled && (line <= beginMarginCorrectlyDrawnZone || endMarginCorrectlyDrawnZone <= line);
+ }
+
+ bool isCurrentBlockHighlight(int line) {
+ return isEnabled && beginFoldBlock <= line && line <= endFoldBlock;
+ }
+
+ bool isHeadBlockFold(int line) {
+ return beginFoldBlock == line && line < endFoldBlock;
+ }
+
+ bool isBodyBlockFold(int line) {
+ return beginFoldBlock < line && line < endFoldBlock;
+ }
+
+ bool isTailBlockFold(int line) {
+ return beginFoldBlock < line && line == endFoldBlock;
+ }
+
+ // beginFoldBlock : Begin of current fold block.
+ // endStartBlock : End of zone where margin is already drawn.
+ // beginMarginCorrectlyDrawnZone : Begin of zone where margin is already drawn.
+ // endMarginCorrectlyDrawnZone : End of current fold block.
+ int beginFoldBlock;
+ int endFoldBlock;
+ int beginMarginCorrectlyDrawnZone;
+ int endMarginCorrectlyDrawnZone;
+ bool isEnabled;
+};
+
class CaseFolder {
public:
virtual ~CaseFolder() {
@@ -299,6 +340,7 @@ public:
void ClearLevels();
int GetLastChild(int lineParent, int level=-1);
int GetFoldParent(int line);
+ void GetHighlightDelimiters(int line, HighlightDelimiter &hDelimiter);
void Indent(bool forwards);
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 245ef14..7528483 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -2,7 +2,7 @@
/** @file Editor.cxx
** Main code for the edit control.
**/
-// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
@@ -755,6 +755,7 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
anchor_ = ClampPositionIntoDocument(anchor_);
+ int currentLine = pdoc->LineFromPosition(currentPos_.Position());
/* For Line selection - ensure the anchor and caret are always
at the beginning and end of the region lines. */
if (sel.selType == Selection::selLines) {
@@ -773,6 +774,10 @@ void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition ancho
sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
+
+ if (highlightDelimiter.NeedsDrawing(currentLine)) {
+ RedrawSelMargin();
+ }
}
void Editor::SetSelection(int currentPos_, int anchor_) {
@@ -782,6 +787,7 @@ void Editor::SetSelection(int currentPos_, int anchor_) {
// Just move the caret on the main selection
void Editor::SetSelection(SelectionPosition currentPos_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
+ int currentLine = pdoc->LineFromPosition(currentPos_.Position());
if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) {
InvalidateSelection(SelectionRange(currentPos_));
}
@@ -794,6 +800,10 @@ void Editor::SetSelection(SelectionPosition currentPos_) {
SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor);
}
ClaimSelection();
+
+ if (highlightDelimiter.NeedsDrawing(currentLine)) {
+ RedrawSelMargin();
+ }
}
void Editor::SetSelection(int currentPos_) {
@@ -801,6 +811,7 @@ void Editor::SetSelection(int currentPos_) {
}
void Editor::SetEmptySelection(SelectionPosition currentPos_) {
+ int currentLine = pdoc->LineFromPosition(currentPos_.Position());
SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_));
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
InvalidateSelection(rangeNew);
@@ -810,6 +821,9 @@ void Editor::SetEmptySelection(SelectionPosition currentPos_) {
SetRectangularRange();
ClaimSelection();
+ if (highlightDelimiter.NeedsDrawing(currentLine)) {
+ RedrawSelMargin();
+ }
}
void Editor::SetEmptySelection(int currentPos_) {
@@ -910,6 +924,12 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
SetXYScroll(newXY);
}
}
+
+ int currentLine = pdoc->LineFromPosition(newPos.Position());
+
+ if (highlightDelimiter.NeedsDrawing(currentLine)) {
+ RedrawSelMargin();
+ }
return 0;
}
@@ -1692,7 +1712,6 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
int visibleLine = topLine;
int yposScreen = 0;
-
// Work out whether the top line is whitespace located after a
// lessening of fold level which implies a 'fold tail' but which should not
// be displayed until the last of a sequence of whitespace.
@@ -1710,6 +1729,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
needWhiteClosure = true;
}
}
+ if (highlightDelimiter.isEnabled && (vs.ms[margin].mask & SC_MASK_FOLDERS)) {
+ pdoc->GetHighlightDelimiters(pdoc->LineFromPosition(CurrentPosition()), highlightDelimiter);
+ }
// Old code does not know about new markers needed to distinguish all cases
int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
@@ -1720,7 +1742,6 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed());
-
int lineDoc = cs.DocFromDisplay(visibleLine);
PLATFORM_ASSERT(cs.GetVisible(lineDoc));
bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
@@ -1735,17 +1756,21 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
if (level & SC_FOLDLEVELHEADERFLAG) {
if (firstSubLine) {
- if (cs.GetExpanded(lineDoc)) {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDEROPEN;
- else
- marks |= 1 << folderOpenMid;
- } else {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDER;
- else
- marks |= 1 << folderEnd;
- }
+ if (levelNum < levelNextNum) {
+ if (cs.GetExpanded(lineDoc)) {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDEROPEN;
+ else
+ marks |= 1 << folderOpenMid;
+ } else {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDER;
+ else
+ marks |= 1 << folderEnd;
+ }
+ } else if (levelNum > SC_FOLDLEVELBASE){
+ marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ }
} else {
marks |= 1 << SC_MARKNUM_FOLDERSUB;
}
@@ -1787,7 +1812,6 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
marks |= 1 << SC_MARKNUM_FOLDERSUB;
}
}
-
marks &= vs.ms[margin].mask;
PRectangle rcMarker = rcSelMargin;
rcMarker.top = yposScreen;
@@ -1834,7 +1858,20 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
if (marks) {
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
if (marks & 1) {
- vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font);
+ LineMarker::typeOfFold tFold;
+ if (!highlightDelimiter.isCurrentBlockHighlight(lineDoc)) {
+ tFold = LineMarker::undefined;
+ } else if (highlightDelimiter.isBodyBlockFold(lineDoc)) {
+ tFold = LineMarker::body;
+ } else if (highlightDelimiter.isHeadBlockFold(lineDoc)) {
+ tFold = LineMarker::head;
+ } else if (highlightDelimiter.isTailBlockFold(lineDoc)) {
+ tFold = LineMarker::tail;
+ } else {
+ //Normally, this branch is never used. But I prefer to manage it anyway.
+ tFold = LineMarker::undefined;
+ }
+ vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font, tFold);
}
marks >>= 1;
}
@@ -3443,21 +3480,22 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
ll->RestoreBracesHighlight(rangeLine, braces);
bool expanded = cs.GetExpanded(lineDoc);
- // Paint the line above the fold
- if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED))
- ||
- (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) {
- if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ const int level = pdoc->GetLevel(lineDoc);
+ const int levelNext = pdoc->GetLevel(lineDoc + 1);
+ if ((level & SC_FOLDLEVELHEADERFLAG) &&
+ ((level & SC_FOLDLEVELNUMBERMASK) < (levelNext & SC_FOLDLEVELNUMBERMASK))) {
+ // Paint the line above the fold
+ if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED))
+ ||
+ (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.bottom = rcFoldLine.top + 1;
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
}
- }
- // Paint the line below the fold
- if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED))
- ||
- (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) {
- if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ // Paint the line below the fold
+ if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED))
+ ||
+ (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.top = rcFoldLine.bottom - 1;
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
@@ -6575,8 +6613,8 @@ void Editor::ToggleContraction(int line) {
if (cs.GetExpanded(line)) {
int lineMaxSubord = pdoc->GetLastChild(line);
- cs.SetExpanded(line, 0);
if (lineMaxSubord > line) {
+ cs.SetExpanded(line, 0);
cs.SetVisible(line + 1, lineMaxSubord, false);
int lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
@@ -7756,6 +7794,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleData();
RedrawSelMargin();
break;
+ case SCI_MARKERSETBACKSELECTED:
+ if (wParam <= MARKER_MAX)
+ vs.markers[wParam].backSelected.desired = ColourDesired(lParam);
+ InvalidateStyleRedraw();
+ break;
+ case SCI_MARKERENABLEHIGHLIGHT:
+ highlightDelimiter.isEnabled = wParam == 1;
+ InvalidateStyleRedraw();
+ break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
vs.markers[wParam].back.desired = ColourDesired(lParam);
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h
index 7afd2ee..7c2b8b9 100644
--- a/scintilla/src/Editor.h
+++ b/scintilla/src/Editor.h
@@ -2,7 +2,7 @@
/** @file Editor.h
** Defines the main editor class.
**/
-// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H
@@ -139,6 +139,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
int cursorMode;
int controlCharSymbol;
+ // Highlight current folding block
+ HighlightDelimiter highlightDelimiter;
+
bool hasFocus;
bool hideSelection;
bool inOverstrike;
diff --git a/scintilla/src/LineMarker.cxx b/scintilla/src/LineMarker.cxx
index 6f4b0a9..688d139 100644
--- a/scintilla/src/LineMarker.cxx
+++ b/scintilla/src/LineMarker.cxx
@@ -2,7 +2,7 @@
/** @file LineMarker.cxx
** Defines the look of a line marker in the margin .
**/
-// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <string.h>
@@ -20,6 +20,7 @@ using namespace Scintilla;
void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
pal.WantFind(fore, want);
pal.WantFind(back, want);
+ pal.WantFind(backSelected, want);
if (pxpm) {
pxpm->RefreshColourPalette(pal, want);
}
@@ -67,7 +68,30 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
surface->FillRectangle(rcH, fore);
}
-void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter) {
+void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold) {
+ ColourPair head = back;
+ ColourPair body = back;
+ ColourPair tail = back;
+
+ switch (tFold) {
+ case LineMarker::head :
+ head = backSelected;
+ tail = backSelected;
+ break;
+ case LineMarker::body :
+ head = backSelected;
+ body = backSelected;
+ break;
+ case LineMarker::tail :
+ body = backSelected;
+ tail = backSelected;
+ break;
+ default :
+ // LineMarker::undefined
+ break;
+ }
+
+
if ((markType == SC_MARK_PIXMAP) && (pxpm)) {
pxpm->Draw(surface, rcWhole);
return;
@@ -159,106 +183,138 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
// An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) {
- surface->PenColour(back.allocated);
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_LCORNER) {
- surface->PenColour(back.allocated);
+ surface->PenColour(tail.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNER) {
- surface->PenColour(back.allocated);
- surface->MoveTo(centreX, rcWhole.top);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->PenColour(tail.allocated);
surface->MoveTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
+ surface->PenColour(body.allocated);
+ surface->MoveTo(centreX, rcWhole.top);
+ surface->LineTo(centreX, rc.top + dimOn2 + 1);
+
+ surface->PenColour(head.allocated);
+ surface->LineTo(centreX, rcWhole.bottom);
+
} else if (markType == SC_MARK_LCORNERCURVE) {
- surface->PenColour(back.allocated);
+ surface->PenColour(tail.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNERCURVE) {
- surface->PenColour(back.allocated);
- surface->MoveTo(centreX, rcWhole.top);
- surface->LineTo(centreX, rcWhole.bottom);
-
+ surface->PenColour(tail.allocated);
surface->MoveTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
+ surface->PenColour(body.allocated);
+ surface->MoveTo(centreX, rcWhole.top);
+ surface->LineTo(centreX, rc.top + dimOn2-2);
+
+ surface->PenColour(head.allocated);
+ surface->LineTo(centreX, rcWhole.bottom);
+
} else if (markType == SC_MARK_BOXPLUS) {
- surface->PenColour(back.allocated);
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
} else if (markType == SC_MARK_BOXPLUSCONNECTED) {
- surface->PenColour(back.allocated);
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
-
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
+ DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+
+ if (tFold == LineMarker::body) {
+ surface->PenColour(tail.allocated);
+ surface->MoveTo(centreX + 1, centreY + blobSize);
+ surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
+
+ surface->MoveTo(centreX + blobSize, centreY + blobSize);
+ surface->LineTo(centreX + blobSize, centreY - blobSize);
+
+ surface->MoveTo(centreX + 1, centreY - blobSize);
+ surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
+ }
} else if (markType == SC_MARK_BOXMINUS) {
- surface->PenColour(back.allocated);
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ surface->PenColour(head.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
- surface->PenColour(back.allocated);
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ surface->PenColour(head.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
+ if (tFold == LineMarker::body) {
+ surface->PenColour(tail.allocated);
+ surface->MoveTo(centreX + 1, centreY + blobSize);
+ surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
+
+ surface->MoveTo(centreX + blobSize, centreY + blobSize);
+ surface->LineTo(centreX + blobSize, centreY - blobSize);
+
+ surface->MoveTo(centreX + 1, centreY - blobSize);
+ surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
+ }
} else if (markType == SC_MARK_CIRCLEPLUS) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- surface->PenColour(back.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
} else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- surface->PenColour(back.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
-
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
+ DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+
} else if (markType == SC_MARK_CIRCLEMINUS) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- surface->PenColour(back.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ surface->PenColour(head.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
- surface->PenColour(back.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
+ DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ surface->PenColour(head.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
+ surface->PenColour(body.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
diff --git a/scintilla/src/LineMarker.h b/scintilla/src/LineMarker.h
index fa0f29f..fdb76d3 100644
--- a/scintilla/src/LineMarker.h
+++ b/scintilla/src/LineMarker.h
@@ -2,7 +2,7 @@
/** @file LineMarker.h
** Defines the look of a line marker in the margin .
**/
-// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef LINEMARKER_H
@@ -12,19 +12,24 @@
namespace Scintilla {
#endif
+
/**
*/
class LineMarker {
public:
+ enum typeOfFold { undefined, head, body, tail };
+
int markType;
ColourPair fore;
ColourPair back;
+ ColourPair backSelected;
int alpha;
XPM *pxpm;
LineMarker() {
markType = SC_MARK_CIRCLE;
fore = ColourDesired(0,0,0);
back = ColourDesired(0xff,0xff,0xff);
+ backSelected = ColourDesired(0xff,0x00,0x00);
alpha = SC_ALPHA_NOALPHA;
pxpm = NULL;
}
@@ -33,6 +38,7 @@ public:
markType = SC_MARK_CIRCLE;
fore = ColourDesired(0,0,0);
back = ColourDesired(0xff,0xff,0xff);
+ backSelected = ColourDesired(0xff,0x00,0x00);
alpha = SC_ALPHA_NOALPHA;
pxpm = NULL;
}
@@ -44,6 +50,7 @@ public:
markType = SC_MARK_CIRCLE;
fore = ColourDesired(0,0,0);
back = ColourDesired(0xff,0xff,0xff);
+ backSelected = ColourDesired(0xff,0x00,0x00);
alpha = SC_ALPHA_NOALPHA;
delete pxpm;
pxpm = NULL;
@@ -52,7 +59,7 @@ public:
void RefreshColourPalette(Palette &pal, bool want);
void SetXPM(const char *textForm);
void SetXPM(const char *const *linesForm);
- void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
+ void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold);
};
#ifdef SCI_NAMESPACE