23 #if defined (HAVE_CONFIG_H)
41 #if defined (USE_READLINE)
53 #if defined (USE_READLINE)
56 gnu_history :
public command_history
61 : command_history (), mark (0) { }
63 ~gnu_history (
void) { }
75 int do_where (
void)
const;
77 int do_length (
void)
const;
79 int do_max_input_history (
void)
const;
81 int do_base (
void)
const;
83 int do_current_number (
void)
const;
87 int do_unstifle (
void);
89 int do_is_stifled (
void)
const;
91 void do_set_mark (
int);
93 int do_goto_mark (
void);
97 void do_read_range (
const std::string&,
int,
int,
bool);
103 void do_truncate_file (
const std::string&,
int)
const;
111 void do_clean_up_and_save (
const std::string&,
int);
119 gnu_history::do_process_histcontrol (
const std::string& control_arg)
123 size_t len = control_arg.length ();
128 if (control_arg[beg] ==
':')
132 size_t end = control_arg.find (
":", beg);
134 if (end == std::string::npos)
139 if (tmp ==
"erasedups")
141 else if (tmp ==
"ignoreboth")
143 else if (tmp ==
"ignoredups")
145 else if (tmp ==
"ignorespace")
149 (
"Octave:history-control",
150 "unknown histcontrol directive %s", tmp.c_str ());
152 if (end != std::string::npos)
159 gnu_history::do_histcontrol (
void)
const
167 retval.append (
"ignorespace");
171 if (retval.length () > 0)
174 retval.append (
"ignoredups");
179 if (retval.length () > 0)
182 retval.append (
"erasedups");
191 if (! do_ignoring_entries ())
194 || (s.length () == 1 && (s[0] ==
'\r' || s[0] ==
'\n')))
199 int stmp_len = stmp.length ();
200 if (stmp[stmp_len - 1] ==
'\n')
201 stmp.resize (stmp_len - 1);
204 lines_this_session += added;
205 return (added > 0) ?
true :
false;
211 gnu_history::do_remove (
int n)
217 gnu_history::do_clear (
void)
223 gnu_history::do_where (
void)
const
229 gnu_history::do_length (
void)
const
235 gnu_history::do_max_input_history (
void)
const
241 gnu_history::do_base (
void)
const
247 gnu_history::do_current_number (
void)
const
249 return (xsize > 0) ? do_base () + do_where () : -1;
253 gnu_history::do_stifle (
int n)
259 gnu_history::do_unstifle (
void)
265 gnu_history::do_is_stifled (
void)
const
271 gnu_history::do_set_mark (
int n)
277 gnu_history::do_goto_mark (
void)
300 gnu_history::do_read (
const std::string&
f,
bool must_exist)
306 if (status != 0 && must_exist)
314 lines_in_file = do_where ();
320 error (
"gnu_history::read: missing filename");
324 gnu_history::do_read_range (
const std::string& f,
int from,
int to,
328 from = lines_in_file;
334 if (status != 0 && must_exist)
336 std::ostringstream buf;
337 buf <<
"reading lines " << from <<
" to " << to
338 <<
" from file '" << f <<
"'";
340 error (status, buf.str ());
344 lines_in_file = do_where ();
350 error (
"gnu_history::read_range: missing filename");
354 gnu_history::do_write (
const std::string& f_arg)
const
375 error (
"gnu_history::write: missing filename");
384 if (lines_this_session)
386 if (lines_this_session < do_where ())
401 std::fstream
tmp (f, std::ios::out);
410 std::string msg =
"appending to file '" + f_arg +
"'";
415 lines_in_file += lines_this_session;
417 lines_this_session = 0;
420 error (
"gnu_history::append: missing filename");
427 gnu_history::do_truncate_file (
const std::string& f_arg,
int n)
const
439 error (
"gnu_history::truncate_file: missing filename");
444 gnu_history::do_list (
int limit,
bool number_lines)
const
455 gnu_history::do_get_entry (
int n)
const
468 gnu_history::do_replace_entry (
int which,
const std::string& line)
474 gnu_history::do_clean_up_and_save (
const std::string& f_arg,
int n)
490 do_write (f.c_str ());
493 error (
"gnu_history::clean_up_and_save: missing filename");
513 (*current_liboctave_error_handler)
514 (
"unable to create command history object!");
522 #if defined (USE_READLINE)
787 if (read_history_file)
909 error (
"command_history::read: missing filename");
916 error (
"command_history::read_range: missing filename");
930 error (
"command_history::write: missing filename");
951 error (
"command_history::append: missing filename");
968 error (
"command_history::truncate_file: missing filename");
999 error (
"command_history::clean_up_and_save: missing filename");
1010 std::strerror (err_num));
1016 (*current_liboctave_error_handler) (
"%s", s.c_str ());
static void write(const std::string &="")
static std::string histcontrol(void)
static void cleanup_instance(void)
virtual void do_clear(void)
void octave_replace_history_entry(int, const char *)
Octave interface to the compression and uncompression libraries.
static void read(bool=true)
virtual int do_unstifle(void)
static int current_number(void)
static int is_stifled(void)
virtual void do_append(const std::string &)
virtual bool do_is_initialized(void) const
void octave_stifle_history(int)
static int goto_mark(void)
virtual int do_goto_mark(void)
char * octave_history_get(int n)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
int octave_history_is_stifled(void)
virtual int do_is_stifled(void) const
virtual int do_base(void) const
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
virtual void do_read_range(const std::string &, int, int, bool)
static void set_size(int)
int octave_add_history(const char *, int)
void error(const char *fmt,...)
int octave_history_truncate_file(const char *, int)
static std::string get_entry(int)
int octave_max_input_history(void)
static void ignore_entries(bool=true)
int octave_append_history(int, const char *)
static bool add(const std::string &)
void error(int, const std::string &msg="") const
void octave_remove_history(int)
static command_history * instance
static bool is_initialized(void)
static void clean_up_and_save(const std::string &="", int=-1)
static int max_input_history(void)
static std::string tilde_expand(const std::string &)
liboctave_warning_with_id_handler current_liboctave_warning_with_id_handler
static void make_command_history(void)
char * octave_history_goto_mark(int n)
virtual int do_where(void) const
virtual void do_replace_entry(int, const std::string &)
virtual int do_max_input_history(void) const
int octave_history_length(void)
static void truncate_file(const std::string &="", int=-1)
static void insert_text(const std::string &text)
virtual std::string do_histcontrol(void) const
static string_vector list(int=-1, bool=false)
virtual std::string do_file(void)
int octave_history_base(void)
static int unstifle(void)
static void remove_startup_hook(startup_hook_fcn f)
static void clear_undo_list(void)
virtual void do_set_mark(int)
virtual int do_size(void) const
virtual void do_remove(int)
virtual bool do_add(const std::string &)
virtual void do_process_histcontrol(const std::string &)
static void read_range(int=-1, int=-1, bool=true)
virtual int do_length(void) const
virtual void do_stifle(int)
int octave_read_history(const char *)
int octave_where_history(void)
static void initialize(bool, const std::string &, int, const std::string &)
may be zero for pure relative error test tem the relative tolerance must be greater than or equal to
static void set_mark(int n)
char ** octave_history_list(int, int)
void octave_using_history(void)
virtual void do_ignore_entries(bool)
virtual bool do_ignoring_entries(void) const
int octave_read_history_range(const char *, int, int)
static void set_file(const std::string &)
virtual void do_set_file(const std::string &)
virtual std::string do_get_entry(int) const
virtual void do_write(const std::string &) const
static bool ignoring_entries(void)
octave::sys::file_stat fs(filename)
static bool instance_ok(void)
virtual void do_truncate_file(const std::string &, int) const
virtual int do_current_number(void) const
int octave_write_history(const char *)
virtual void do_clean_up_and_save(const std::string &, int)
virtual string_vector do_list(int, bool) const
void octave_clear_history(void)
static void append(const std::string &="")
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
virtual void do_read(const std::string &, bool)
virtual void do_set_size(int)
static std::string file(void)
virtual void do_initialize(bool, const std::string &, int, const std::string &)
int octave_unstifle_history(void)
static void replace_entry(int, const std::string &)
static void process_histcontrol(const std::string &)