diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-02-10 17:13:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-10 17:13:20 +0100 |
| commit | 7f87c847ba8ec976c6ad345942f9867658a89ab2 (patch) | |
| tree | 00717f3197ea9d2d76c45207dd4f468b2ee201cb /FL | |
| parent | 72f860438170638d6aa492b477a59ff88b565d9d (diff) | |
Unlimited undo/redo for Fl_Input_ and Fl_Text_Buffer (#558) (#676)
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Input.H | 2 | ||||
| -rw-r--r-- | FL/Fl_Input_.H | 9 | ||||
| -rw-r--r-- | FL/Fl_Text_Buffer.H | 15 | ||||
| -rw-r--r-- | FL/Fl_Text_Editor.H | 3 |
4 files changed, 26 insertions, 3 deletions
diff --git a/FL/Fl_Input.H b/FL/Fl_Input.H index 93d1c2642..f53debd50 100644 --- a/FL/Fl_Input.H +++ b/FL/Fl_Input.H @@ -1,7 +1,7 @@ // // Input header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this diff --git a/FL/Fl_Input_.H b/FL/Fl_Input_.H index d89a341bc..a7062f5a0 100644 --- a/FL/Fl_Input_.H +++ b/FL/Fl_Input_.H @@ -39,6 +39,7 @@ #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP) class Fl_Input_Undo_Action; +class Fl_Input_Undo_Action_List; /** This class provides a low-overhead text input field. @@ -148,6 +149,8 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget { /** \internal local undo event */ Fl_Input_Undo_Action* undo_; + Fl_Input_Undo_Action_List* undo_list_; + Fl_Input_Undo_Action_List* redo_list_; /** \internal Horizontal cursor position in pixels while moving up or down. */ static double up_down_pos; @@ -212,6 +215,9 @@ protected: /* Return the number of lines displayed on a single page. */ int linesPerPage(); + /* Apply the current undo/redo operation, called from undo() or redo() */ + int apply_undo(); + public: /* Change the size of the widget. */ @@ -378,6 +384,9 @@ public: /* Undo previous changes to the text buffer. */ int undo(); + /* Redo previous undo operations. */ + int redo(); + /* Copy the yank buffer to the clipboard. */ int copy_cuts(); diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H index e3e131ef1..dabe5677a 100644 --- a/FL/Fl_Text_Buffer.H +++ b/FL/Fl_Text_Buffer.H @@ -1,7 +1,7 @@ // // Header file for Fl_Text_Buffer class. // -// Copyright 2001-2021 by Bill Spitzak and others. +// Copyright 2001-2023 by Bill Spitzak and others. // Original code Copyright Mark Edel. Permission to distribute under // the LGPL for the FLTK library granted by Mark Edel. // @@ -61,6 +61,7 @@ #include "Fl_Export.H" +class Fl_Text_Undo_Action_List; class Fl_Text_Undo_Action; /** @@ -327,6 +328,11 @@ public: int undo(int *cp=0); /** + Redo previous undo action. + */ + int redo(int *cp=0); + + /** Lets the undo system know if we can undo changes */ void canUndo(char flag=1); @@ -813,6 +819,11 @@ protected: */ void update_selections(int pos, int nDeleted, int nInserted); + /** + Apply the current undo/redo operation, called from undo() or redo(). + */ + int apply_undo(Fl_Text_Undo_Action* action, int* cursorPos); + Fl_Text_Selection mPrimary; /**< highlighted areas */ Fl_Text_Selection mSecondary; /**< highlighted areas */ Fl_Text_Selection mHighlight; /**< highlighted areas */ @@ -841,6 +852,8 @@ protected: bytes and should only be increased if frequent and large changes in buffer size are expected */ Fl_Text_Undo_Action* mUndo; /**< local undo event */ + Fl_Text_Undo_Action_List* mUndoList; /**< List of undo event */ + Fl_Text_Undo_Action_List* mRedoList; /**< List of redo event */ }; #endif diff --git a/FL/Fl_Text_Editor.H b/FL/Fl_Text_Editor.H index 5bf49781e..16af25451 100644 --- a/FL/Fl_Text_Editor.H +++ b/FL/Fl_Text_Editor.H @@ -1,7 +1,7 @@ // // Header file for Fl_Text_Editor class. // -// Copyright 2001-2010 by Bill Spitzak and others. +// Copyright 2001-2023 by Bill Spitzak and others. // Original code Copyright Mark Edel. Permission to distribute under // the LGPL for the FLTK library granted by Mark Edel. // @@ -110,6 +110,7 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { static int kf_paste(int c, Fl_Text_Editor* e); static int kf_select_all(int c, Fl_Text_Editor* e); static int kf_undo(int c, Fl_Text_Editor* e); + static int kf_redo(int c, Fl_Text_Editor* e); protected: int handle_key(); |
