aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-07-22 20:32:53 +1000
committerNeil <nyamatongwe@gmail.com>2022-07-22 20:32:53 +1000
commit6d53881b6c21e7824ba3c83ac175bb233f8ff2a8 (patch)
treed526fa4e7f5539d5abdeafe7a9af7820778af36c /src
parente12f8f179666ed70d03c99039565ba63c45f7c7a (diff)
downloadscintilla-mirror-6d53881b6c21e7824ba3c83ac175bb233f8ff2a8.tar.gz
Move EditView::hideSelection to (inverted) SelectionAppearance::visible so that
it can differ between screen and print. Add GetSelectionHidden to allow testing of HideSelection.
Diffstat (limited to 'src')
-rw-r--r--src/EditView.cxx21
-rw-r--r--src/EditView.h1
-rw-r--r--src/Editor.cxx6
-rw-r--r--src/ViewStyle.h2
4 files changed, 17 insertions, 13 deletions
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