aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2019-02-02 10:26:58 +1100
committerZufu Liu <unknown>2019-02-02 10:26:58 +1100
commit9cc096e3f7deb6f10512e30da3e589eed927fdd5 (patch)
tree2430275cd7bece15c853a71af9fb64267d4476a0
parent3b23e66a4f754a935f308a5c41a2f08f2968d5c3 (diff)
downloadscintilla-mirror-9cc096e3f7deb6f10512e30da3e589eed927fdd5.tar.gz
Backport: Feature [feature-requests:#1217]. Implement CARETSTYLE_BLOCK_ALWAYS.
Backport of changeset 7248:aba09a1c7c63.
-rw-r--r--doc/ScintillaDoc.html8
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--src/EditView.cxx6
-rw-r--r--src/EditView.h2
-rw-r--r--src/Editor.cxx4
7 files changed, 17 insertions, 9 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index e897060ae..81f2ef551 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -3210,11 +3210,13 @@ struct Sci_TextToFind {
<p><b id="SCI_SETCARETSTYLE">SCI_SETCARETSTYLE(int caretStyle)</b><br />
<b id="SCI_GETCARETSTYLE">SCI_GETCARETSTYLE &rarr; int</b><br />
The style of the caret can be set with <code>SCI_SETCARETSTYLE</code> to be a line caret
- (CARETSTYLE_LINE=1), a block caret (CARETSTYLE_BLOCK=2) or to not draw at all
- (CARETSTYLE_INVISIBLE=0). The default value is the line caret (CARETSTYLE_LINE=1).
+ (CARETSTYLE_LINE=1, insert mode), a block caret (CARETSTYLE_BLOCK=2, insert mode),
+ a block caret in both insert and overtype mode (CARETSTYLE_BLOCK_ALWAYS=3) or to not draw at all
+ (CARETSTYLE_INVISIBLE=0, insert mode). The default value for insert mode is the line caret (CARETSTYLE_LINE=1),
+ for overtype mode is the bar caret.
You can determine the current caret style setting using <code>SCI_GETCARETSTYLE</code>.</p>
- <p>The block character draws most combining and multibyte character sequences successfully,
+ <p>The block caret draws most combining and multibyte character sequences successfully,
though some fonts like Thai Fonts (and possibly others) can sometimes appear strange when
the cursor is positioned at these characters, which may result in only drawing a part of the
cursor character sequence. This is most notable on Windows platforms.</p>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 70bf1b3f3..6156a68a4 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -554,6 +554,10 @@
<a href="https://sourceforge.net/p/scintilla/bugs/1548/">Bug #1548</a>.
</li>
<li>
+ Block caret in both insert and overtype mode SCI_SETCARETSTYLE(CARETSTYLE_BLOCK_ALWAYS).
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1217/">Feature #1217</a>.
+ </li>
+ <li>
The C++ lexer, with styling.within.preprocessor on, now interprets "(" in preprocessor "#if("
as an operator instead of part of the directive. This improves folding as well which could become
unbalanced.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 298103cea..9a7ddb1b3 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -829,6 +829,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define CARETSTYLE_INVISIBLE 0
#define CARETSTYLE_LINE 1
#define CARETSTYLE_BLOCK 2
+#define CARETSTYLE_BLOCK_ALWAYS 3
#define SCI_SETCARETSTYLE 2512
#define SCI_GETCARETSTYLE 2513
#define SCI_SETINDICATORCURRENT 2500
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 7cbb20020..f0099d901 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -2178,6 +2178,7 @@ enu CaretStyle=CARETSTYLE_
val CARETSTYLE_INVISIBLE=0
val CARETSTYLE_LINE=1
val CARETSTYLE_BLOCK=2
+val CARETSTYLE_BLOCK_ALWAYS=3
# Set the style of the caret to be drawn.
set void SetCaretStyle=2512(int caretStyle,)
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 3143134d2..8eaaee32c 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -1331,7 +1331,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
for (size_t r = 0; (r<model.sel.Count()) || drawDrag; r++) {
const bool mainCaret = r == model.sel.Main();
SelectionPosition posCaret = (drawDrag ? model.posDrag : model.sel.Range(r).caret);
- if (vsDraw.caretStyle == CARETSTYLE_BLOCK && !drawDrag && posCaret > model.sel.Range(r).anchor) {
+ if ((vsDraw.caretStyle == CARETSTYLE_BLOCK || vsDraw.caretStyle == CARETSTYLE_BLOCK_ALWAYS) && !drawDrag && posCaret > model.sel.Range(r).anchor) {
if (posCaret.VirtualSpace() > 0)
posCaret.SetVirtualSpace(posCaret.VirtualSpace() - 1);
else
@@ -1378,12 +1378,12 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
/* Dragging text, use a line caret */
rcCaret.left = round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
- } else if (model.inOverstrike && drawOverstrikeCaret) {
+ } else if ((model.inOverstrike && vsDraw.caretStyle != CARETSTYLE_BLOCK_ALWAYS) && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
rcCaret.top = rcCaret.bottom - 2;
rcCaret.left = xposCaret + 1;
rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
- } else if ((vsDraw.caretStyle == CARETSTYLE_BLOCK) || imeCaretBlockOverride) {
+ } else if ((vsDraw.caretStyle == CARETSTYLE_BLOCK || vsDraw.caretStyle == CARETSTYLE_BLOCK_ALWAYS) || imeCaretBlockOverride) {
/* Block caret */
rcCaret.left = xposCaret;
if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) {
diff --git a/src/EditView.h b/src/EditView.h
index f649f7c87..300dc92a9 100644
--- a/src/EditView.h
+++ b/src/EditView.h
@@ -54,7 +54,7 @@ public:
int tabWidthMinimumPixels;
bool hideSelection;
- bool drawOverstrikeCaret;
+ bool drawOverstrikeCaret; // used by the curses platform
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 563b3a665..f48ba333b 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1351,7 +1351,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2;
} else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) {
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2;
- if ((vs.caretStyle == CARETSTYLE_BLOCK) || view.imeCaretBlockOverride) {
+ if ((vs.caretStyle == CARETSTYLE_BLOCK || vs.caretStyle == CARETSTYLE_BLOCK_ALWAYS) || view.imeCaretBlockOverride) {
// Ensure we can see a good portion of the block caret
newXY.xOffset += static_cast<int>(vs.aveCharWidth);
}
@@ -7277,7 +7277,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.caretcolour.AsInteger();
case SCI_SETCARETSTYLE:
- if (wParam <= CARETSTYLE_BLOCK)
+ if (wParam <= CARETSTYLE_BLOCK_ALWAYS)
vs.caretStyle = static_cast<int>(wParam);
else
/* Default to the line caret */