diff options
author | Neil <nyamatongwe@gmail.com> | 2024-07-28 09:48:13 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2024-07-28 09:48:13 +1000 |
commit | 1cccf5165b891eb95c85932474bb872ab0fbe638 (patch) | |
tree | 1772ba118f46766cd81814f69ee413a5556e1e06 /src | |
parent | 76ef74bc44e201562320906ca18d3add7084ff8b (diff) | |
download | scintilla-mirror-1cccf5165b891eb95c85932474bb872ab0fbe638.tar.gz |
Add SCI_GETUNDOSEQUENCE to determine whether an undo sequence is active and its
nesting depth.
Diffstat (limited to 'src')
-rw-r--r-- | src/CellBuffer.cxx | 4 | ||||
-rw-r--r-- | src/CellBuffer.h | 1 | ||||
-rw-r--r-- | src/Document.cxx | 4 | ||||
-rw-r--r-- | src/Document.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 3 | ||||
-rw-r--r-- | src/UndoHistory.cxx | 4 | ||||
-rw-r--r-- | src/UndoHistory.h | 1 |
7 files changed, 18 insertions, 0 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index b0b9d9c39..4985517e0 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -1070,6 +1070,10 @@ void CellBuffer::EndUndoAction() noexcept { uh->EndUndoAction(); } +int CellBuffer::UndoSequenceDepth() const noexcept { + return uh->UndoSequenceDepth(); +} + void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) { bool startSequence = false; uh->AppendAction(ActionType::container, token, nullptr, 0, startSequence, mayCoalesce); diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 3a72601a6..d5d9a0467 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -166,6 +166,7 @@ public: bool IsCollectingUndo() const noexcept; void BeginUndoAction(bool mayCoalesce=false) noexcept; void EndUndoAction() noexcept; + int UndoSequenceDepth() const noexcept; void AddUndoAction(Sci::Position token, bool mayCoalesce); void DeleteUndoHistory() noexcept; diff --git a/src/Document.cxx b/src/Document.cxx index 3ae8964ba..88b876ebd 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1543,6 +1543,10 @@ Sci::Position Document::Redo() { return newPos; } +int Document::UndoSequenceDepth() const noexcept { + return cb.UndoSequenceDepth(); +} + void Document::DelChar(Sci::Position pos) { DeleteChars(pos, LenChar(pos)); } diff --git a/src/Document.h b/src/Document.h index efb1ae6d6..fa1c3fe42 100644 --- a/src/Document.h +++ b/src/Document.h @@ -397,6 +397,7 @@ public: bool IsCollectingUndo() const noexcept { return cb.IsCollectingUndo(); } void BeginUndoAction(bool coalesceWithPrior=false) noexcept { cb.BeginUndoAction(coalesceWithPrior); } void EndUndoAction() noexcept { cb.EndUndoAction(); } + int UndoSequenceDepth() const noexcept; void AddUndoAction(Sci::Position token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } void SetSavePoint(); bool IsSavePoint() const noexcept { return cb.IsSavePoint(); } diff --git a/src/Editor.cxx b/src/Editor.cxx index 390c83898..0561b42f8 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6636,6 +6636,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { pdoc->EndUndoAction(); return 0; + case Message::GetUndoSequence: + return pdoc->UndoSequenceDepth(); + case Message::GetUndoActions: return pdoc->UndoActions(); diff --git a/src/UndoHistory.cxx b/src/UndoHistory.cxx index c4b241103..c0d7ba5f2 100644 --- a/src/UndoHistory.cxx +++ b/src/UndoHistory.cxx @@ -350,6 +350,10 @@ void UndoHistory::EndUndoAction() noexcept { } } +int UndoHistory::UndoSequenceDepth() const noexcept { + return undoSequenceDepth; +} + void UndoHistory::DropUndoSequence() noexcept { undoSequenceDepth = 0; } diff --git a/src/UndoHistory.h b/src/UndoHistory.h index 8cde395ae..be639c541 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -101,6 +101,7 @@ public: void BeginUndoAction(bool mayCoalesce=false) noexcept; void EndUndoAction() noexcept; + int UndoSequenceDepth() const noexcept; void DropUndoSequence() noexcept; void DeleteUndoHistory() noexcept; |