ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=c5dce45a953cf7a4559600389cd029737b53c98a
commit c5dce45a953cf7a4559600389cd029737b53c98a Author: Andy Williams <[email protected]> Date: Fri Apr 7 18:14:31 2017 +0100 elm_code: Expose whether or not undo and redo can operate A quick peek at the stack will allow us to inform users of the widget if operations will apply. --- src/lib/elementary/elm_code_widget.eo | 8 ++++++++ src/lib/elementary/elm_code_widget_undo.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/lib/elementary/elm_code_widget.eo b/src/lib/elementary/elm_code_widget.eo index ab129ca..e3138a9 100644 --- a/src/lib/elementary/elm_code_widget.eo +++ b/src/lib/elementary/elm_code_widget.eo @@ -278,9 +278,17 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text) undo { [[Undo last action]] } + can_undo_get { + [[Determine if there are any available undo operations]] + return: bool; [[$true if there are undo operations]] + } redo { [[Redo last action]] } + can_redo_get { + [[Determine if there are any available redo operations]] + return: bool; [[$true if there are redo operations]] + } } implements { class.constructor; diff --git a/src/lib/elementary/elm_code_widget_undo.c b/src/lib/elementary/elm_code_widget_undo.c index 5da08d1..7e4acc8 100644 --- a/src/lib/elementary/elm_code_widget_undo.c +++ b/src/lib/elementary/elm_code_widget_undo.c @@ -109,6 +109,12 @@ _elm_code_widget_undo_change(Evas_Object *widget, } } +static Eina_Bool +_elm_code_widget_can_undo_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) +{ + return !!pd->undo_stack_ptr; +} + static void _elm_code_widget_undo(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { @@ -123,6 +129,15 @@ _elm_code_widget_undo(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) pd->undo_stack_ptr = eina_list_next(pd->undo_stack_ptr); } +static Eina_Bool +_elm_code_widget_can_redo_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) +{ + if (pd->undo_stack_ptr) + return !!eina_list_prev(pd->undo_stack_ptr); + + return !!eina_list_last(pd->undo_stack); +} + static void _elm_code_widget_redo(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { --
