aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--call/ScintillaCall.cxx8
-rw-r--r--doc/ScintillaDoc.html33
-rw-r--r--doc/ScintillaHistory.html2
-rw-r--r--include/Scintilla.h6
-rw-r--r--include/Scintilla.iface12
-rw-r--r--include/ScintillaCall.h4
-rw-r--r--include/ScintillaMessages.h4
-rw-r--r--include/ScintillaTypes.h5
-rw-r--r--src/EditModel.cxx2
-rw-r--r--src/EditModel.h2
-rw-r--r--src/Editor.cxx13
11 files changed, 62 insertions, 29 deletions
diff --git a/call/ScintillaCall.cxx b/call/ScintillaCall.cxx
index 32855b9be..550adc710 100644
--- a/call/ScintillaCall.cxx
+++ b/call/ScintillaCall.cxx
@@ -1259,12 +1259,12 @@ ChangeHistoryOption ScintillaCall::ChangeHistory() {
return static_cast<Scintilla::ChangeHistoryOption>(Call(Message::GetChangeHistory));
}
-void ScintillaCall::SetSelectionUndoHistory(bool selectionUndoHistory) {
- Call(Message::SetSelectionUndoHistory, selectionUndoHistory);
+void ScintillaCall::SetUndoSelectionHistory(Scintilla::UndoSelectionHistoryOption undoSelectionHistory) {
+ Call(Message::SetUndoSelectionHistory, static_cast<uintptr_t>(undoSelectionHistory));
}
-bool ScintillaCall::SelectionUndoHistory() {
- return Call(Message::GetSelectionUndoHistory);
+UndoSelectionHistoryOption ScintillaCall::UndoSelectionHistory() {
+ return static_cast<Scintilla::UndoSelectionHistoryOption>(Call(Message::GetUndoSelectionHistory));
}
Line ScintillaCall::FirstVisibleLine() {
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 44df71562..3bc5acd90 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -1938,8 +1938,8 @@ struct Sci_TextToFindFull {
<a class="message" href="#SCI_ENDUNDOACTION">SCI_ENDUNDOACTION</a><br />
<a class="message" href="#SCI_GETUNDOSEQUENCE">SCI_GETUNDOSEQUENCE &rarr; int</a><br />
<a class="message" href="#SCI_ADDUNDOACTION">SCI_ADDUNDOACTION(int token, int flags)</a><br />
- <a class="message" href="#SCI_SETSELECTIONUNDOHISTORY">SCI_SETSELECTIONUNDOHISTORY(bool selectionUndoHistory)</a><br />
- <a class="message" href="#SCI_GETSELECTIONUNDOHISTORY">SCI_GETSELECTIONUNDOHISTORY &rarr; bool</a><br />
+ <a class="message" href="#SCI_SETUNDOSELECTIONHISTORY">SCI_SETUNDOSELECTIONHISTORY(int undoSelectionHistory)</a><br />
+ <a class="message" href="#SCI_GETUNDOSELECTIONHISTORY">SCI_GETUNDOSELECTIONHISTORY &rarr; int</a><br />
</code>
<p><b id="SCI_UNDO">SCI_UNDO</b><br />
@@ -2018,14 +2018,35 @@ struct Sci_TextToFindFull {
look like typing or deletions that look like multiple uses of the Backspace or Delete keys.
</p>
- <p><b id="SCI_SETSELECTIONUNDOHISTORY">SCI_SETSELECTIONUNDOHISTORY(bool selectionUndoHistory)</b><br />
- <b id="SCI_GETSELECTIONUNDOHISTORY">SCI_GETSELECTIONUNDOHISTORY &rarr; bool</b><br />
+ <p><b id="SCI_SETUNDOSELECTIONHISTORY">SCI_SETUNDOSELECTIONHISTORY(int undoSelectionHistory)</b><br />
+ <b id="SCI_GETUNDOSELECTIONHISTORY">SCI_GETUNDOSELECTIONHISTORY &rarr; int</b><br />
The selection for each action can be saved and then restored when undo or redo is performed.
- <code>SCI_SETSELECTIONUNDOHISTORY</code> controls this.
- The current <code>bool</code> argument may change to a set of flags.
+ <code>SCI_SETUNDOSELECTIONHISTORY</code> controls this.
There is a memory cost for this feature with a minimum of 150 bytes for each of undo and redo for each recorded action.
Recording may be turned on at any time.</p>
+ <p>The <code class="parameter">undoSelectionHistory</code> argument can be:</p>
+ <table class="standard" summary="Undo selection history state">
+ <tbody valign="top">
+ <tr>
+ <th align="left"><code>SC_UNDO_SELECTION_HISTORY_DISABLED</code></th>
+
+ <td>0</td>
+
+ <td>The default: undo selection history turned off.</td>
+ </tr>
+
+ <tr>
+ <th align="left"><code>SC_UNDO_SELECTION_HISTORY_ENABLED</code></th>
+
+ <td>1</td>
+
+ <td>Restore selection for each undo and redo.</td>
+ </tr>
+
+ </tbody>
+ </table>
+
<h2 id="UndoSaveRestore">Undo Save and Restore</h2>
<p>This feature is unfinished and has limitations.
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 5f28aae36..7cb5ebcee 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -595,7 +595,7 @@
Released 18 December 2024.
</li>
<li>
- Remember selection with undo and redo. Controlled with SCI_SETSELECTIONUNDOHISTORY.
+ Remember selection with undo and redo. Controlled with SCI_SETUNDOSELECTIONHISTORY.
<a href="https://sourceforge.net/p/scintilla/feature-requests/1273/">Feature #1273</a>,
<a href="https://sourceforge.net/p/scintilla/bugs/1479/">Bug #1479</a>,
<a href="https://sourceforge.net/p/scintilla/bugs/1224/">Bug #1224</a>.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 9f5b4e7a2..736a7e2d5 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -532,8 +532,10 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SC_CHANGE_HISTORY_INDICATORS 4
#define SCI_SETCHANGEHISTORY 2780
#define SCI_GETCHANGEHISTORY 2781
-#define SCI_SETSELECTIONUNDOHISTORY 2782
-#define SCI_GETSELECTIONUNDOHISTORY 2783
+#define SC_UNDO_SELECTION_HISTORY_DISABLED 0
+#define SC_UNDO_SELECTION_HISTORY_ENABLED 1
+#define SCI_SETUNDOSELECTIONHISTORY 2782
+#define SCI_GETUNDOSELECTIONHISTORY 2783
#define SCI_GETFIRSTVISIBLELINE 2152
#define SCI_GETLINE 2153
#define SCI_GETLINECOUNT 2154
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index ba37ceaf3..65d3d157b 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1334,11 +1334,15 @@ set void SetChangeHistory=2780(ChangeHistoryOption changeHistory,)
# Report change history status.
get ChangeHistoryOption GetChangeHistory=2781(,)
-# Enable or disable selection undo history.
-set void SetSelectionUndoHistory=2782(bool selectionUndoHistory,)
+enu UndoSelectionHistoryOption=SC_UNDO_SELECTION_HISTORY_
+val SC_UNDO_SELECTION_HISTORY_DISABLED=0
+val SC_UNDO_SELECTION_HISTORY_ENABLED=1
-# Report selection undo history status.
-get bool GetSelectionUndoHistory=2783(,)
+# Enable or disable undo selection history.
+set void SetUndoSelectionHistory=2782(UndoSelectionHistoryOption undoSelectionHistory,)
+
+# Report undo selection history status.
+get UndoSelectionHistoryOption GetUndoSelectionHistory=2783(,)
# Retrieve the display line at the top of the display.
get line GetFirstVisibleLine=2152(,)
diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h
index ab0bb3306..bcd462be9 100644
--- a/include/ScintillaCall.h
+++ b/include/ScintillaCall.h
@@ -360,8 +360,8 @@ public:
Position FormatRangeFull(bool draw, RangeToFormatFull *fr);
void SetChangeHistory(Scintilla::ChangeHistoryOption changeHistory);
Scintilla::ChangeHistoryOption ChangeHistory();
- void SetSelectionUndoHistory(bool selectionUndoHistory);
- bool SelectionUndoHistory();
+ void SetUndoSelectionHistory(Scintilla::UndoSelectionHistoryOption undoSelectionHistory);
+ Scintilla::UndoSelectionHistoryOption UndoSelectionHistory();
Line FirstVisibleLine();
Position GetLine(Line line, char *text);
std::string GetLine(Line line);
diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h
index 02dd42e24..f60be4d52 100644
--- a/include/ScintillaMessages.h
+++ b/include/ScintillaMessages.h
@@ -285,8 +285,8 @@ enum class Message {
FormatRangeFull = 2777,
SetChangeHistory = 2780,
GetChangeHistory = 2781,
- SetSelectionUndoHistory = 2782,
- GetSelectionUndoHistory = 2783,
+ SetUndoSelectionHistory = 2782,
+ GetUndoSelectionHistory = 2783,
GetFirstVisibleLine = 2152,
GetLine = 2153,
GetLineCount = 2154,
diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h
index 6d3e2a705..af726b2ab 100644
--- a/include/ScintillaTypes.h
+++ b/include/ScintillaTypes.h
@@ -299,6 +299,11 @@ enum class ChangeHistoryOption {
Indicators = 4,
};
+enum class UndoSelectionHistoryOption {
+ Disabled = 0,
+ Enabled = 1,
+};
+
enum class FoldLevel {
None = 0x0,
Base = 0x400,
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 60848e6dc..1f9c2d064 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -181,7 +181,7 @@ int EditModel::GetMark(Sci::Line line) const {
}
void EditModel::EnsureModelState() {
- if (!modelState && rememberingSelectionForUndo) {
+ if (!modelState && (undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled)) {
if (ViewStateShared vss = pdoc->GetViewState(this)) {
modelState = std::dynamic_pointer_cast<ModelState>(vss);
} else {
diff --git a/src/EditModel.h b/src/EditModel.h
index 716fd5788..f75cece44 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -92,7 +92,7 @@ public:
Document *pdoc;
- bool rememberingSelectionForUndo = false;
+ Scintilla::UndoSelectionHistoryOption undoSelectionHistoryOption = UndoSelectionHistoryOption::Disabled;
bool needRedoRemembered = false;
ModelStateShared modelState;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 8a7b15719..d63f43f3f 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2399,7 +2399,7 @@ void Editor::SelectAll() {
}
void Editor::RestoreSelection(Sci::Position newPos, UndoRedo history) {
- if (rememberingSelectionForUndo && modelState) {
+ if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) && modelState) {
// Undo wants the element after the current as it just undid it
const int index = pdoc->UndoCurrent() + (history == UndoRedo::undo ? 1 : 0);
const SelectionSimple *pss = modelState->SelectionFromStack(index, history);
@@ -2789,7 +2789,8 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
}
} else {
- if (rememberingSelectionForUndo && FlagSet(mh.modificationType, ModificationFlags::User)) {
+ if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) &&
+ FlagSet(mh.modificationType, ModificationFlags::User)) {
if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)) {
RememberSelectionForUndo(pdoc->UndoCurrent());
}
@@ -8687,12 +8688,12 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::GetChangeHistory:
return static_cast<sptr_t>(changeHistoryOption);
- case Message::SetSelectionUndoHistory:
- rememberingSelectionForUndo = wParam;
+ case Message::SetUndoSelectionHistory:
+ undoSelectionHistoryOption = static_cast<UndoSelectionHistoryOption>(wParam);
break;
- case Message::GetSelectionUndoHistory:
- return rememberingSelectionForUndo;
+ case Message::GetUndoSelectionHistory:
+ return static_cast<sptr_t>(undoSelectionHistoryOption);
case Message::SetExtraAscent:
vs.extraAscent = static_cast<int>(wParam);