From aebe16893c91df685271d06a35470b44744bbff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Tue, 22 Sep 2015 18:02:43 +0200 Subject: [PATCH] Add emacs-like redo. --- nonlib/Loggable.C | 9 +++++++++ nonlib/Loggable.H | 1 + timeline/src/Project.C | 6 ++++++ timeline/src/Project.H | 1 + timeline/src/TLE.fl | 7 ++++++- timeline/src/Timeline.C | 9 +++++++++ timeline/src/Timeline.H | 1 + 7 files changed, 33 insertions(+), 1 deletion(-) diff --git a/nonlib/Loggable.C b/nonlib/Loggable.C index e89c7d7..717ad6d 100644 --- a/nonlib/Loggable.C +++ b/nonlib/Loggable.C @@ -541,6 +541,15 @@ Loggable::undo ( void ) } +void +Loggable::redo ( void ) +{ + if (! _fp) + return; + + _undo_offset = ftell( _fp ); +} + /** write a snapshot of the current state of all loggable objects to * file handle /fp/ */ bool diff --git a/nonlib/Loggable.H b/nonlib/Loggable.H index 2b1242c..cb3703c 100644 --- a/nonlib/Loggable.H +++ b/nonlib/Loggable.H @@ -177,6 +177,7 @@ public: static bool open ( const char *filename ); static bool close ( void ); static void undo ( void ); + static void redo ( void ); static void compact ( void ); diff --git a/timeline/src/Project.C b/timeline/src/Project.C index f92375f..3991674 100644 --- a/timeline/src/Project.C +++ b/timeline/src/Project.C @@ -134,6 +134,12 @@ Project::undo ( void ) Loggable::undo(); } +void +Project::redo ( void ) +{ + Loggable::redo(); +} + bool Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date, char **created_by ) { diff --git a/timeline/src/Project.H b/timeline/src/Project.H index a1a67a4..8e295fd 100644 --- a/timeline/src/Project.H +++ b/timeline/src/Project.H @@ -62,5 +62,6 @@ public: static bool open ( void ) { return _is_open; } static bool create ( const char *name, const char *template_name ); static void undo ( void ); + static void redo ( void ); static const char *created_on ( void ) { return _created_on; } }; diff --git a/timeline/src/TLE.fl b/timeline/src/TLE.fl index e54de7f..3d7db05 100644 --- a/timeline/src/TLE.fl +++ b/timeline/src/TLE.fl @@ -456,7 +456,12 @@ free(path);} MenuItem {} { label Undo callback {timeline->command_undo();} - xywh {5 5 40 25} shortcut 0x4007a divider + xywh {5 5 40 25} shortcut 0x4007a + } + MenuItem {} { + label Redo + callback {timeline->command_redo();} + xywh {5 5 40 25} shortcut 0x40079 divider } MenuItem {} { label {Select None} diff --git a/timeline/src/Timeline.C b/timeline/src/Timeline.C index ccde2a1..3524e58 100644 --- a/timeline/src/Timeline.C +++ b/timeline/src/Timeline.C @@ -2088,6 +2088,15 @@ Timeline::command_undo ( void ) track_lock.unlock(); } +void +Timeline::command_redo ( void ) +{ + /* FIXME: sequence lock too? */ + track_lock.wrlock(); + Project::redo(); + track_lock.unlock(); +} + bool Timeline::command_load ( const char *name, const char *display_name ) { diff --git a/timeline/src/Timeline.H b/timeline/src/Timeline.H index 022c3af..2ac1d94 100644 --- a/timeline/src/Timeline.H +++ b/timeline/src/Timeline.H @@ -246,6 +246,7 @@ public: void command_move_track_up ( Track *track ); void command_move_track_down ( Track *track ); void command_undo ( void ); + void command_redo ( void ); int find_track ( const Track * track ) const;