diff options
-rw-r--r-- | call/ScintillaCall.cxx | 4 | ||||
-rw-r--r-- | doc/ScintillaDoc.html | 10 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 3 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | include/ScintillaCall.h | 1 | ||||
-rw-r--r-- | include/ScintillaMessages.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 3 | ||||
-rw-r--r-- | test/simpleTests.py | 19 |
9 files changed, 42 insertions, 3 deletions
diff --git a/call/ScintillaCall.cxx b/call/ScintillaCall.cxx index dcffb8a7e..4981d6299 100644 --- a/call/ScintillaCall.cxx +++ b/call/ScintillaCall.cxx @@ -2367,6 +2367,10 @@ SelectionMode ScintillaCall::SelectionMode() { return static_cast<Scintilla::SelectionMode>(Call(Message::GetSelectionMode)); } +void ScintillaCall::SetMoveExtendsSelection(bool moveExtendsSelection) { + Call(Message::SetMoveExtendsSelection, moveExtendsSelection); +} + bool ScintillaCall::MoveExtendsSelection() { return Call(Message::GetMoveExtendsSelection); } diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index c0b80e793..43407a40b 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -129,7 +129,7 @@ <h1>Scintilla Documentation</h1> - <p>Last edited 1 November 2023 NH</p> + <p>Last edited 5 November 2023 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 /> @@ -980,6 +980,7 @@ struct Sci_TextRangeFull { <a class="message" href="#SCI_SELECTIONISRECTANGLE">SCI_SELECTIONISRECTANGLE → bool</a><br /> <a class="message" href="#SCI_SETSELECTIONMODE">SCI_SETSELECTIONMODE(int selectionMode)</a><br /> <a class="message" href="#SCI_GETSELECTIONMODE">SCI_GETSELECTIONMODE → int</a><br /> + <a class="message" href="#SCI_SETMOVEEXTENDSSELECTION">SCI_SETMOVEEXTENDSSELECTION(bool moveExtendsSelection)</a><br /> <a class="message" href="#SCI_GETMOVEEXTENDSSELECTION">SCI_GETMOVEEXTENDSSELECTION → bool</a><br /> <a class="message" href="#SCI_GETLINESELSTARTPOSITION">SCI_GETLINESELSTARTPOSITION(line line) → position</a><br /> <a class="message" href="#SCI_GETLINESELENDPOSITION">SCI_GETLINESELENDPOSITION(line line) → position</a><br /> @@ -1135,8 +1136,11 @@ struct Sci_TextRangeFull { <code>SC_SEL_THIN</code> is the mode after a rectangular selection has been typed into and ensures that no characters are selected.</p> - <p><b id="SCI_GETMOVEEXTENDSSELECTION">SCI_GETMOVEEXTENDSSELECTION → bool</b><br /> - This returns 1 if regular caret moves will extend or reduce the selection, 0 if not. + <p> + <b id="SCI_SETMOVEEXTENDSSELECTION">SCI_SETMOVEEXTENDSSELECTION(bool moveExtendsSelection)</b><br /> + <b id="SCI_GETMOVEEXTENDSSELECTION">SCI_GETMOVEEXTENDSSELECTION → bool</b><br /> + This controls whether regular caret moves extends the selection leaving the anchor unchanged. + It is 1 if regular caret moves will extend or reduce the selection, 0 if not. <code>SCI_SETSELECTIONMODE</code> toggles this setting between on and off.</p> <p><b id="SCI_GETLINESELSTARTPOSITION">SCI_GETLINESELSTARTPOSITION(line line) → position</b><br /> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 333121b42..f823ee0ef 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -591,6 +591,9 @@ Released 18 November 2023. </li> <li> + Add SCI_SETMOVEEXTENDSSELECTION to simplify selection mode manipulation. + </li> + <li> Improve performance of global replace by reducing cache invalidation overhead. <a href="https://sourceforge.net/p/scintilla/feature-requests/1502/">Feature #1502</a>. </li> diff --git a/include/Scintilla.h b/include/Scintilla.h index 43a41e986..5b85dac47 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -875,6 +875,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP #define SC_SEL_THIN 3 #define SCI_SETSELECTIONMODE 2422 #define SCI_GETSELECTIONMODE 2423 +#define SCI_SETMOVEEXTENDSSELECTION 2719 #define SCI_GETMOVEEXTENDSSELECTION 2706 #define SCI_GETLINESELSTARTPOSITION 2424 #define SCI_GETLINESELENDPOSITION 2425 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 9f02c78d2..b15606af0 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2362,6 +2362,9 @@ set void SetSelectionMode=2422(SelectionMode selectionMode,) # Get the mode of the current selection. get SelectionMode GetSelectionMode=2423(,) +# Set whether or not regular caret moves will extend or reduce the selection. +set void SetMoveExtendsSelection=2719(bool moveExtendsSelection,) + # Get whether or not regular caret moves will extend or reduce the selection. get bool GetMoveExtendsSelection=2706(,) diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h index 8a01f2acb..0c95ef9e7 100644 --- a/include/ScintillaCall.h +++ b/include/ScintillaCall.h @@ -635,6 +635,7 @@ public: void CopyText(Position length, const char *text); void SetSelectionMode(Scintilla::SelectionMode selectionMode); Scintilla::SelectionMode SelectionMode(); + void SetMoveExtendsSelection(bool moveExtendsSelection); bool MoveExtendsSelection(); Position GetLineSelStartPosition(Line line); Position GetLineSelEndPosition(Line line); diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h index 12b2c2504..e45398d72 100644 --- a/include/ScintillaMessages.h +++ b/include/ScintillaMessages.h @@ -557,6 +557,7 @@ enum class Message { CopyText = 2420, SetSelectionMode = 2422, GetSelectionMode = 2423, + SetMoveExtendsSelection = 2719, GetMoveExtendsSelection = 2706, GetLineSelStartPosition = 2424, GetLineSelEndPosition = 2425, diff --git a/src/Editor.cxx b/src/Editor.cxx index 0b65041d2..ca7fe2e88 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -8226,6 +8226,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { default: // ?! return static_cast<sptr_t>(SelectionMode::Stream); } + case Message::SetMoveExtendsSelection: + sel.SetMoveExtends(wParam != 0); + break; case Message::GetMoveExtendsSelection: return sel.MoveExtends(); case Message::GetLineSelStartPosition: diff --git a/test/simpleTests.py b/test/simpleTests.py index d372e0fbd..6f82c4004 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -2057,6 +2057,7 @@ class TestModalSelection(unittest.TestCase): self.assertEqual(self.ed.GetSelectionNAnchor(0), 1) self.ed.SelectionMode = self.ed.SC_SEL_STREAM self.assertEqual(self.ed.GetSelectionMode(), self.ed.SC_SEL_STREAM) + self.assertEqual(self.ed.MoveExtendsSelection, True) self.assertEqual(self.ed.Selections, 1) self.assertEqual(self.ed.MainSelection, 0) self.assertEqual(self.ed.GetSelectionNCaret(0), 1) @@ -2072,6 +2073,24 @@ class TestModalSelection(unittest.TestCase): self.assertEqual(self.ed.GetSelectionNCaret(0), 6) self.assertEqual(self.ed.GetSelectionNAnchor(0), 1) self.ed.ClearSelections() + + def testTurningOffMoveExtendsSelection(self): + self.ed.SetSelection(1, 1) + self.ed.SelectionMode = self.ed.SC_SEL_STREAM + self.ed.CharRight() + self.ed.LineDown() + self.assertEqual(self.ed.MoveExtendsSelection, True) + self.ed.MoveExtendsSelection = False + self.assertEqual(self.ed.MoveExtendsSelection, False) + self.ed.CharRight() + self.assertEqual(self.ed.Selections, 1) + self.assertEqual(self.ed.MainSelection, 0) + self.assertEqual(selectionRepresentation(self.ed, 0), "6-6") + self.ed.CharRight() + self.assertEqual(self.ed.Selections, 1) + self.assertEqual(self.ed.MainSelection, 0) + self.assertEqual(selectionRepresentation(self.ed, 0), "7-7") + self.ed.ClearSelections() def testRectangleSelection(self): self.ed.SetSelection(1, 1) |