Mercurial > hg > octave-nkf
diff liboctave/util/cmd-edit.cc @ 16539:8ea8df0747e9
make undo button and menu item work for command window
* main-window.h, main-window.cc (main_window::handle_undo_request,
main_window::command_window_undo_callback): New functions.
(main_window::construct_edit_menu): Connect _undo_action::triggered to
main_window::handle_undo_request.
* cmd-edit.h, cmd-edit.cc (command_window::redisplay,
command_window::do_redisplay, command_window::undo,
command_window::do_undo, gnu_readline::do_redisplay,
gnu_readline::do_undo): New functions.
* oct-rl-edit.h, oct-rl-edit.c (octave_rl_do_undo): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 18 Apr 2013 03:19:48 -0400 |
parents | 106a38d7b396 |
children | d5ae5aa80d42 |
line wrap: on
line diff
--- a/liboctave/util/cmd-edit.cc +++ b/liboctave/util/cmd-edit.cc @@ -86,6 +86,8 @@ FILE *do_get_output_stream (void); + void do_redisplay (void); + int do_terminal_rows (void); int do_terminal_cols (void); @@ -143,6 +145,8 @@ void do_accept_line (void); + bool do_undo (void); + void do_clear_undo_list (void); void set_startup_hook (startup_hook_fcn f); @@ -292,6 +296,12 @@ return ::octave_rl_get_output_stream (); } +void +gnu_readline::do_redisplay (void) +{ + ::octave_rl_redisplay (); +} + // GNU readline handles SIGWINCH, so these values have a good chance // of being correct even if the window changes size (they may be // wrong if, for example, the luser changes the window size while the @@ -530,6 +540,12 @@ command_accept_line (1, '\n'); } +bool +gnu_readline::do_undo (void) +{ + return ::octave_rl_do_undo (); +} + void gnu_readline::do_clear_undo_list () { @@ -961,6 +977,13 @@ ? instance->do_get_output_stream () : 0; } +void +command_editor::redisplay (void) +{ + if (instance_ok ()) + instance->do_redisplay (); +} + int command_editor::terminal_rows (void) { @@ -1177,6 +1200,12 @@ instance->do_accept_line (); } +bool +command_editor::undo (void) +{ + return instance_ok () ? instance->do_undo () : false; +} + void command_editor::clear_undo_list (void) {