GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
cmd-hist.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cstring>
31 
32 #include <fstream>
33 #include <sstream>
34 #include <string>
35 
36 #include "cmd-edit.h"
37 #include "cmd-hist.h"
38 #include "file-ops.h"
39 #include "lo-error.h"
40 #include "lo-sysdep.h"
41 #include "singleton-cleanup.h"
42 #include "str-vec.h"
43 
44 #if defined (USE_READLINE)
45 #include <cstdlib>
46 
47 #include "oct-rl-hist.h"
48 
49 #include "file-ops.h"
50 #include "file-stat.h"
51 #endif
52 
54 
55 command_history *command_history::s_instance = nullptr;
56 
57 #if defined (USE_READLINE)
58 
59 class
60 gnu_history : public command_history
61 {
62 public:
63 
64  gnu_history ()
65  : command_history (), m_mark (0) { }
66 
67  OCTAVE_DISABLE_COPY_MOVE (gnu_history)
68 
69  ~gnu_history () = default;
70 
71  void do_process_histcontrol (const std::string&);
72 
73  std::string do_histcontrol () const;
74 
75  bool do_add (const std::string&);
76 
77  void do_remove (int);
78 
79  void do_clear ();
80 
81  int do_where () const;
82 
83  int do_length () const;
84 
85  int do_max_input_history () const;
86 
87  int do_base () const;
88 
89  int do_current_number () const;
90 
91  void do_stifle (int);
92 
93  int do_unstifle ();
94 
95  int do_is_stifled () const;
96 
97  void do_set_mark (int);
98 
99  int do_goto_mark ();
100 
101  void do_read (const std::string&, bool);
102 
103  void do_read_range (const std::string&, int, int, bool);
104 
105  void do_write (const std::string&) const;
106 
107  void do_append (const std::string&);
108 
109  void do_truncate_file (const std::string&, int) const;
110 
111  string_vector do_list (int, bool) const;
112 
113  std::string do_get_entry (int) const;
114 
115  void do_replace_entry (int, const std::string&);
116 
117  void do_clean_up_and_save (const std::string&, int);
118 
119 private:
120 
121  int m_mark;
122 };
123 
124 void
125 gnu_history::do_process_histcontrol (const std::string& control_arg)
126 {
127  m_history_control = 0;
128 
129  std::size_t len = control_arg.length ();
130  std::size_t beg = 0;
131 
132  while (beg < len)
133  {
134  if (control_arg[beg] == ':')
135  beg++;
136  else
137  {
138  std::size_t end = control_arg.find (':', beg);
139 
140  if (end == std::string::npos)
141  end = len;
142 
143  std::string tmp = control_arg.substr (beg, end-beg);
144 
145  if (tmp == "erasedups")
146  m_history_control |= HC_ERASEDUPS;
147  else if (tmp == "ignoreboth")
148  m_history_control |= (HC_IGNDUPS | HC_IGNSPACE);
149  else if (tmp == "ignoredups")
150  m_history_control |= HC_IGNDUPS;
151  else if (tmp == "ignorespace")
152  m_history_control |= HC_IGNSPACE;
153  else
155  ("Octave:history-control",
156  "unknown histcontrol directive %s", tmp.c_str ());
157 
158  if (end != std::string::npos)
159  beg = end + 1;
160  }
161  }
162 }
163 
164 std::string
165 gnu_history::do_histcontrol () const
166 {
167  // FIXME: instead of reconstructing this value, should we just save
168  // the string we were given when constructing the command_history object?
169 
170  std::string retval;
171 
172  if (m_history_control & HC_IGNSPACE)
173  retval.append ("ignorespace");
174 
175  if (m_history_control & HC_IGNDUPS)
176  {
177  if (retval.length () > 0)
178  retval += ':';
179 
180  retval.append ("ignoredups");
181  }
182 
183  if (m_history_control & HC_ERASEDUPS)
184  {
185  if (retval.length () > 0)
186  retval += ':';
187 
188  retval.append ("erasedups");
189  }
190 
191  return retval;
192 }
193 
194 bool
195 gnu_history::do_add (const std::string& s)
196 {
197  if (! do_ignoring_entries ())
198  {
199  if (s.empty ()
200  || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n')))
201  return false;
202 
203  // Strip newline before adding to list
204  std::string stmp = s;
205  if (stmp.back () == '\n')
206  stmp.pop_back ();
207 
208  int added = ::octave_add_history (stmp.c_str (), m_history_control);
209  m_lines_this_session += added;
210  return added > 0 ? true : false;
211  }
212  return false;
213 }
214 
215 void
216 gnu_history::do_remove (int n)
217 {
219 }
220 
221 void
222 gnu_history::do_clear ()
223 {
225 }
226 
227 int
228 gnu_history::do_where () const
229 {
231 }
232 
233 int
234 gnu_history::do_length () const
235 {
237 }
238 
239 int
240 gnu_history::do_max_input_history () const
241 {
243 }
244 
245 int
246 gnu_history::do_base () const
247 {
249 }
250 
251 int
252 gnu_history::do_current_number () const
253 {
254  return m_size > 0 ? do_base () + do_where () : -1;
255 }
256 
257 void
258 gnu_history::do_stifle (int n)
259 {
261 }
262 
263 int
264 gnu_history::do_unstifle ()
265 {
267 }
268 
269 int
270 gnu_history::do_is_stifled () const
271 {
273 }
274 
275 void
276 gnu_history::do_set_mark (int n)
277 {
278  m_mark = n;
279 }
280 
281 int
282 gnu_history::do_goto_mark ()
283 {
284  if (m_mark)
285  {
286  char *line = ::octave_history_goto_mark (m_mark);
287 
288  if (line)
289  {
291 
293  }
294  }
295 
296  m_mark = 0;
297 
298  // FIXME: for operate_and_get_next.
300 
301  return 0;
302 }
303 
304 void
305 gnu_history::do_read (const std::string& f, bool must_exist)
306 {
307  if (! f.empty ())
308  {
309  int status = ::octave_read_history (f.c_str ());
310 
311  if (status != 0 && must_exist)
312  {
313  std::string msg = "reading file '" + f + "'";
314 
315  error (status, msg);
316  }
317  else
318  {
319  m_lines_in_file = do_where ();
320 
322  }
323  }
324  else
325  error ("gnu_history::read: missing filename");
326 }
327 
328 void
329 gnu_history::do_read_range (const std::string& f, int from, int to,
330  bool must_exist)
331 {
332  if (from < 0)
333  from = m_lines_in_file;
334 
335  if (! f.empty ())
336  {
337  int status = ::octave_read_history_range (f.c_str (), from, to);
338 
339  if (status != 0 && must_exist)
340  {
341  std::ostringstream buf;
342  buf << "reading lines " << from << " to " << to
343  << " from file '" << f << "'";
344 
345  error (status, buf.str ());
346  }
347  else
348  {
349  m_lines_in_file = do_where ();
350 
352  }
353  }
354  else
355  error ("gnu_history::read_range: missing filename");
356 }
357 
358 void
359 gnu_history::do_write (const std::string& f_arg) const
360 {
361  if (m_initialized)
362  {
363  std::string f = f_arg;
364 
365  if (f.empty ())
366  f = m_file;
367 
368  if (! f.empty ())
369  {
370  // Try to create the folder if it does not exist
371  std::string hist_dir = sys::file_ops::dirname (f);
372  if (! hist_dir.empty ())
373  {
374  if (! sys::dir_exists (hist_dir)
375  && (sys::recursive_mkdir (hist_dir, 0777) < 0))
376  (*current_liboctave_error_handler)
377  ("%s: Could not create directory \"%s\" for history",
378  "gnu_history::do_write", hist_dir.c_str ());
379  }
380 
381  int status = ::octave_write_history (f.c_str ());
382 
383  if (status != 0)
384  {
385  std::string msg = "writing file '" + f + "'";
386 
387  error (status, msg);
388  }
389  }
390  else
391  error ("gnu_history::write: missing filename");
392  }
393 }
394 
395 void
396 gnu_history::do_append (const std::string& f_arg)
397 {
398  if (m_initialized)
399  {
400  if (m_lines_this_session)
401  {
402  if (m_lines_this_session < do_where ())
403  {
404  // Create file if it doesn't already exist.
405 
406  std::string f = f_arg;
407 
408  if (f.empty ())
409  f = m_file;
410 
411  if (! f.empty ())
412  {
413  if (! sys::file_exists (f))
414  {
415  std::ofstream tmp = sys::ofstream (f, std::ios::out);
416  tmp.close ();
417  }
418 
419  int status
420  = ::octave_append_history (m_lines_this_session, f.c_str ());
421 
422  if (status != 0)
423  {
424  std::string msg = "appending to file '" + f_arg + "'";
425 
426  error (status, msg);
427  }
428  else
429  m_lines_in_file += m_lines_this_session;
430 
431  m_lines_this_session = 0;
432  }
433  else
434  error ("gnu_history::append: missing filename");
435  }
436  }
437  }
438 }
439 
440 void
441 gnu_history::do_truncate_file (const std::string& f_arg, int n) const
442 {
443  if (m_initialized)
444  {
445  std::string f = f_arg;
446 
447  if (f.empty ())
448  f = m_file;
449 
450  if (! f.empty ())
451  ::octave_history_truncate_file (f.c_str (), n);
452  else
453  error ("gnu_history::truncate_file: missing filename");
454  }
455 }
456 
458 gnu_history::do_list (int limit, bool number_lines) const
459 {
460  string_vector retval;
461 
462  if (limit)
463  retval = ::octave_history_list (limit, number_lines);
464 
465  return retval;
466 }
467 
468 std::string
469 gnu_history::do_get_entry (int n) const
470 {
471  std::string retval;
472 
473  char *line = ::octave_history_get (do_base () + n);
474 
475  if (line)
476  retval = line;
477 
478  return retval;
479 }
480 
481 void
482 gnu_history::do_replace_entry (int which, const std::string& line)
483 {
484  ::octave_replace_history_entry (which, line.c_str ());
485 }
486 
487 void
488 gnu_history::do_clean_up_and_save (const std::string& f_arg, int n)
489 {
490  if (m_initialized)
491  {
492  std::string f = f_arg;
493 
494  if (f.empty ())
495  f = m_file;
496 
497  if (! f.empty ())
498  {
499  if (n < 0)
500  n = m_size;
501 
502  stifle (n);
503 
504  do_write (f.c_str ());
505  }
506  else
507  error ("gnu_history::clean_up_and_save: missing filename");
508  }
509 }
510 
511 #endif
512 
513 bool
514 command_history::instance_ok ()
515 {
516  bool retval = true;
517 
518  if (! s_instance)
519  {
520  make_command_history ();
521 
522  if (s_instance)
523  singleton_cleanup_list::add (cleanup_instance);
524  }
525 
526  if (! s_instance)
527  (*current_liboctave_error_handler)
528  ("unable to create command history object!");
529 
530  return retval;
531 }
532 
533 void
534 command_history::make_command_history ()
535 {
536 #if defined (USE_READLINE)
537  s_instance = new gnu_history ();
538 #else
539  s_instance = new command_history ();
540 #endif
541 }
542 
543 void
544 command_history::initialize (bool read_history_file,
545  const std::string& f_arg, int sz,
546  const std::string& control_arg)
547 {
548  if (instance_ok ())
549  s_instance->do_initialize (read_history_file, f_arg, sz, control_arg);
550 }
551 
552 bool
554 {
555  // We just want to check the status of an existing instance, not
556  // create one.
557  return s_instance && s_instance->do_is_initialized ();
558 }
559 
560 void
561 command_history::set_file (const std::string& f_arg)
562 {
563  if (instance_ok ())
564  {
565  std::string f = sys::file_ops::tilde_expand (f_arg);
566 
567  s_instance->do_set_file (f);
568  }
569 }
570 
571 std::string
573 {
574  return instance_ok () ? s_instance->do_file () : "";
575 }
576 
577 void
578 command_history::process_histcontrol (const std::string& control_arg)
579 {
580  if (instance_ok ())
581  s_instance->do_process_histcontrol (control_arg);
582 }
583 
584 std::string
586 {
587  return instance_ok () ? s_instance->do_histcontrol () : "";
588 }
589 
590 void
592 {
593  if (instance_ok ())
594  s_instance->do_set_size (n);
595 }
596 
597 int
599 {
600  return instance_ok () ? s_instance->do_size () : 0;
601 }
602 
603 void
605 {
606  if (instance_ok ())
607  s_instance->do_ignore_entries (flag);
608 }
609 
610 bool
612 {
613  return instance_ok () ? s_instance->do_ignoring_entries () : false;
614 }
615 
616 bool
617 command_history::add (const std::string& s)
618 {
619  if (instance_ok ())
620  return s_instance->do_add (s);
621  return false;
622 }
623 
624 void
626 {
627  if (instance_ok ())
628  s_instance->do_remove (n);
629 }
630 
631 void
633 {
634  if (instance_ok ())
635  s_instance->do_clear ();
636 }
637 
638 int
640 {
641  return instance_ok () ? s_instance->do_where () : 0;
642 }
643 
644 int
646 {
647  return instance_ok () ? s_instance->do_length () : 0;
648 }
649 
650 int
652 {
653  return instance_ok () ? s_instance->do_max_input_history () : 0;
654 }
655 
656 int
658 {
659  return instance_ok () ? s_instance->do_base () : 0;
660 }
661 
662 int
664 {
665  return instance_ok () ? s_instance->do_current_number () : 0;
666 }
667 
668 void
670 {
671  if (instance_ok ())
672  s_instance->do_stifle (n);
673 }
674 
675 int
677 {
678  return instance_ok () ? s_instance->do_unstifle () : 0;
679 }
680 
681 int
683 {
684  return instance_ok () ? s_instance->do_is_stifled () : 0;
685 }
686 
687 void
689 {
690  if (instance_ok ())
691  s_instance->do_set_mark (n);
692 }
693 
694 int
696 {
697  return instance_ok () ? s_instance->do_goto_mark () : 0;
698 }
699 
700 void
701 command_history::read (bool must_exist)
702 {
703  read (file (), must_exist);
704 }
705 
706 void
707 command_history::read (const std::string& f, bool must_exist)
708 {
709  if (instance_ok ())
710  s_instance->do_read (f, must_exist);
711 }
712 
713 void
714 command_history::read_range (int from, int to, bool must_exist)
715 {
716  read_range (file (), from, to, must_exist);
717 }
718 
719 void
720 command_history::read_range (const std::string& f, int from, int to,
721  bool must_exist)
722 {
723  if (instance_ok ())
724  s_instance->do_read_range (f, from, to, must_exist);
725 }
726 
727 void
728 command_history::write (const std::string& f)
729 {
730  if (instance_ok ())
731  s_instance->do_write (f);
732 }
733 
734 void
735 command_history::append (const std::string& f)
736 {
737  if (instance_ok ())
738  s_instance->do_append (f);
739 }
740 
741 void
742 command_history::truncate_file (const std::string& f, int n)
743 {
744  if (instance_ok ())
745  s_instance->do_truncate_file (f, n);
746 }
747 
749 command_history::list (int limit, bool number_lines)
750 {
751  return (instance_ok ()
752  ? s_instance->do_list (limit, number_lines) : string_vector ());
753 }
754 
755 std::string
757 {
758  return instance_ok () ? s_instance->do_get_entry (n) : "";
759 }
760 
761 void
762 command_history::replace_entry (int which, const std::string& line)
763 {
764  if (instance_ok ())
765  s_instance->do_replace_entry (which, line);
766 }
767 
768 void
769 command_history::clean_up_and_save (const std::string& f, int n)
770 {
771  if (instance_ok ())
772  s_instance->do_clean_up_and_save (f, n);
773 }
774 
775 void
777 { }
778 
779 void
780 command_history::do_initialize (bool read_history_file,
781  const std::string& f_arg, int sz,
782  const std::string& control_arg)
783 {
787 
788  if (read_history_file)
789  command_history::read (false);
790 
791  m_initialized = true;
792 }
793 
794 bool
796 {
797  return m_initialized;
798 }
799 
800 void
801 command_history::do_set_file (const std::string& f)
802 {
803  m_file = f;
804 }
805 
806 std::string
808 {
809  return m_file;
810 }
811 
812 void
814 {
815  m_size = n;
816 }
817 
818 int
820 {
821  return m_size;
822 }
823 
824 void
826 {
827  m_ignoring_additions = flag;
828 }
829 
830 bool
832 {
833  return m_ignoring_additions;
834 }
835 
836 bool
837 command_history::do_add (const std::string&)
838 {
839  return false;
840 }
841 
842 void
844 { }
845 
846 void
848 { }
849 
850 int
852 {
853  return 0;
854 }
855 
856 int
858 {
859  return 0;
860 }
861 
862 int
864 {
865  return 0;
866 }
867 
868 int
870 {
871  return 0;
872 }
873 
874 int
876 {
877  return m_size > 0 ? do_base () + do_where () : -1;
878 }
879 
880 void
882 { }
883 
884 int
886 {
887  return -1;
888 }
889 
890 int
892 {
893  return 0;
894 }
895 
896 void
898 { }
899 
900 int
902 {
903  return 0;
904 }
905 
906 void
907 command_history::do_read (const std::string& f, bool)
908 {
909  if (f.empty ())
910  error ("command_history::read: missing filename");
911 }
912 
913 void
914 command_history::do_read_range (const std::string& f, int, int, bool)
915 {
916  if (f.empty ())
917  error ("command_history::read_range: missing filename");
918 }
919 
920 void
921 command_history::do_write (const std::string& f_arg) const
922 {
923  if (m_initialized)
924  {
925  std::string f = f_arg;
926 
927  if (f.empty ())
928  f = m_file;
929 
930  if (f.empty ())
931  error ("command_history::write: missing filename");
932  }
933 }
934 
935 void
936 command_history::do_append (const std::string& f_arg)
937 {
938  if (m_initialized)
939  {
941  {
943  {
944  // Create file if it doesn't already exist.
945 
946  std::string f = f_arg;
947 
948  if (f.empty ())
949  f = m_file;
950 
951  if (f.empty ())
952  error ("command_history::append: missing filename");
953  }
954  }
955  }
956 }
957 
958 void
959 command_history::do_truncate_file (const std::string& f_arg, int) const
960 {
961  if (m_initialized)
962  {
963  std::string f = f_arg;
964 
965  if (f.empty ())
966  f = m_file;
967 
968  if (f.empty ())
969  error ("command_history::truncate_file: missing filename");
970  }
971 }
972 
974 command_history::do_list (int, bool) const
975 {
976  return string_vector ();
977 }
978 
979 std::string
981 {
982  return "";
983 }
984 
985 void
986 command_history::do_replace_entry (int, const std::string&)
987 { }
988 
989 void
990 command_history::do_clean_up_and_save (const std::string& f_arg, int)
991 {
992  if (m_initialized)
993  {
994  std::string f = f_arg;
995 
996  if (f.empty ())
997  f = m_file;
998 
999  if (f.empty ())
1000  error ("command_history::clean_up_and_save: missing filename");
1001  }
1002 }
1003 
1004 void
1005 command_history::error (int err_num, const std::string& msg) const
1006 {
1007  if (msg.empty ())
1008  (*current_liboctave_error_handler) ("%s", std::strerror (err_num));
1009  else
1010  (*current_liboctave_error_handler) ("%s: %s", msg.c_str (),
1011  std::strerror (err_num));
1012 }
1013 
1014 void
1015 command_history::error (const std::string& s) const
1016 {
1017  (*current_liboctave_error_handler) ("%s", s.c_str ());
1018 }
1019 
1020 OCTAVE_END_NAMESPACE(octave)
static void remove_startup_hook(startup_hook_fcn f)
Definition: cmd-edit.cc:1517
static void clear_undo_list()
Definition: cmd-edit.cc:1499
static void insert_text(const std::string &text)
Definition: cmd-edit.cc:1472
static void truncate_file(const std::string &="", int=-1)
Definition: cmd-hist.cc:742
virtual std::string do_get_entry(int) const
Definition: cmd-hist.cc:980
bool m_ignoring_additions
Definition: cmd-hist.h:222
virtual int do_goto_mark()
Definition: cmd-hist.cc:901
static bool ignoring_entries()
Definition: cmd-hist.cc:611
static int current_number()
Definition: cmd-hist.cc:663
static void read(bool=true)
Definition: cmd-hist.cc:701
static bool is_initialized()
Definition: cmd-hist.cc:553
virtual void do_stifle(int)
Definition: cmd-hist.cc:881
virtual void do_replace_entry(int, const std::string &)
Definition: cmd-hist.cc:986
virtual int do_is_stifled() const
Definition: cmd-hist.cc:891
static void clear()
Definition: cmd-hist.cc:632
static int size()
Definition: cmd-hist.cc:598
virtual void do_read(const std::string &, bool)
Definition: cmd-hist.cc:907
virtual bool do_add(const std::string &)
Definition: cmd-hist.cc:837
static int unstifle()
Definition: cmd-hist.cc:676
static void initialize(bool, const std::string &, int, const std::string &)
Definition: cmd-hist.cc:544
static void append(const std::string &="")
Definition: cmd-hist.cc:735
static std::string file()
Definition: cmd-hist.cc:572
virtual string_vector do_list(int, bool) const
Definition: cmd-hist.cc:974
virtual bool do_ignoring_entries() const
Definition: cmd-hist.cc:831
static void stifle(int)
Definition: cmd-hist.cc:669
static void set_file(const std::string &)
Definition: cmd-hist.cc:561
virtual int do_size() const
Definition: cmd-hist.cc:819
static std::string histcontrol()
Definition: cmd-hist.cc:585
static int length()
Definition: cmd-hist.cc:645
virtual bool do_is_initialized() const
Definition: cmd-hist.cc:795
static bool add(const std::string &)
Definition: cmd-hist.cc:617
static void set_size(int)
Definition: cmd-hist.cc:591
static void remove(int)
Definition: cmd-hist.cc:625
virtual void do_set_size(int)
Definition: cmd-hist.cc:813
virtual int do_base() const
Definition: cmd-hist.cc:869
static int base()
Definition: cmd-hist.cc:657
virtual void do_set_mark(int)
Definition: cmd-hist.cc:897
virtual int do_length() const
Definition: cmd-hist.cc:857
static void clean_up_and_save(const std::string &="", int=-1)
Definition: cmd-hist.cc:769
void error(int, const std::string &msg="") const
Definition: cmd-hist.cc:1005
int m_lines_this_session
Definition: cmd-hist.h:231
bool m_initialized
Definition: cmd-hist.h:219
virtual std::string do_histcontrol() const
Definition: cmd-hist.h:154
virtual int do_where() const
Definition: cmd-hist.cc:851
virtual void do_clean_up_and_save(const std::string &, int)
Definition: cmd-hist.cc:990
virtual void do_read_range(const std::string &, int, int, bool)
Definition: cmd-hist.cc:914
virtual void do_truncate_file(const std::string &, int) const
Definition: cmd-hist.cc:959
static void ignore_entries(bool=true)
Definition: cmd-hist.cc:604
virtual void do_clear()
Definition: cmd-hist.cc:847
virtual void do_remove(int)
Definition: cmd-hist.cc:843
virtual int do_current_number() const
Definition: cmd-hist.cc:875
static int where()
Definition: cmd-hist.cc:639
static void process_histcontrol(const std::string &)
Definition: cmd-hist.cc:578
virtual std::string do_file()
Definition: cmd-hist.cc:807
virtual void do_write(const std::string &) const
Definition: cmd-hist.cc:921
static void replace_entry(int, const std::string &)
Definition: cmd-hist.cc:762
std::string m_file
Definition: cmd-hist.h:234
static void read_range(int=-1, int=-1, bool=true)
Definition: cmd-hist.cc:714
virtual int do_unstifle()
Definition: cmd-hist.cc:885
virtual void do_initialize(bool, const std::string &, int, const std::string &)
Definition: cmd-hist.cc:780
static void set_mark(int n)
Definition: cmd-hist.cc:688
virtual void do_process_histcontrol(const std::string &)
Definition: cmd-hist.cc:776
static string_vector list(int=-1, bool=false)
Definition: cmd-hist.cc:749
static int goto_mark()
Definition: cmd-hist.cc:695
static int is_stifled()
Definition: cmd-hist.cc:682
static std::string get_entry(int)
Definition: cmd-hist.cc:756
static int max_input_history()
Definition: cmd-hist.cc:651
static void write(const std::string &="")
Definition: cmd-hist.cc:728
virtual void do_ignore_entries(bool)
Definition: cmd-hist.cc:825
virtual void do_set_file(const std::string &)
Definition: cmd-hist.cc:801
virtual int do_max_input_history() const
Definition: cmd-hist.cc:863
virtual void do_append(const std::string &)
Definition: cmd-hist.cc:936
static void add(fptr f)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
Definition: error.cc:988
std::string dirname(const std::string &path)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:41
liboctave_warning_with_id_handler current_liboctave_warning_with_id_handler
Definition: lo-error.c:53
F77_RET_T const F77_DBLE const F77_DBLE * f
bool dir_exists(const std::string &dirname)
Definition: lo-sysdep.cc:389
bool file_exists(const std::string &filename, bool is_dir)
Definition: lo-sysdep.cc:341
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:635
octave_idx_type n
Definition: mx-inlines.cc:761
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:289
int recursive_mkdir(const std::string &name, mode_t mode)
Definition: file-ops.cc:433
void octave_stifle_history(int)
int octave_unstifle_history(void)
int octave_where_history(void)
void octave_clear_history(void)
char * octave_history_goto_mark(int n)
int octave_read_history_range(const char *, int, int)
int octave_write_history(const char *)
int octave_append_history(int, const char *)
int octave_read_history(const char *)
char ** octave_history_list(int, int)
int octave_max_input_history(void)
@ HC_IGNDUPS
Definition: oct-rl-hist.h:39
@ HC_ERASEDUPS
Definition: oct-rl-hist.h:40
@ HC_IGNSPACE
Definition: oct-rl-hist.h:38
int octave_history_length(void)
void octave_replace_history_entry(int, const char *)
char * octave_history_get(int n)
int octave_history_base(void)
int octave_add_history(const char *, int)
int octave_history_truncate_file(const char *, int)
void octave_using_history(void)
int octave_history_is_stifled(void)
void octave_remove_history(int)
F77_RET_T len
Definition: xerbla.cc:61