Mercurial > hg > octave-nkf
diff src/oct-hist.cc @ 3016:f512c16826d1
[project @ 1997-06-03 03:16:13 by jwe]
author | jwe |
---|---|
date | Tue, 03 Jun 1997 03:21:08 +0000 |
parents | aa9d0c0e0458 |
children | 5708b8bb4f06 |
line wrap: on
line diff
--- a/src/oct-hist.cc +++ b/src/oct-hist.cc @@ -52,12 +52,14 @@ #include "cmd-hist.h" #include "file-ops.h" +#include "lo-mappers.h" #include "oct-env.h" #include "str-vec.h" #include <defaults.h> #include "defun.h" #include "error.h" +#include "gripes.h" #include "input.h" #include "oct-hist.h" #include "oct-obj.h" @@ -72,6 +74,15 @@ // Nonzero means input is coming from temporary history file. int input_from_tmp_history_file = 0; +// Where history is saved. +static string Vhistory_file; + +// The number of lines to keep in the history file. +static int Vhistory_size; + +// TRUE if we are saving history. +int Vsaving_history; + // Get some default values, possibly reading them from the // environment. @@ -574,6 +585,71 @@ return retval; } +static int +history_size (void) +{ + double val; + if (builtin_real_scalar_variable ("history_size", val) + && ! xisnan (val)) + { + int ival = NINT (val); + if (ival >= 0 && ival == val) + { + Vhistory_size = ival; + command_history::set_size (ival); + return 0; + } + } + gripe_invalid_value_specified ("history_size"); + return -1; +} + +static int +history_file (void) +{ + int status = 0; + + string s = builtin_string_variable ("history_file"); + + if (s.empty ()) + { + gripe_invalid_value_specified ("history_file"); + status = -1; + } + else + { + Vhistory_file = s; + command_history::set_file (file_ops::tilde_expand (s)); + } + + return status; +} + +static int +saving_history (void) +{ + Vsaving_history = check_preference ("saving_history"); + + command_history::ignore_entries (! Vsaving_history); + + return 0; +} + +void +symbols_of_oct_hist (void) +{ + DEFVAR (history_file, default_history_file (), 0, history_file, + "name of command history file"); + + double tmp_hist_size = default_history_size (); + + DEFVAR (history_size, tmp_hist_size, 0, history_size, + "number of commands to save in the history list"); + + DEFVAR (saving_history, 1.0, 0, saving_history, + "save command history"); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***