aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--call/ScintillaCall.cxx4
-rw-r--r--doc/ScintillaDoc.html10
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--include/ScintillaCall.h1
-rw-r--r--include/ScintillaMessages.h1
-rw-r--r--src/EditView.cxx21
-rw-r--r--src/EditView.h1
-rw-r--r--src/Editor.cxx6
-rw-r--r--src/ViewStyle.h2
-rw-r--r--test/simpleTests.py7
11 files changed, 40 insertions, 17 deletions
diff --git a/call/ScintillaCall.cxx b/call/ScintillaCall.cxx
index 20fb452da..e142af79d 100644
--- a/call/ScintillaCall.cxx
+++ b/call/ScintillaCall.cxx
@@ -1215,6 +1215,10 @@ void ScintillaCall::HideSelection(bool hide) {
Call(Message::HideSelection, hide);
}
+bool ScintillaCall::SelectionHidden() {
+ return Call(Message::GetSelectionHidden);
+}
+
int ScintillaCall::PointXFromPosition(Position pos) {
return static_cast<int>(Call(Message::PointXFromPosition, 0, pos));
}
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index b1d2b5e09..503984654 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -129,7 +129,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 15 May 2022 NH</p>
+ <p>Last edited 18 July 2022 NH</p>
<p style="background:#90F0C0">Scintilla 5 has moved the lexers from Scintilla into a new
<a href="Lexilla.html">Lexilla</a> project.<br />
@@ -1382,6 +1382,7 @@ struct Sci_TextToFindFull {
<a class="message" href="#SCI_POINTXFROMPOSITION">SCI_POINTXFROMPOSITION(&lt;unused&gt;, position pos) &rarr; int</a><br />
<a class="message" href="#SCI_POINTYFROMPOSITION">SCI_POINTYFROMPOSITION(&lt;unused&gt;, position pos) &rarr; int</a><br />
<a class="message" href="#SCI_HIDESELECTION">SCI_HIDESELECTION(bool hide)</a><br />
+ <a class="message" href="#SCI_GETSELECTIONHIDDEN">SCI_GETSELECTIONHIDDEN &rarr; bool</a><br />
<a class="message" href="#SCI_GETSELTEXT">SCI_GETSELTEXT(&lt;unused&gt;, char *text) &rarr; position</a><br />
<a class="message" href="#SCI_GETCURLINE">SCI_GETCURLINE(position length, char *text) &rarr; position</a><br />
<a class="message" href="#SCI_SELECTIONISRECTANGLE">SCI_SELECTIONISRECTANGLE &rarr; bool</a><br />
@@ -1651,10 +1652,11 @@ struct Sci_TextToFindFull {
in the document.</p>
<p><b id="SCI_HIDESELECTION">SCI_HIDESELECTION(bool hide)</b><br />
+ <b id="SCI_GETSELECTIONHIDDEN">SCI_GETSELECTIONHIDDEN &rarr; bool</b><br />
The normal state is to make the selection visible by drawing it as set by <a class="message"
- href="#SCI_SETSELFORE"><code>SCI_SETSELFORE</code></a> and <a class="message"
- href="#SCI_SETSELBACK"><code>SCI_SETSELBACK</code></a>. However, if you hide the selection, it
- is drawn as normal text.</p>
+ href="#SCI_SETSELFORE"><code>SCI_SETSELFORE</code></a>, <a class="message"
+ href="#SCI_SETSELBACK"><code>SCI_SETSELBACK</code></a>, and related calls.
+ However, if you hide the selection, it is drawn as normal text.</p>
<p><b id="SCI_CHOOSECARETX">SCI_CHOOSECARETX</b><br />
Scintilla remembers the x value of the last position horizontally moved to explicitly by the
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 0a5c46933..c65cb87a3 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -491,6 +491,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_GETTEXTRANGE 2162
#define SCI_GETTEXTRANGEFULL 2039
#define SCI_HIDESELECTION 2163
+#define SCI_GETSELECTIONHIDDEN 2088
#define SCI_POINTXFROMPOSITION 2164
#define SCI_POINTYFROMPOSITION 2165
#define SCI_LINEFROMPOSITION 2166
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index be3d78692..bfa7f5e93 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1271,6 +1271,9 @@ fun position GetTextRangeFull=2039(, textrangefull tr)
# Draw the selection either highlighted or in normal (non-highlighted) style.
fun void HideSelection=2163(bool hide,)
+#Is the selection visible or hidden?
+get bool GetSelectionHidden=2088(,)
+
# Retrieve the x value of the point in the window where a position is displayed.
fun int PointXFromPosition=2164(, position pos)
diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h
index 40cf1e576..549c372b5 100644
--- a/include/ScintillaCall.h
+++ b/include/ScintillaCall.h
@@ -342,6 +342,7 @@ public:
Position GetTextRange(void *tr);
Position GetTextRangeFull(void *tr);
void HideSelection(bool hide);
+ bool SelectionHidden();
int PointXFromPosition(Position pos);
int PointYFromPosition(Position pos);
Line LineFromPosition(Position pos);
diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h
index 3b2927472..d114db78d 100644
--- a/include/ScintillaMessages.h
+++ b/include/ScintillaMessages.h
@@ -275,6 +275,7 @@ enum class Message {
GetTextRange = 2162,
GetTextRangeFull = 2039,
HideSelection = 2163,
+ GetSelectionHidden = 2088,
PointXFromPosition = 2164,
PointYFromPosition = 2165,
LineFromPosition = 2166,
diff --git a/src/EditView.cxx b/src/EditView.cxx
index bb519350f..554582bcb 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -185,7 +185,6 @@ void Hexits(char *hexits, int ch) noexcept {
EditView::EditView() {
tabWidthMinimumPixels = 2; // needed for calculating tab stops for fractional proportional fonts
- hideSelection = false;
drawOverstrikeCaret = true;
bufferedDraw = true;
phasesDraw = PhasesDraw::Two;
@@ -1076,7 +1075,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.right = xEol + xStart + virtualSpace;
const ColourRGBA backgroundFill = background.value_or(vsDraw.styles[ll->styles[ll->numCharsInLine]].back);
surface->FillRectangleAligned(rcSegment, backgroundFill);
- if (!hideSelection && (vsDraw.selection.layer == Layer::Base)) {
+ if (vsDraw.selection.visible && (vsDraw.selection.layer == Layer::Base)) {
const SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)),
SelectionPosition(model.pdoc->LineEnd(line),
model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line))));
@@ -1098,7 +1097,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
InSelection eolInSelection = InSelection::inNone;
- if (!hideSelection && lastSubLine) {
+ if (vsDraw.selection.visible && lastSubLine) {
eolInSelection = model.LineEndInSelection(line);
}
@@ -1354,7 +1353,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
const int widthFoldDisplayText = static_cast<int>(surface->WidthText(fontText, foldDisplayText));
InSelection eolInSelection = InSelection::inNone;
- if (!hideSelection) {
+ if (vsDraw.selection.visible) {
eolInSelection = model.LineEndInSelection(line);
}
@@ -1684,7 +1683,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
Sci::Line lineDoc, int xStart, PRectangle rcLine, int subLine) const {
// When drag is active it is the only caret drawn
const bool drawDrag = model.posDrag.IsValid();
- if (hideSelection && !drawDrag)
+ if (!vsDraw.selection.visible && !drawDrag)
return;
const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
// For each selection draw
@@ -1870,7 +1869,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
if (rcSegment.right > rcLine.right)
rcSegment.right = rcLine.right;
- InSelection inSelection = hideSelection ? InSelection::inNone : model.sel.CharacterInSelection(iDoc);
+ InSelection inSelection = vsDraw.selection.visible ? model.sel.CharacterInSelection(iDoc) : InSelection::inNone;
if (FlagSet(vsDraw.caret.style, CaretStyle::Curses) && (inSelection == InSelection::inMain))
inSelection = CharacterInCursesSelection(iDoc, model, vsDraw);
const bool inHotspot = model.hotspot.Valid() && model.hotspot.ContainsCharacter(iDoc);
@@ -2119,7 +2118,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
}
}
}
- InSelection inSelection = hideSelection ? InSelection::inNone : model.sel.CharacterInSelection(iDoc);
+ InSelection inSelection = vsDraw.selection.visible ? model.sel.CharacterInSelection(iDoc) : InSelection::inNone;
if (FlagSet(vsDraw.caret.style, CaretStyle::Curses) && (inSelection == InSelection::inMain))
inSelection = CharacterInCursesSelection(iDoc, model, vsDraw);
const std::optional<ColourRGBA> selectionFore = SelectionForeground(model, vsDraw, inSelection);
@@ -2357,7 +2356,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
if (FlagSet(phase, DrawPhase::text)) {
- if (!hideSelection) {
+ if (vsDraw.selection.visible) {
DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::UnderText);
}
DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::UnderText);
@@ -2386,7 +2385,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
DrawMarkUnderline(surface, model, vsDraw, line, rcLine);
}
- if (!hideSelection && FlagSet(phase, DrawPhase::selectionTranslucent)) {
+ if (vsDraw.selection.visible && FlagSet(phase, DrawPhase::selectionTranslucent)) {
DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::OverText);
}
@@ -2523,7 +2522,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
durLayout += ep.Duration(true);
#endif
if (ll) {
- ll->containsCaret = !hideSelection && (lineDoc == lineCaret)
+ ll->containsCaret = vsDraw.selection.visible && (lineDoc == lineCaret)
&& (ll->lines == 1 || !vsDraw.caretLine.subLine || ll->InLine(caretOffset, subLine));
PRectangle rcLine = rcTextArea;
@@ -2633,7 +2632,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, PRectangle rcArea, int subLine) const {
InSelection eolInSelection = InSelection::inNone;
- if ((!hideSelection) && (subLine == (ll->lines - 1))) {
+ if (vsDraw.selection.visible && (subLine == (ll->lines - 1))) {
eolInSelection = model.LineEndInSelection(line);
}
diff --git a/src/EditView.h b/src/EditView.h
index d65bf0736..832da9f15 100644
--- a/src/EditView.h
+++ b/src/EditView.h
@@ -56,7 +56,6 @@ public:
std::unique_ptr<LineTabstops> ldTabstops;
int tabWidthMinimumPixels;
- bool hideSelection;
bool drawOverstrikeCaret; // used by the curses platform
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f99914ebd..5b0486be0 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6322,10 +6322,14 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
}
case Message::HideSelection:
- view.hideSelection = wParam != 0;
+ vs.selection.visible = wParam == 0;
Redraw();
break;
+ case Message::GetSelectionHidden:
+ return !vs.selection.visible;
+ break;
+
case Message::FormatRange:
case Message::FormatRangeFull:
return FormatRange(iMessage, wParam, lParam);
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index ce6bd5642..c5ee232c3 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -46,6 +46,8 @@ inline std::optional<ColourRGBA> OptionalColour(Scintilla::uptr_t wParam, Scinti
}
struct SelectionAppearance {
+ // Is the selection visible?
+ bool visible = true;
// Whether to draw on base layer or over text
Scintilla::Layer layer = Layer::Base;
// Draw selection past line end characters up to right border
diff --git a/test/simpleTests.py b/test/simpleTests.py
index 195479eaa..3ea186cf9 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -2201,6 +2201,13 @@ class TestElements(unittest.TestCase):
self.ed.ResetElementColour(self.ed.SC_ELEMENT_HOT_SPOT_ACTIVE)
self.ed.ResetElementColour(self.ed.SC_ELEMENT_HOT_SPOT_ACTIVE_BACK)
+ def testHideSelection(self):
+ self.assertEquals(self.ed.SelectionHidden, False)
+ self.ed.HideSelection(True)
+ self.assertEquals(self.ed.SelectionHidden, True)
+ self.ed.HideSelection(False) # Restore
+ self.assertEquals(self.ed.SelectionHidden, False)
+
class TestIndices(unittest.TestCase):
def setUp(self):
self.xite = Xite.xiteFrame