Mercurial > octave
changeset 28973:fdb7c296505a
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 21 Oct 2020 15:03:16 -0400 |
parents | 02b97abbc6fc (current diff) a00eca5d6cbe (diff) |
children | c2db7bd05c00 |
files | NEWS etc/NEWS.6 libinterp/corefcn/input.cc libinterp/corefcn/input.h |
diffstat | 4 files changed, 55 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/debug.txi Tue Oct 20 16:02:07 2020 -0400 +++ b/doc/interpreter/debug.txi Wed Oct 21 15:03:16 2020 -0400 @@ -178,7 +178,10 @@ When in debug mode the @key{RETURN} key will execute the last entered command. This is useful, for example, after hitting a breakpoint and entering @code{dbstep} once. After that, one can advance line by line through the code -with only a single key stroke. +with only a single key stroke. This feature may be disabled using the +@code{auto_repeat_debug_command} function. + +@DOCSTRING(auto_repeat_debug_command) @node Call Stack @section Call Stack
--- a/etc/NEWS.6 Tue Oct 20 16:02:07 2020 -0400 +++ b/etc/NEWS.6 Wed Oct 21 15:03:16 2020 -0400 @@ -206,6 +206,7 @@ ### Alphabetical list of new functions added in Octave 6 +* `auto_repeat_debug_command` * `commandhistory` * `commandwindow` * `filebrowser`
--- a/libinterp/corefcn/input.cc Tue Oct 20 16:02:07 2020 -0400 +++ b/libinterp/corefcn/input.cc Wed Oct 21 15:03:16 2020 -0400 @@ -410,10 +410,10 @@ input_system::input_system (interpreter& interp) : m_interpreter (interp), m_PS1 (R"(octave:\#> )"), m_PS2 ("> "), m_completion_append_char (' '), m_gud_mode (false), - m_mfile_encoding ("system"), m_last_debugging_command ("\n"), - m_input_event_hook_functions (), m_initialized (false) - { - } + m_mfile_encoding ("system"), m_auto_repeat_debug_command (true), + m_last_debugging_command ("\n"), m_input_event_hook_functions (), + m_initialized (false) + { } void input_system::initialize (bool line_editing) { @@ -625,6 +625,14 @@ m_dir_encoding[load_path_dir (dir)] = enc; return; + } + + octave_value + input_system::auto_repeat_debug_command (const octave_value_list& args, + int nargout) + { + return set_internal_variable (m_auto_repeat_debug_command, args, nargout, + "auto_repeat_debug_command"); } bool input_system::yes_or_no (const std::string& prompt) @@ -837,7 +845,7 @@ else input_sys.last_debugging_command ("\n"); } - else if (tw.in_debug_repl ()) + else if (tw.in_debug_repl () && input_sys.auto_repeat_debug_command ()) { retval = input_sys.last_debugging_command (); history_skip_auto_repeated_debugging_command = true; @@ -1574,3 +1582,22 @@ return ovl (retval); } + +DEFMETHOD (auto_repeat_debug_command, interp, args, nargout, + doc: /* -*- texinfo -*- +@deftypefn {} {@var{val} =} auto_repeat_debug_command () +@deftypefnx {} {@var{old_val} =} auto_repeat_debug_command (@var{new_val}) +@deftypefnx {} {} auto_repeat_debug_command (@var{new_val}, "local") +Query or set the internal variable that controls whether debugging +commands are automatically repeated when the input line is empty (typing +just @key{RET}). + +When called from inside a function with the @qcode{"local"} option, the +variable is changed locally for the function and any subroutines it calls. +The original variable value is restored when exiting the function. +@end deftypefn */) +{ + octave::input_system& input_sys = interp.get_input_system (); + + return input_sys.auto_repeat_debug_command (args, nargout); +}
--- a/libinterp/corefcn/input.h Tue Oct 20 16:02:07 2020 -0400 +++ b/libinterp/corefcn/input.h Wed Oct 21 15:03:16 2020 -0400 @@ -152,6 +152,21 @@ void set_dir_encoding (const std::string& dir, std::string& enc); + octave_value + auto_repeat_debug_command (const octave_value_list& args, int nargout); + + bool auto_repeat_debug_command (void) const + { + return m_auto_repeat_debug_command; + } + + bool auto_repeat_debug_command (bool val) + { + bool old_val = m_auto_repeat_debug_command; + m_auto_repeat_debug_command = val; + return old_val; + } + bool yes_or_no (const std::string& prompt); std::string interactive_input (const std::string& s, bool& eof); @@ -192,6 +207,9 @@ // map of directories -> used mfile encoding std::unordered_map<std::string, std::string> m_dir_encoding; + // TRUE means repeat last debug command if the user just types RET. + bool m_auto_repeat_debug_command; + // If we are in debugging mode, this is the last command entered, // so that we can repeat the previous command if the user just // types RET.