# HG changeset patch # User Torsten # Date 1376333227 -7200 # Node ID 33ce8c381f2c97fe452068fef14f3855af70dce8 # Parent 251807f3cdc1a321bd5e9d5ef5fdacb5f93291d0 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 diff -r 251807f3cdc1 -r 33ce8c381f2c libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Mon Aug 12 14:47:21 2013 +0200 +++ b/libinterp/corefcn/input.cc Mon Aug 12 20:47:07 2013 +0200 @@ -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); } diff -r 251807f3cdc1 -r 33ce8c381f2c libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Mon Aug 12 14:47:21 2013 +0200 +++ b/libinterp/corefcn/oct-hist.cc Mon Aug 12 20:47:07 2013 +0200 @@ -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, , diff -r 251807f3cdc1 -r 33ce8c381f2c liboctave/util/cmd-hist.cc --- a/liboctave/util/cmd-hist.cc Mon Aug 12 14:47:21 2013 +0200 +++ b/liboctave/util/cmd-hist.cc Mon Aug 12 20:47:07 2013 +0200 @@ -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 diff -r 251807f3cdc1 -r 33ce8c381f2c liboctave/util/cmd-hist.h --- a/liboctave/util/cmd-hist.h Mon Aug 12 14:47:21 2013 +0200 +++ b/liboctave/util/cmd-hist.h Mon Aug 12 20:47:07 2013 +0200 @@ -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);