diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-04-14 16:54:11 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-04-14 16:54:11 +0200 |
| commit | e18b5353cd1931421db376ac4ace4000dfffa86c (patch) | |
| tree | 21287b785750561712a051a41f18e75064682e66 /src/Fl_Text_Buffer.cxx | |
| parent | afd3fde5de41cd5c10e0953e25976912cf4cf25f (diff) | |
Fixed leak in Fl_Text_Buffer #716
Diffstat (limited to 'src/Fl_Text_Buffer.cxx')
| -rw-r--r-- | src/Fl_Text_Buffer.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index e6eb70c55..2cfe6f1e3 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -158,6 +158,10 @@ public: clear(); } + int size() { + return list_size_; + } + void push(Fl_Text_Undo_Action* action) { if (list_size_ == list_capacity_) { list_capacity_ += 25; @@ -628,6 +632,13 @@ int Fl_Text_Buffer::undo(int *cursorPos) { return ret; } +/* + Check if undo is anabled and if the last action can be undone. + */ +bool Fl_Text_Buffer::can_undo() { + return (mCanUndo && mUndo && !mUndo->empty()); +} + /** Redo previous undo action. */ @@ -642,7 +653,18 @@ int Fl_Text_Buffer::redo(int *cursorPos) { // running the redo action will also generate a new undo action // Note: there is a slight chance that the current undo action and the // generated action merge into one. - return apply_undo(redo_action, cursorPos); + int ret = apply_undo(redo_action, cursorPos); + + delete redo_action; + return ret; +} + +/** + Check if undo is anabled and if the last undo action can be redone. + \see canUndo() + */ +bool Fl_Text_Buffer::can_redo() { + return (mCanUndo && mRedoList->size()); } /* |
