Mercurial > hg > octave-lyh
changeset 17227:33ce8c381f2c
make history widget respect history_control settings (bug #39728)
* input.cc(octave_gets): append entry to the history widget only if really
something has been added to the history
* oct-hist.cc(edit_history_add_hist,octave_history_write_timestamp):
append entry to the history widget only if really something has benn added
to the history
* cmd-hist.cc(class gnu_history): do_add with boolean return value,
(do_add): return true if something has been added to the history via
::octave_add_history, false otherwise,
(command_history::add): now returns the return value of do_add,
(command_history::do_add): return false
* cmd-hist.h: add and do_add now with boolean return value
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 12 Aug 2013 20:47:07 +0200 |
parents | 251807f3cdc1 |
children | ea9992fd9c89 |
files | libinterp/corefcn/input.cc libinterp/corefcn/oct-hist.cc liboctave/util/cmd-hist.cc liboctave/util/cmd-hist.h |
diffstat | 4 files changed, 17 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/input.cc +++ b/libinterp/corefcn/input.cc @@ -272,9 +272,7 @@ { if (! history_skip_auto_repeated_debugging_command) { - command_history::add (retval); - - if (! command_history::ignoring_entries ()) + if (command_history::add (retval)) octave_link::append_history (retval); }
--- a/libinterp/corefcn/oct-hist.cc +++ b/libinterp/corefcn/oct-hist.cc @@ -328,10 +328,8 @@ tmp.resize (len - 1); if (! tmp.empty ()) - { - command_history::add (tmp); + if (command_history::add (tmp)) octave_link::append_history (tmp); - } } } @@ -580,10 +578,8 @@ std::string timestamp = now.strftime (Vhistory_timestamp_format_string); if (! timestamp.empty ()) - { - command_history::add (timestamp); + if (command_history::add (timestamp)) octave_link::append_history (timestamp); - } } DEFUN (edit_history, args, ,
--- a/liboctave/util/cmd-hist.cc +++ b/liboctave/util/cmd-hist.cc @@ -65,7 +65,7 @@ std::string do_histcontrol (void) const; - void do_add (const std::string&); + bool do_add (const std::string&); void do_remove (int); @@ -184,14 +184,14 @@ return retval; } -void +bool gnu_history::do_add (const std::string& s) { if (! do_ignoring_entries ()) { if (s.empty () || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n'))) - return; + return false; // Strip newline before adding to list std::string stmp = s; @@ -199,8 +199,11 @@ if (stmp[stmp_len - 1] == '\n') stmp.resize (stmp_len - 1); - lines_this_session += ::octave_add_history (stmp.c_str (), history_control); + int added = ::octave_add_history (stmp.c_str (), history_control); + lines_this_session += added; + return (added > 0) ? true : false; } + return false; } void @@ -587,11 +590,12 @@ ? instance->do_ignoring_entries () : false; } -void +bool command_history::add (const std::string& s) { if (instance_ok ()) - instance->do_add (s); + return instance->do_add (s); + return false; } void @@ -818,9 +822,10 @@ return ignoring_additions; } -void +bool command_history::do_add (const std::string&) { + return false; } void
--- a/liboctave/util/cmd-hist.h +++ b/liboctave/util/cmd-hist.h @@ -61,7 +61,7 @@ static bool ignoring_entries (void); - static void add (const std::string&); + static bool add (const std::string&); static void remove (int); @@ -156,7 +156,7 @@ virtual bool do_ignoring_entries (void) const; - virtual void do_add (const std::string&); + virtual bool do_add (const std::string&); virtual void do_remove (int);