Mercurial > hg > octave-shane
changeset 16382:389b09a914e2
allow gui to force readline to return from its idle/read loop
* cmd-edit.h, cmd-edit.cc (command_editor::interrupt,
command_editor::do_interrupt): New functions.
(gnu_readline::do_interrupt): New function.
* oct-rl-edit.h, oct-rl-edit.c (octave_rl_done): New function.
* main-window.cc (main_window::debug_step_into_callback,
main_window::debug_step_over_callback,
main_window::debug_step_out_callback):
Call command_editor::interrupt.
* input.cc (get_debug_input): Reset command_editor::interrutp state.
If previous state is true, then exit early.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 27 Mar 2013 20:29:06 -0400 |
parents | f33dcbd6a005 |
children | 3cacd597464d |
files | libgui/src/main-window.cc libinterp/interpfcn/input.cc liboctave/util/cmd-edit.cc liboctave/util/cmd-edit.h liboctave/util/oct-rl-edit.c liboctave/util/oct-rl-edit.h |
diffstat | 6 files changed, 68 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -50,6 +50,7 @@ #include "toplev.h" #include "version.h" +#include "cmd-edit.h" #include "cmd-hist.h" #include "oct-env.h" @@ -1215,22 +1216,35 @@ Fdbcont (); } +// The next three callbacks are invoked by GUI buttons. Those buttons +// should only be active when we are doing debugging, which means that +// Octave is waiting for input in get_debug_input. Calling +// command_editor::interrupt will force readline to return even if it +// has not read any input, and then get_debug_input will return, +// allowing the evaluator to continue and execute the next statement. + void main_window::debug_step_into_callback (void) { Fdbstep (ovl ("in")); + + command_editor::interrupt (true); } void main_window::debug_step_over_callback (void) { Fdbstep (); + + command_editor::interrupt (true); } void main_window::debug_step_out_callback (void) { Fdbstep (ovl ("out")); + + command_editor::interrupt (true); } void
--- a/libinterp/interpfcn/input.cc +++ b/libinterp/interpfcn/input.cc @@ -554,15 +554,20 @@ int retval = curr_parser.run (); - if (retval == 0 && curr_parser.stmt_list) + if (command_editor::interrupt (false)) + break; + else { - curr_parser.stmt_list->accept (*current_evaluator); + if (retval == 0 && curr_parser.stmt_list) + { + curr_parser.stmt_list->accept (*current_evaluator); - if (octave_completion_matches_called) - octave_completion_matches_called = false; + if (octave_completion_matches_called) + octave_completion_matches_called = false; + } + + octave_quit (); } - - octave_quit (); } }
--- a/liboctave/util/cmd-edit.cc +++ b/liboctave/util/cmd-edit.cc @@ -163,6 +163,8 @@ bool do_filename_quoting_desired (bool); + void do_interrupt (bool); + static int operate_and_get_next (int, int); static int history_search_backward (int, int); @@ -587,6 +589,12 @@ return ::octave_rl_filename_quoting_desired (arg); } +void +gnu_readline::do_interrupt (bool arg) +{ + ::octave_rl_done (arg); +} + int gnu_readline::operate_and_get_next (int /* count */, int /* c */) { @@ -1270,6 +1278,26 @@ ? instance->do_filename_quoting_desired (arg) : false; } +bool +command_editor::interrupt (bool arg) +{ + bool retval; + + if (instance_ok ()) + { + // Return the current interrupt state. + retval = instance->interrupted; + + instance->do_interrupt (arg); + + instance->interrupted = arg; + } + else + retval = false; + + return retval; +} + // Return a string which will be printed as a prompt. The string may // contain special characters which are decoded as follows: //
--- a/liboctave/util/cmd-edit.h +++ b/liboctave/util/cmd-edit.h @@ -37,7 +37,7 @@ protected: command_editor (void) - : command_number (0) { } + : command_number (0), interrupted (false) { } public: @@ -147,6 +147,8 @@ static bool filename_quoting_desired (bool); + static bool interrupt (bool); + static int current_command_number (void); static void reset_current_command_number (int n); @@ -287,6 +289,8 @@ virtual bool do_filename_quoting_desired (bool) { return false; } + virtual void do_interrupt (bool) { } + int read_octal (const std::string& s); void error (int); @@ -295,6 +299,8 @@ // The current command number. int command_number; + + bool interrupted; }; #endif
--- a/liboctave/util/oct-rl-edit.c +++ b/liboctave/util/oct-rl-edit.c @@ -218,6 +218,12 @@ return retval; } +void +octave_rl_done (int arg) +{ + rl_done = arg; +} + char * octave_rl_filename_completion_function (const char *text, int state) {
--- a/liboctave/util/oct-rl-edit.h +++ b/liboctave/util/oct-rl-edit.h @@ -90,6 +90,8 @@ extern int octave_rl_filename_quoting_desired (int); +extern void octave_rl_done (int); + extern char *octave_rl_filename_completion_function (const char *, int); extern void octave_rl_set_basic_word_break_characters (const char *);