aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html80
-rw-r--r--include/Scintilla.h5
-rw-r--r--include/Scintilla.iface11
-rw-r--r--src/Editor.cxx69
-rw-r--r--src/Editor.h3
-rw-r--r--src/PositionCache.cxx3
-rw-r--r--src/PositionCache.h1
7 files changed, 142 insertions, 30 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index d4e9146f9..175be3396 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -9,7 +9,7 @@
<meta name="generator" content="SciTE" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Scintilla and SciTE</title>
+ <title>Scintilla Documentation</title>
<style type="text/css">
<!--
@@ -38,7 +38,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 28/April/2009 NH</p>
+ <p>Last edited 9/June/2009 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -878,8 +878,34 @@ struct TextToFind {
<p><b id="SCI_SETSTATUS">SCI_SETSTATUS(int status)</b><br />
<b id="SCI_GETSTATUS">SCI_GETSTATUS</b><br />
If an error occurs, Scintilla may set an internal error number that can be retrieved with
- <code>SCI_GETSTATUS</code>. Not currently used but will be in the future. To clear the error
- status call <code>SCI_SETSTATUS(0)</code>.</p>
+ <code>SCI_GETSTATUS</code>.
+ To clear the error status call <code>SCI_SETSTATUS(0)</code>.
+ The currently defined statuses are:
+
+ <table cellpadding="1" cellspacing="2" border="0" summary="Status values">
+ <tbody valign="top">
+ <tr>
+ <th align="left">SC_STATUS_OK</th>
+ <td>0</td>
+ <td>No failures</td>
+ </tr>
+
+ <tr>
+ <th align="left">SC_STATUS_FAILURE</th>
+ <td>1</td>
+ <td>Generic failure</td>
+ </tr>
+
+ <tr>
+ <th align="left">SC_STATUS_BADALLOC</th>
+ <td>2</td>
+ <td>Memory is exhausted</td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ </p>
<h2 id="UndoAndRedo">Undo and Redo</h2>
@@ -4527,6 +4553,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<a class="message" href="#SCI_GETWRAPVISUALFLAGS">SCI_GETWRAPVISUALFLAGS</a><br />
<a class="message" href="#SCI_SETWRAPVISUALFLAGSLOCATION">SCI_SETWRAPVISUALFLAGSLOCATION(int wrapVisualFlagsLocation)</a><br />
<a class="message" href="#SCI_GETWRAPVISUALFLAGSLOCATION">SCI_GETWRAPVISUALFLAGSLOCATION</a><br />
+ <a class="message" href="#SCI_SETWRAPINDENTMODE">SCI_SETWRAPINDENTMODE(int indentMode)</a><br />
+ <a class="message" href="#SCI_GETWRAPINDENTMODE">SCI_GETWRAPINDENTMODE</a><br />
<a class="message" href="#SCI_SETWRAPSTARTINDENT">SCI_SETWRAPSTARTINDENT(int indent)</a><br />
<a class="message" href="#SCI_GETWRAPSTARTINDENT">SCI_GETWRAPSTARTINDENT</a><br />
<a class="message" href="#SCI_SETLAYOUTCACHE">SCI_SETLAYOUTCACHE(int cacheMode)</a><br />
@@ -4546,7 +4574,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<p>For wrapped lines Scintilla can draw visual flags (little arrows) at end of a a subline of a
wrapped line and at begin of the next subline. These can be enabled individually, but if Scintilla
- draws the visual flag at begin of the next subline this subline will be indented by one char.
+ draws the visual flag at the beginning of the next subline this subline will be indented by one char.
Independent from drawing a visual flag at the begin the subline can have an indention.</p>
<p>Much of the time used by Scintilla is spent on laying out and drawing text. The same text
@@ -4617,7 +4645,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<p><b id="SCI_SETWRAPVISUALFLAGSLOCATION">SCI_SETWRAPVISUALFLAGSLOCATION(int wrapVisualFlagsLocation)</b><br />
<b id="SCI_GETWRAPVISUALFLAGSLOCATION">SCI_GETWRAPVISUALFLAGSLOCATION</b><br />
- You can set wether the visual flags to indicate a line is wrapped are drawn near the border or near the text.
+ You can set whether the visual flags to indicate a line is wrapped are drawn near the border or near the text.
Bits set in wrapVisualFlagsLocation set the location to near the text for the corresponding visual flag.
<table cellpadding="1" cellspacing="2" border="0" summary="Wrap visual flags locations">
@@ -4645,7 +4673,45 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<tr>
<td align="left"><code>SC_WRAPVISUALFLAGLOC_START_BY_TEXT</code></td>
<td align="center">2</td>
- <td>Visual flag at begin of subline drawn near text</td>
+ <td>Visual flag at beginning of subline drawn near text</td>
+ </tr>
+ </tbody>
+ </table>
+ </p>
+
+ <p><b id="SCI_SETWRAPINDENTMODE">SCI_SETWRAPINDENTMODE(int indentMode)</b><br />
+ <b id="SCI_GETWRAPINDENTMODE">SCI_GETWRAPINDENTMODE</b><br />
+ Wrapped sublines can be indented to the position of their first subline or one more indent level.
+ The default is <code>SC_WRAPINDENT_FIXED</code>.
+ The modes are:
+
+ <table cellpadding="1" cellspacing="2" border="0" summary="Wrap visual flags locations">
+ <tbody>
+ <tr>
+ <th align="left">Symbol</th>
+ <th>Value</th>
+ <th align="left">Effect</th>
+ </tr>
+ </tbody>
+
+ <tbody valign="top">
+ <tr>
+ <td align="left"><code>SC_WRAPINDENT_FIXED</code></td>
+ <td align="center">0</td>
+ <td>Wrapped sublines aligned to left of window plus amount set by
+ <a class="message" href="#SCI_SETWRAPSTARTINDENT">SCI_SETWRAPSTARTINDENT</a></td>
+ </tr>
+
+ <tr>
+ <td align="left"><code>SC_WRAPINDENT_SAME</code></td>
+ <td align="center">1</td>
+ <td>Wrapped sublines are aligned to first subline indent</td>
+ </tr>
+
+ <tr>
+ <td align="left"><code>SC_WRAPINDENT_INDENT</code></td>
+ <td align="center">2</td>
+ <td>Wrapped sublines are aligned to first subline indent plus one more level of indentation</td>
</tr>
</tbody>
</table>
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 312ec6204..476fa0506 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -444,6 +444,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETWRAPVISUALFLAGSLOCATION 2463
#define SCI_SETWRAPSTARTINDENT 2464
#define SCI_GETWRAPSTARTINDENT 2465
+#define SC_WRAPINDENT_FIXED 0
+#define SC_WRAPINDENT_SAME 1
+#define SC_WRAPINDENT_INDENT 2
+#define SCI_SETWRAPINDENTMODE 2472
+#define SCI_GETWRAPINDENTMODE 2473
#define SC_CACHE_NONE 0
#define SC_CACHE_CARET 1
#define SC_CACHE_PAGE 2
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index d0f376fa5..d2e4a6f9a 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1131,6 +1131,17 @@ set void SetWrapStartIndent=2464(int indent,)
# Retrive the start indent for wrapped lines.
get int GetWrapStartIndent=2465(,)
+enu WrapIndentMode=SC_WRAPINDENT_
+val SC_WRAPINDENT_FIXED=0
+val SC_WRAPINDENT_SAME=1
+val SC_WRAPINDENT_INDENT=2
+
+# Sets how wrapped sublines are placed. Default is fixed.
+set void SetWrapIndentMode=2472(int mode,)
+
+# Retrieve how wrapped sublines are placed. Default is fixed.
+get int GetWrapIndentMode=2473(,)
+
enu LineCache=SC_CACHE_
val SC_CACHE_NONE=0
val SC_CACHE_CARET=1
diff --git a/src/Editor.cxx b/src/Editor.cxx
index d54bbe36c..f7f5cb2bb 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -184,7 +184,8 @@ Editor::Editor() {
wrapVisualFlags = 0;
wrapVisualFlagsLocation = 0;
wrapVisualStartIndent = 0;
- actualWrapVisualStartIndent = 0;
+ wrapIndentMode = SC_WRAPINDENT_FIXED;
+ wrapAddIndent = 0;
convertPastes = true;
@@ -252,6 +253,15 @@ void Editor::RefreshStyleData() {
palette.Allocate(wMain);
RefreshColourPalette(palette, false);
}
+ if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
+ wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth;
+ } else if (wrapIndentMode == SC_WRAPINDENT_SAME) {
+ wrapAddIndent = 0;
+ } else { //SC_WRAPINDENT_FIXED
+ wrapAddIndent = wrapVisualStartIndent * vs.aveCharWidth;
+ if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0))
+ wrapAddIndent = vs.aveCharWidth; // must indent to show start visual
+ }
SetScrollBars();
}
}
@@ -448,10 +458,10 @@ Point Editor::LocationFromPosition(int pos) {
for (int subLine = 0; subLine < ll->lines; subLine++) {
if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) {
pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)];
- if (actualWrapVisualStartIndent != 0) {
+ if (ll->wrapIndent != 0) {
int lineStart = ll->LineStart(subLine);
if (lineStart != 0) // Wrapped
- pt.x += actualWrapVisualStartIndent * vs.aveCharWidth;
+ pt.x += ll->wrapIndent;
}
}
if (posInLine >= ll->LineStart(subLine)) {
@@ -513,9 +523,9 @@ int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosit
int lineEnd = ll->LineLastVisible(subLine);
int subLineStart = ll->positions[lineStart];
- if (actualWrapVisualStartIndent != 0) {
+ if (ll->wrapIndent != 0) {
if (lineStart != 0) // Wrapped
- pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
+ pt.x -= ll->wrapIndent;
}
int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd);
while (i < lineEnd) {
@@ -565,9 +575,9 @@ int Editor::PositionFromLineX(int lineDoc, int x) {
int lineEnd = ll->LineLastVisible(subLine);
int subLineStart = ll->positions[lineStart];
- if (actualWrapVisualStartIndent != 0) {
+ if (ll->wrapIndent != 0) {
if (lineStart != 0) // Wrapped
- x -= actualWrapVisualStartIndent * vs.aveCharWidth;
+ x -= ll->wrapIndent;
}
int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd);
while (i < lineEnd) {
@@ -1999,6 +2009,20 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
width -= vstyle.aveCharWidth; // take into account the space for end wrap mark
}
+ ll->wrapIndent = wrapAddIndent;
+ if (wrapIndentMode != SC_WRAPINDENT_FIXED)
+ for (int i = 0; i < ll->numCharsInLine; i++) {
+ if (!IsSpaceOrTab(ll->chars[i])) {
+ ll->wrapIndent += ll->positions[i]; // Add line indent
+ break;
+ }
+ }
+ // Check for text width minimum
+ if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15)
+ ll->wrapIndent = wrapAddIndent;
+ // Check for wrapIndent minimum
+ if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < static_cast<int>(vstyle.aveCharWidth)))
+ ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual
ll->lines = 0;
// Calculate line start positions based upon width.
int lastGoodBreak = 0;
@@ -2024,7 +2048,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->SetLineStart(ll->lines, lastGoodBreak);
startOffset = ll->positions[lastGoodBreak];
// take into account the space for start wrap mark and indent
- startOffset -= actualWrapVisualStartIndent * vstyle.aveCharWidth;
+ startOffset -= ll->wrapIndent;
p = lastGoodBreak + 1;
continue;
}
@@ -2417,7 +2441,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
- if (actualWrapVisualStartIndent != 0) {
+ if (ll->wrapIndent != 0) {
bool continuedWrapLine = false;
if (subLine < ll->lines) {
@@ -2429,7 +2453,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
PRectangle rcPlace = rcSegment;
rcPlace.left = ll->positions[startseg] + xStart - subLineStart;
- rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth;
+ rcPlace.right = rcPlace.left + ll->wrapIndent;
// default bgnd here..
surface->FillRectangle(rcSegment, overrideBackground ? background :
@@ -2450,7 +2474,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
DrawWrapMarker(surface, rcPlace, false, wrapColour);
}
- xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth;
+ xStart += ll->wrapIndent;
}
}
@@ -2832,8 +2856,8 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll,
rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[lineStart] + xStart;
// Adjust caret position to take into account any word wrapping symbols.
- if ((actualWrapVisualStartIndent != 0) && (lineStart != 0)) {
- int wordWrapCharWidth = actualWrapVisualStartIndent * vs.aveCharWidth;
+ if ((ll->wrapIndent != 0) && (lineStart != 0)) {
+ int wordWrapCharWidth = ll->wrapIndent;
rcCaret.left += wordWrapCharWidth;
rcCaret.right += wordWrapCharWidth;
}
@@ -3114,10 +3138,10 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
if (ll->InLine(offset, subLine)) {
int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
- if (actualWrapVisualStartIndent != 0) {
+ if (ll->wrapIndent != 0) {
int lineStart = ll->LineStart(subLine);
if (lineStart != 0) // Wrapped
- xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth;
+ xposCaret += ll->wrapIndent;
}
if ((xposCaret >= 0) && (vs.caretWidth > 0) && (vs.caretStyle != CARETSTYLE_INVISIBLE) &&
((posDrag >= 0) || (caret.active && caret.on))) {
@@ -6786,9 +6810,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETWRAPVISUALFLAGS:
wrapVisualFlags = wParam;
- actualWrapVisualStartIndent = wrapVisualStartIndent;
- if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0))
- actualWrapVisualStartIndent = 1; // must indent to show start visual
InvalidateStyleRedraw();
ReconfigureScrollBars();
break;
@@ -6806,9 +6827,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETWRAPSTARTINDENT:
wrapVisualStartIndent = wParam;
- actualWrapVisualStartIndent = wrapVisualStartIndent;
- if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0))
- actualWrapVisualStartIndent = 1; // must indent to show start visual
InvalidateStyleRedraw();
ReconfigureScrollBars();
break;
@@ -6816,6 +6834,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETWRAPSTARTINDENT:
return wrapVisualStartIndent;
+ case SCI_SETWRAPINDENTMODE:
+ wrapIndentMode = wParam;
+ InvalidateStyleRedraw();
+ ReconfigureScrollBars();
+ break;
+
+ case SCI_GETWRAPINDENTMODE:
+ return wrapIndentMode;
+
case SCI_SETLAYOUTCACHE:
llc.SetLevel(wParam);
break;
diff --git a/src/Editor.h b/src/Editor.h
index b74466416..e9372be00 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -235,7 +235,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
int wrapVisualFlags;
int wrapVisualFlagsLocation;
int wrapVisualStartIndent;
- int actualWrapVisualStartIndent;
+ int wrapAddIndent; // This will be added to initial indent of line
+ int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
bool convertPastes;
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index cd5becf1a..71b408236 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -61,7 +61,8 @@ LineLayout::LineLayout(int maxLineLength_) :
hsStart(0),
hsEnd(0),
widthLine(wrapWidthInfinite),
- lines(1) {
+ lines(1),
+ wrapIndent(0) {
Resize(maxLineLength_);
}
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 5d486cb60..6c4c62efd 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -51,6 +51,7 @@ public:
// Wrapped line support
int widthLine;
int lines;
+ int wrapIndent; // In pixels
LineLayout(int maxLineLength_);
virtual ~LineLayout();