Mercurial > hg > octave-nkf
diff liboctave/util/cmd-hist.cc @ 17219: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 | 7c06875c2dcc |
children | d63878346099 |
line wrap: on
line diff
--- 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