aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html35
-rw-r--r--include/Scintilla.h4
-rw-r--r--include/Scintilla.iface10
-rw-r--r--src/Editor.cxx58
-rw-r--r--src/ViewStyle.cxx2
-rw-r--r--src/ViewStyle.h4
6 files changed, 101 insertions, 12 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 22e4a7658..be0c3cef0 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -2658,7 +2658,7 @@ struct TextToFind {
<p><b id="SCI_GETLINEINDENTPOSITION">SCI_GETLINEINDENTPOSITION(int line)</b><br />
This returns the position at the end of indentation of a line.</p>
- <p><b id="SCI_SETINDENTATIONGUIDES">SCI_SETINDENTATIONGUIDES(bool view)</b><br />
+ <p><b id="SCI_SETINDENTATIONGUIDES">SCI_SETINDENTATIONGUIDES(int indentView)</b><br />
<b id="SCI_GETINDENTATIONGUIDES">SCI_GETINDENTATIONGUIDES</b><br />
Indentation guides are dotted vertical lines that appear within indentation white space every
indent size columns. They make it easy to see which constructs line up especially when they
@@ -2666,6 +2666,39 @@ struct TextToFind {
href="#StyleDefinition"><code>STYLE_INDENTGUIDE</code></a> (37) is used to specify the
foreground and background colour of the indentation guides.</p>
+ <p>There are 4 indentation guide views.
+ SC_IV_NONE turns the feature off but the other 3 states determine how far the guides appear on
+ empty lines.
+ <table border="0" summary="Search flags">
+ <tbody>
+ <tr>
+ <td><code>SC_IV_NONE</code></td>
+ <td>No indentation guides are shown.</td>
+ </tr>
+
+ <tr>
+ <td><code>SC_IV_REAL</code></td>
+ <td>Indentation guides are shown inside real indentation white space.</td>
+ </tr>
+
+ <tr>
+ <td><code>SC_IV_LOOKFORWARD</code></td>
+ <td>Indentation guides are shown beyond the actual indentation up to the level of the
+ next non-empty line.
+ If the previous non-empty line was a fold header then indentation guides are shown for
+ one more level of indent than that line. This setting is good for Python.</td>
+ </tr>
+
+ <tr>
+ <td><code>SC_IV_LOOKBOTH</code></td>
+ <td>Indentation guides are shown beyond the actual indentation up to the level of the
+ next non-empty line or previous non-empty line whichever is the greater.
+ This setting is good for most languages.</td>
+ </tr>
+
+ </table>
+ </p>
+
<p><b id="SCI_SETHIGHLIGHTGUIDE">SCI_SETHIGHLIGHTGUIDE(int column)</b><br />
<b id="SCI_GETHIGHLIGHTGUIDE">SCI_GETHIGHLIGHTGUIDE</b><br />
When brace highlighting occurs, the indentation guide corresponding to the braces may be
diff --git a/include/Scintilla.h b/include/Scintilla.h
index f4eca1aef..816edb36f 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -298,6 +298,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETCOLUMN 2129
#define SCI_SETHSCROLLBAR 2130
#define SCI_GETHSCROLLBAR 2131
+#define SC_IV_NONE 0
+#define SC_IV_REAL 1
+#define SC_IV_LOOKFORWARD 2
+#define SC_IV_LOOKBOTH 3
#define SCI_SETINDENTATIONGUIDES 2132
#define SCI_GETINDENTATIONGUIDES 2133
#define SCI_SETHIGHLIGHTGUIDE 2134
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index e1f24ebb1..6d05e437e 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -727,11 +727,17 @@ set void SetHScrollBar=2130(bool show,)
# Is the horizontal scroll bar visible?
get bool GetHScrollBar=2131(,)
+enu IndentView=SC_IV_
+val SC_IV_NONE=0
+val SC_IV_REAL=1
+val SC_IV_LOOKFORWARD=2
+val SC_IV_LOOKBOTH=3
+
# Show or hide indentation guides.
-set void SetIndentationGuides=2132(bool show,)
+set void SetIndentationGuides=2132(int indentView,)
# Are the indentation guides visible?
-get bool GetIndentationGuides=2133(,)
+get int GetIndentationGuides=2133(,)
# Set the highlighted indentation guide column.
# 0 = no highlighted guide.
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 916f32316..3373424da 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2286,7 +2286,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// Normal text display
surface->FillRectangle(rcSegment, textBack);
if (vsDraw.viewWhitespace != wsInvisible ||
- (inIndentation && vsDraw.viewIndentationGuides)) {
+ (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
if (ll->chars[cpos + startseg] == ' ') {
if (drawWhitespaceBackground &&
@@ -2361,12 +2361,13 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
textBack = vsDraw.whitespaceBackground.allocated;
surface->FillRectangle(rcSegment, textBack);
}
- if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
+ if ((vsDraw.viewWhitespace != wsInvisible) ||
+ (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
surface->PenColour(textFore);
}
- if (inIndentation && vsDraw.viewIndentationGuides) {
+ if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
if (xIG >= ll->positions[i] && xIG > 0) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment,
@@ -2426,7 +2427,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
if (vsDraw.viewWhitespace != wsInvisible ||
- (inIndentation && vsDraw.viewIndentationGuides)) {
+ (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
@@ -2446,7 +2447,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
surface->FillRectangle(rcDot, textFore);
}
}
- if (inIndentation && vsDraw.viewIndentationGuides) {
+ if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
int startSpace = ll->positions[cpos + startseg];
if (startSpace > 0 && (startSpace % indentWidth == 0)) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
@@ -2477,6 +2478,49 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
break;
}
}
+ if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth)
+ && (subLine == 0)) {
+ int indentSpace = pdoc->GetLineIndentation(line);
+ // Find the most recent line with some text
+
+ int lineLastWithText = line;
+ while (lineLastWithText > 0 && pdoc->IsWhiteLine(lineLastWithText)) {
+ lineLastWithText--;
+ }
+ if (lineLastWithText < line) {
+ // This line is empty, so use indentation of last line with text
+ int indentLastWithText = pdoc->GetLineIndentation(lineLastWithText);
+ int isFoldHeader = pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG;
+ if (isFoldHeader) {
+ // Level is one more level than parent
+ indentLastWithText += pdoc->IndentSize();
+ }
+ if (vsDraw.viewIndentationGuides == ivLookForward) {
+ // In viLookForward mode, previous line only used if it is a fold header
+ if (isFoldHeader) {
+ indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
+ }
+ } else { // viLookBoth
+ indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
+ }
+ }
+
+ int lineNextWithText = line;
+ while (lineNextWithText < pdoc->LinesTotal() && pdoc->IsWhiteLine(lineNextWithText)) {
+ lineNextWithText++;
+ }
+ if (lineNextWithText > line) {
+ // This line is empty, so use indentation of last line with text
+ indentSpace = Platform::Maximum(indentSpace,
+ pdoc->GetLineIndentation(lineNextWithText));
+ }
+
+ for (int indentPos=pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) {
+ int xIndent = indentPos * vsDraw.spaceWidth;
+ DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
+ (ll->xHighlightGuide == xIndent));
+ }
+ }
DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false);
@@ -3030,7 +3074,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
vsPrint.showMarkedLines = false;
vsPrint.fixedColumnWidth = 0;
vsPrint.zoomLevel = printMagnification;
- vsPrint.viewIndentationGuides = false;
+ vsPrint.viewIndentationGuides = ivNone;
// Don't show the selection when printing
vsPrint.selbackset = false;
vsPrint.selforeset = false;
@@ -6557,7 +6601,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return verticalScrollBarVisible;
case SCI_SETINDENTATIONGUIDES:
- vs.viewIndentationGuides = wParam != 0;
+ vs.viewIndentationGuides = IndentView(wParam);
Redraw();
break;
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index f73c15ed1..15efea8cc 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -229,7 +229,7 @@ void ViewStyle::Init(size_t stylesSize_) {
}
zoomLevel = 0;
viewWhitespace = wsInvisible;
- viewIndentationGuides = false;
+ viewIndentationGuides = ivNone;
viewEOL = false;
showMarkedLines = true;
extraFontFlag = false;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index a41e5f452..2f2d52461 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -38,6 +38,8 @@ public:
const char *Save(const char *name);
};
+enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
+
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
/**
@@ -87,7 +89,7 @@ public:
int fixedColumnWidth;
int zoomLevel;
WhiteSpaceVisibility viewWhitespace;
- bool viewIndentationGuides;
+ IndentView viewIndentationGuides;
bool viewEOL;
bool showMarkedLines;
ColourPair caretcolour;