Mercurial > octave-nkf
changeset 19736:c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
* oct-rl-edit.h, oct-rl-edit.c (octave_rl_kill_full_line): New function.
* cmd-edit.h, cmd-edit.cc (command_editor::kill_full_line,
command_editor::do_kill_full_line, gnu_readline::do_kill_full_line,
default_command_editor::do_kill_full_line): New functions.
* main-window.cc (main_window::clear_command_window_callback):
Kill pending input line before clearing screen.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 12 Feb 2015 14:32:01 -0500 |
parents | f4af02a9a6fc |
children | a81177f4bfe6 |
files | libgui/src/main-window.cc liboctave/util/cmd-edit.cc liboctave/util/cmd-edit.h liboctave/util/oct-rl-edit.c liboctave/util/oct-rl-edit.h |
diffstat | 5 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Thu Feb 12 14:12:43 2015 -0500 +++ b/libgui/src/main-window.cc Thu Feb 12 14:32:01 2015 -0500 @@ -2011,6 +2011,7 @@ void main_window::clear_command_window_callback (void) { + command_editor::kill_full_line (); command_editor::clear_screen (); }
--- a/liboctave/util/cmd-edit.cc Thu Feb 12 14:12:43 2015 -0500 +++ b/liboctave/util/cmd-edit.cc Thu Feb 12 14:32:01 2015 -0500 @@ -151,6 +151,8 @@ void do_replace_line (const std::string& text, bool clear_undo); + void do_kill_full_line (void); + void do_insert_text (const std::string& text); void do_newline (void); @@ -572,6 +574,12 @@ } void +gnu_readline::do_kill_full_line (void) +{ + ::octave_rl_kill_full_line (); +} + +void gnu_readline::do_insert_text (const std::string& text) { ::octave_rl_insert_text (text.c_str ()); @@ -841,6 +849,8 @@ void do_replace_line (const std::string& text, bool clear_undo); + void do_kill_full_line (void); + void do_insert_text (const std::string& text); void do_newline (void); @@ -920,6 +930,12 @@ } void +default_command_editor::do_kill_full_line (void) +{ + // FIXME +} + +void default_command_editor::do_insert_text (const std::string&) { // FIXME @@ -1330,6 +1346,13 @@ } void +command_editor::kill_full_line (void) +{ + if (instance_ok ()) + instance->do_kill_full_line (); +} + +void command_editor::insert_text (const std::string& text) { if (instance_ok ())
--- a/liboctave/util/cmd-edit.h Thu Feb 12 14:12:43 2015 -0500 +++ b/liboctave/util/cmd-edit.h Thu Feb 12 14:32:01 2015 -0500 @@ -133,6 +133,8 @@ static void replace_line (const std::string& text, bool clear_undo = true); + static void kill_full_line (void); + static void insert_text (const std::string& text); static void newline (void); @@ -309,6 +311,8 @@ virtual void do_replace_line (const std::string& text, bool clear_undo) = 0; + virtual void do_kill_full_line (void) = 0; + virtual void do_insert_text (const std::string& text) = 0; virtual void do_newline (void) = 0;
--- a/liboctave/util/oct-rl-edit.c Thu Feb 12 14:12:43 2015 -0500 +++ b/liboctave/util/oct-rl-edit.c Thu Feb 12 14:32:01 2015 -0500 @@ -150,6 +150,12 @@ } void +octave_rl_kill_full_line (void) +{ + rl_kill_full_line (0, 0); +} + +void octave_rl_insert_text (const char *s) { rl_insert_text (s);
--- a/liboctave/util/oct-rl-edit.h Thu Feb 12 14:12:43 2015 -0500 +++ b/liboctave/util/oct-rl-edit.h Thu Feb 12 14:32:01 2015 -0500 @@ -74,6 +74,8 @@ extern void octave_rl_replace_line (const char *s, int clear_undo); +extern void octave_rl_kill_full_line (void); + extern void octave_rl_insert_text (const char *); extern int octave_rl_newline (int, int);