GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-hist.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 /*
24 
25 The functions listed below were adapted from similar functions from
26 GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
27 Software Foundation, Inc.
28 
29  do_history edit_history_readline
30  do_edit_history edit_history_add_hist
31 
32 */
33 
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37 
38 #include <cstdlib>
39 #include <cstring>
40 
41 #include <string>
42 
43 #include <fstream>
44 
45 #include <sys/types.h>
46 #include <unistd.h>
47 
48 #include "cmd-hist.h"
49 #include "file-ops.h"
50 #include "lo-mappers.h"
51 #include "octave-link.h"
52 #include "oct-env.h"
53 #include "oct-time.h"
54 #include "str-vec.h"
55 
56 #include <defaults.h>
57 #include "defun.h"
58 #include "error.h"
59 #include "gripes.h"
60 #include "input.h"
61 #include "oct-hist.h"
62 #include "oct-obj.h"
63 #include "pager.h"
64 #include "parse.h"
65 #include "sighandlers.h"
66 #include "sysdep.h"
67 #include "toplev.h"
68 #include "unwind-prot.h"
69 #include "utils.h"
70 #include "variables.h"
71 
72 // TRUE means input is coming from temporary history file.
74 
75 static std::string
77 {
78  std::string file;
79 
80  std::string env_file = octave_env::getenv ("OCTAVE_HISTFILE");
81 
82  if (! env_file.empty ())
83  file = env_file;
84 
85  if (file.empty ())
87  ".octave_hist");
88 
89  return file;
90 }
91 
92 static int
94 {
95  int size = 1000;
96 
97  std::string env_size = octave_env::getenv ("OCTAVE_HISTSIZE");
98 
99  if (! env_size.empty ())
100  {
101  int val;
102 
103  if (sscanf (env_size.c_str (), "%d", &val) == 1)
104  size = val > 0 ? val : 0;
105  }
106 
107  return size;
108 }
109 
110 static std::string
112 {
113  return
114  std::string ("# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <")
116  + std::string ("@")
118  + std::string (">");
119 }
120 
121 // The format of the timestamp marker written to the history file when
122 // Octave exits.
123 static std::string Vhistory_timestamp_format_string
125 
126 // Display, save, or load history. Stolen and modified from bash.
127 //
128 // Arg of -w FILENAME means write file, arg of -r FILENAME
129 // means read file, arg of -q means don't number lines. Arg of N
130 // means only display that many items.
131 
132 static string_vector
133 do_history (const octave_value_list& args, int nargout)
134 {
135  bool numbered_output = nargout == 0;
136 
137  unwind_protect frame;
138 
139  string_vector hlist;
140 
142 
143  int nargin = args.length ();
144 
145  // Number of history lines to show (-1 = all)
146  int limit = -1;
147 
148  for (octave_idx_type i = 0; i < nargin; i++)
149  {
150  octave_value arg = args(i);
151 
152  std::string option;
153 
154  if (arg.is_string ())
155  option = arg.string_value ();
156  else if (arg.is_numeric_type ())
157  {
158  limit = arg.int_value ();
159  if (limit < 0)
160  limit = -limit;
161  continue;
162  }
163  else
164  {
165  gripe_wrong_type_arg ("history", arg);
166  return hlist;
167  }
168 
169  if (option == "-r" || option == "-w" || option == "-a"
170  || option == "-n")
171  {
172  if (i < nargin - 1)
173  {
174  if (args(i+1).is_string ())
175  command_history::set_file (args(++i).string_value ());
176  else
177  {
178  error ("history: expecting file name for %s option",
179  option.c_str ());
180  return hlist;
181  }
182  }
183  else
185 
186  if (option == "-a")
187  // Append 'new' lines to file.
189 
190  else if (option == "-w")
191  // Write entire history.
193 
194  else if (option == "-r")
195  {
196  // Read entire file.
199  }
200 
201  else if (option == "-n")
202  {
203  // Read 'new' history from file.
206  }
207 
208  else
209  panic_impossible ();
210 
211  return hlist;
212  }
213  else if (option == "-c")
214  {
217  }
218  else if (option == "-q")
219  numbered_output = false;
220  else if (option == "--")
221  {
222  i++;
223  break;
224  }
225  else
226  {
227  // The last argument found in the command list that looks like
228  // an integer will be used
229  int tmp;
230 
231  if (sscanf (option.c_str (), "%d", &tmp) == 1)
232  {
233  if (tmp > 0)
234  limit = tmp;
235  else
236  limit = -tmp;
237  }
238 
239  else
240  {
241  if (option.length () > 0 && option[0] == '-')
242  error ("history: unrecognized option '%s'", option.c_str ());
243  else
244  error ("history: bad non-numeric arg '%s'", option.c_str ());
245 
246  return hlist;
247  }
248  }
249  }
250 
251  hlist = command_history::list (limit, numbered_output);
252 
253  int len = hlist.length ();
254 
255  if (nargout == 0)
256  {
257  for (octave_idx_type i = 0; i < len; i++)
258  octave_stdout << hlist[i] << "\n";
259  }
260 
261  return hlist;
262 }
263 
264 // Read the edited history lines from STREAM and return them
265 // one at a time. This can read unlimited length lines. The
266 // caller should free the storage.
267 
268 static char *
269 edit_history_readline (std::fstream& stream)
270 {
271  char c;
272  int line_len = 128;
273  int lindex = 0;
274  char *line = new char [line_len];
275  line[0] = '\0';
276 
277  while (stream.get (c))
278  {
279  if (lindex + 2 >= line_len)
280  {
281  char *tmp_line = new char [line_len += 128];
282  strcpy (tmp_line, line);
283  delete [] line;
284  line = tmp_line;
285  }
286 
287  if (c == '\n')
288  {
289  line[lindex++] = '\n';
290  line[lindex++] = '\0';
291  return line;
292  }
293  else
294  line[lindex++] = c;
295  }
296 
297  if (! lindex)
298  {
299  delete [] line;
300  return 0;
301  }
302 
303  if (lindex + 2 >= line_len)
304  {
305  char *tmp_line = new char [lindex+3];
306  strcpy (tmp_line, line);
307  delete [] line;
308  line = tmp_line;
309  }
310 
311  // Finish with newline if none in file.
312 
313  line[lindex++] = '\n';
314  line[lindex++] = '\0';
315  return line;
316 }
317 
318 static void
319 edit_history_add_hist (const std::string& line)
320 {
321  if (! line.empty ())
322  {
323  std::string tmp = line;
324 
325  int len = tmp.length ();
326 
327  if (len > 0 && tmp[len-1] == '\n')
328  tmp.resize (len - 1);
329 
330  if (! tmp.empty ())
331  if (command_history::add (tmp))
333  }
334 }
335 
336 static bool
337 get_int_arg (const octave_value& arg, int& val)
338 {
339  bool ok = true;
340 
341  if (arg.is_string ())
342  {
343  std::string tmp = arg.string_value ();
344 
345  ok = sscanf (tmp.c_str (), "%d", &val) == 1;
346  }
347  else if (arg.is_numeric_type ())
348  val = arg.int_value ();
349  else
350  ok = false;
351 
352  return ok;
353 }
354 
355 static std::string
357  bool insert_curr, const char *warn_for)
358 {
359  std::string retval;
360 
362 
363  int hist_count = hlist.length () - 1; // switch to zero-based indexing
364 
365  // The current command line is already part of the history list by
366  // the time we get to this point. Delete the cmd from the list when
367  // executing 'edit_history' so that it doesn't show up in the history
368  // but the actual commands performed will.
369 
370  if (! insert_curr)
371  command_history::remove (hist_count);
372 
373  hist_count--; // skip last entry in history list
374 
375  // If no numbers have been specified, the default is to edit the
376  // last command in the history list.
377 
378  int hist_beg = hist_count;
379  int hist_end = hist_count;
380 
381  bool reverse = false;
382 
383  // Process options.
384 
385  int nargin = args.length ();
386 
387  bool usage_error = false;
388  if (nargin == 2)
389  {
390  if (get_int_arg (args(0), hist_beg)
391  && get_int_arg (args(1), hist_end))
392  {
393  if (hist_beg < 0)
394  hist_beg += (hist_count + 1);
395  else
396  hist_beg--;
397  if (hist_end < 0)
398  hist_end += (hist_count + 1);
399  else
400  hist_end--;
401  }
402  else
403  usage_error = true;
404  }
405  else if (nargin == 1)
406  {
407  if (get_int_arg (args(0), hist_beg))
408  {
409  if (hist_beg < 0)
410  hist_beg += (hist_count + 1);
411  else
412  hist_beg--;
413  hist_end = hist_beg;
414  }
415  else
416  usage_error = true;
417  }
418 
419  if (usage_error)
420  {
421  usage ("%s [first] [last]", warn_for);
422  return retval;
423  }
424 
425  if (hist_beg > hist_count || hist_end > hist_count)
426  {
427  error ("%s: history specification out of range", warn_for);
428  return retval;
429  }
430 
431  if (hist_end < hist_beg)
432  {
433  std::swap (hist_end, hist_beg);
434  reverse = true;
435  }
436 
437  std::string name = octave_tempnam ("", "oct-");
438 
439  std::fstream file (name.c_str (), std::ios::out);
440 
441  if (! file)
442  {
443  error ("%s: couldn't open temporary file '%s'", warn_for,
444  name.c_str ());
445  return retval;
446  }
447 
448  if (reverse)
449  {
450  for (int i = hist_end; i >= hist_beg; i--)
451  file << hlist[i] << "\n";
452  }
453  else
454  {
455  for (int i = hist_beg; i <= hist_end; i++)
456  file << hlist[i] << "\n";
457  }
458 
459  file.close ();
460 
461  return name;
462 }
463 
464 static void
465 unlink_cleanup (const char *file)
466 {
467  gnulib::unlink (file);
468 }
469 
470 static void
472 {
473  std::string name = mk_tmp_hist_file (args, false, "edit_history");
474 
475  if (name.empty ())
476  return;
477 
478  // Call up our favorite editor on the file of commands.
479 
480  std::string cmd = VEDITOR;
481  cmd.append (" \"" + name + "\"");
482 
483  // Ignore interrupts while we are off editing commands. Should we
484  // maybe avoid using system()?
485 
486  volatile octave_interrupt_handler old_interrupt_handler
488 
489  int status = system (cmd.c_str ());
490 
491  octave_set_interrupt_handler (old_interrupt_handler);
492 
493  // Check if text edition was successfull. Abort the operation
494  // in case of failure.
495  if (status != EXIT_SUCCESS)
496  {
497  error ("edit_history: text editor command failed");
498  return;
499  }
500 
501  // Write the commands to the history file since source_file
502  // disables command line history while it executes.
503 
504  std::fstream file (name.c_str (), std::ios::in);
505 
506  char *line;
507  //int first = 1;
508  while ((line = edit_history_readline (file)) != 0)
509  {
510  // Skip blank lines.
511 
512  if (line[0] == '\n')
513  {
514  delete [] line;
515  continue;
516  }
517 
518  edit_history_add_hist (line);
519 
520  delete [] line;
521  }
522 
523  file.close ();
524 
525  // Turn on command echo, so the output from this will make better
526  // sense.
527 
528  unwind_protect frame;
529 
530  frame.add_fcn (unlink_cleanup, name.c_str ());
533 
536 
537  source_file (name);
538 }
539 
540 static void
542 {
543  std::string name = mk_tmp_hist_file (args, false, "run_history");
544 
545  if (name.empty ())
546  return;
547 
548  // Turn on command echo so the output from this will make better sense.
549 
550  unwind_protect frame;
551 
552  frame.add_fcn (unlink_cleanup, name.c_str ());
555 
558 
559  source_file (name);
560 }
561 
562 void
564 {
565  command_history::initialize (read_history_file,
568  octave_env::getenv ("OCTAVE_HISTCONTROL"));
569 
571 }
572 
573 void
575 {
576  octave_localtime now;
577 
578  std::string timestamp = now.strftime (Vhistory_timestamp_format_string);
579 
580  if (! timestamp.empty ())
581  if (command_history::add (timestamp))
582  octave_link::append_history (timestamp);
583 }
584 
585 DEFUN (edit_history, args, ,
586  "-*- texinfo -*-\n\
587 @deftypefn {Command} {} edit_history\n\
588 @deftypefnx {Command} {} edit_history @var{cmd_number}\n\
589 @deftypefnx {Command} {} edit_history @var{first} @var{last}\n\
590 Edit the history list using the editor named by the variable @env{EDITOR}.\n\
591 \n\
592 The commands to be edited are first copied to a temporary file. When you\n\
593 exit the editor, Octave executes the commands that remain in the file. It\n\
594 is often more convenient to use @code{edit_history} to define functions\n\
595 rather than attempting to enter them directly on the command line.\n\
596 The block of commands is executed as soon as you exit the editor.\n\
597 To avoid executing any commands, simply delete all the lines from the buffer\n\
598 before leaving the editor.\n\
599 \n\
600 When invoked with no arguments, edit the previously executed command;\n\
601 With one argument, edit the specified command @var{cmd_number};\n\
602 With two arguments, edit the list of commands between @var{first} and\n\
603 @var{last}. Command number specifiers may also be negative where -1\n\
604 refers to the most recently executed command.\n\
605 The following are equivalent and edit the most recently executed command.\n\
606 \n\
607 @example\n\
608 @group\n\
609 edit_history\n\
610 edit_history -1\n\
611 @end group\n\
612 @end example\n\
613 \n\
614 When using ranges, specifying a larger number for the first command than the\n\
615 last command reverses the list of commands before they are placed in the\n\
616 buffer to be edited.\n\
617 @seealso{run_history, history}\n\
618 @end deftypefn")
619 {
620  octave_value_list retval;
621 
622  do_edit_history (args);
623 
624  return retval;
625 }
626 
627 DEFUN (history, args, nargout,
628  "-*- texinfo -*-\n\
629 @deftypefn {Command} {} history\n\
630 @deftypefnx {Command} {} history @var{opt1} @dots{}\n\
631 @deftypefnx {Built-in Function} {@var{h} =} history ()\n\
632 @deftypefnx {Built-in Function} {@var{h} =} history (@var{opt1}, @dots{})\n\
633 If invoked with no arguments, @code{history} displays a list of commands\n\
634 that you have executed.\n\
635 \n\
636 Valid options are:\n\
637 \n\
638 @table @code\n\
639 @item @var{n}\n\
640 @itemx -@var{n}\n\
641 Display only the most recent @var{n} lines of history.\n\
642 \n\
643 @item -c\n\
644 Clear the history list.\n\
645 \n\
646 @item -q\n\
647 Don't number the displayed lines of history. This is useful for cutting\n\
648 and pasting commands using the X Window System.\n\
649 \n\
650 @item -r @var{file}\n\
651 Read the file @var{file}, appending its contents to the current\n\
652 history list. If the name is omitted, use the default history file\n\
653 (normally @file{~/.octave_hist}).\n\
654 \n\
655 @item -w @var{file}\n\
656 Write the current history to the file @var{file}. If the name is\n\
657 omitted, use the default history file (normally @file{~/.octave_hist}).\n\
658 @end table\n\
659 \n\
660 For example, to display the five most recent commands that you have\n\
661 typed without displaying line numbers, use the command\n\
662 @kbd{history -q 5}.\n\
663 \n\
664 If invoked with a single output argument, the history will be saved to that\n\
665 argument as a cell string and will not be output to screen.\n\
666 @seealso{edit_history, run_history}\n\
667 @end deftypefn")
668 {
669  octave_value retval;
670 
671  string_vector hlist = do_history (args, nargout);
672 
673  if (nargout > 0)
674  retval = Cell (hlist);
675 
676  return retval;
677 }
678 
679 DEFUN (run_history, args, ,
680  "-*- texinfo -*-\n\
681 @deftypefn {Command} {} run_history\n\
682 @deftypefnx {Command} {} run_history @var{cmd_number}\n\
683 @deftypefnx {Command} {} run_history @var{first} @var{last}\n\
684 Run commands from the history list.\n\
685 \n\
686 When invoked with no arguments, run the previously executed command;\n\
687 \n\
688 With one argument, run the specified command @var{cmd_number};\n\
689 \n\
690 With two arguments, run the list of commands between @var{first} and\n\
691 @var{last}. Command number specifiers may also be negative where -1\n\
692 refers to the most recently executed command. For example, the command\n\
693 \n\
694 @example\n\
695 @group\n\
696 run_history\n\
697  OR\n\
698 run_history -1\n\
699 @end group\n\
700 @end example\n\
701 \n\
702 @noindent\n\
703 executes the most recent command again.\n\
704 The command\n\
705 \n\
706 @example\n\
707 run_history 13 169\n\
708 @end example\n\
709 \n\
710 @noindent\n\
711 executes commands 13 through 169.\n\
712 \n\
713 Specifying a larger number for the first command than the last command\n\
714 reverses the list of commands before executing them.\n\
715 For example:\n\
716 \n\
717 @example\n\
718 @group\n\
719 disp (1)\n\
720 disp (2)\n\
721 run_history -1 -2\n\
722 @result{}\n\
723  2\n\
724  1\n\
725 @end group\n\
726 @end example\n\
727 \n\
728 @seealso{edit_history, history}\n\
729 @end deftypefn")
730 {
731  octave_value_list retval;
732 
733  do_run_history (args);
734 
735  return retval;
736 }
737 
738 DEFUN (history_control, args, nargout,
739  "-*- texinfo -*-\n\
740 @deftypefn {Built-in Function} {@var{val} =} history_control ()\n\
741 @deftypefnx {Built-in Function} {@var{old_val} =} history_control (@var{new_val})\n\
742 Query or set the internal variable that specifies how commands are saved\n\
743 to the history list.\n\
744 \n\
745 The default value is an empty character string, but may be overridden by the\n\
746 environment variable @w{@env{OCTAVE_HISTCONTROL}}.\n\
747 \n\
748 The value of @code{history_control} is a colon-separated list of values\n\
749 controlling how commands are saved on the history list. If the list\n\
750 of values includes @code{ignorespace}, lines which begin with a space\n\
751 character are not saved in the history list. A value of @code{ignoredups}\n\
752 causes lines matching the previous history entry to not be saved.\n\
753 A value of @code{ignoreboth} is shorthand for @code{ignorespace} and\n\
754 @code{ignoredups}. A value of @code{erasedups} causes all previous lines\n\
755 matching the current line to be removed from the history list before that\n\
756 line is saved. Any value not in the above list is ignored. If\n\
757 @code{history_control} is the empty string, all commands are saved on\n\
758 the history list, subject to the value of @code{history_save}.\n\
759 @seealso{history_file, history_size, history_timestamp_format_string, history_save}\n\
760 @end deftypefn")
761 {
762  octave_value retval;
763 
764  std::string old_history_control = command_history::histcontrol ();
765 
766  std::string tmp = old_history_control;
767 
768  retval = set_internal_variable (tmp, args, nargout, "history_control");
769 
770  if (tmp != old_history_control)
772 
773  return retval;
774 }
775 
776 DEFUN (history_size, args, nargout,
777  "-*- texinfo -*-\n\
778 @deftypefn {Built-in Function} {@var{val} =} history_size ()\n\
779 @deftypefnx {Built-in Function} {@var{old_val} =} history_size (@var{new_val})\n\
780 Query or set the internal variable that specifies how many entries\n\
781 to store in the history file.\n\
782 \n\
783 The default value is @code{1000}, but may be overridden by the environment\n\
784 variable @w{@env{OCTAVE_HISTSIZE}}.\n\
785 @seealso{history_file, history_timestamp_format_string, history_save}\n\
786 @end deftypefn")
787 {
788  octave_value retval;
789 
790  int old_history_size = command_history::size ();
791 
792  int tmp = old_history_size;
793 
794  retval = set_internal_variable (tmp, args, nargout,
795  "history_size", -1,
797 
798  if (tmp != old_history_size)
800 
801  return retval;
802 }
803 
804 DEFUN (history_file, args, nargout,
805  "-*- texinfo -*-\n\
806 @deftypefn {Built-in Function} {@var{val} =} history_file ()\n\
807 @deftypefnx {Built-in Function} {@var{old_val} =} history_file (@var{new_val})\n\
808 Query or set the internal variable that specifies the name of the\n\
809 file used to store command history.\n\
810 \n\
811 The default value is @file{~/.octave_hist}, but may be overridden by the\n\
812 environment variable @w{@env{OCTAVE_HISTFILE}}.\n\
813 @seealso{history_size, history_save, history_timestamp_format_string}\n\
814 @end deftypefn")
815 {
816  octave_value retval;
817 
818  std::string old_history_file = command_history::file ();
819 
820  std::string tmp = old_history_file;
821 
822  retval = set_internal_variable (tmp, args, nargout, "history_file");
823 
824  if (tmp != old_history_file)
826 
827  return retval;
828 }
829 
830 DEFUN (history_timestamp_format_string, args, nargout,
831  "-*- texinfo -*-\n\
832 @deftypefn {Built-in Function} {@var{val} =} history_timestamp_format_string ()\n\
833 @deftypefnx {Built-in Function} {@var{old_val} =} history_timestamp_format_string (@var{new_val})\n\
834 @deftypefnx {Built-in Function} {} history_timestamp_format_string (@var{new_val}, \"local\")\n\
835 Query or set the internal variable that specifies the format string\n\
836 for the comment line that is written to the history file when Octave\n\
837 exits.\n\
838 \n\
839 The format string is passed to @code{strftime}. The default value is\n\
840 \n\
841 @example\n\
842 \"# Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>\"\n\
843 @end example\n\
844 \n\
845 When called from inside a function with the @qcode{\"local\"} option, the\n\
846 variable is changed locally for the function and any subroutines it calls.\n\
847 The original variable value is restored when exiting the function.\n\
848 @seealso{strftime, history_file, history_size, history_save}\n\
849 @end deftypefn")
850 {
851  return SET_INTERNAL_VARIABLE (history_timestamp_format_string);
852 }
853 
854 DEFUN (history_save, args, nargout,
855  "-*- texinfo -*-\n\
856 @deftypefn {Built-in Function} {@var{val} =} history_save ()\n\
857 @deftypefnx {Built-in Function} {@var{old_val} =} history_save (@var{new_val})\n\
858 @deftypefnx {Built-in Function} {} history_save (@var{new_val}, \"local\")\n\
859 Query or set the internal variable that controls whether commands entered\n\
860 on the command line are saved in the history file.\n\
861 \n\
862 When called from inside a function with the @qcode{\"local\"} option, the\n\
863 variable is changed locally for the function and any subroutines it calls.\n\
864 The original variable value is restored when exiting the function.\n\
865 @seealso{history_control, history_file, history_size, history_timestamp_format_string}\n\
866 @end deftypefn")
867 {
868  octave_value retval;
869 
870  bool old_history_save = ! command_history::ignoring_entries ();
871 
872  bool tmp = old_history_save;
873 
874  retval = set_internal_variable (tmp, args, nargout, "history_save");
875 
876  if (tmp != old_history_save)
878 
879  return retval;
880 }
static bool ignoring_entries(void)
Definition: cmd-hist.cc:606
Definition: Cell.h:35
octave_interrupt_handler octave_set_interrupt_handler(const volatile octave_interrupt_handler &h, bool restart_syscalls)
Definition: sighandlers.cc:603
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
Definition: gripes.cc:135
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file, const std::string &warn_for)
Definition: oct-parse.cc:8405
std::string strftime(const std::string &fmt) const
Definition: oct-time.cc:144
octave_idx_type length(void) const
Definition: oct-obj.h:89
bool is_numeric_type(void) const
Definition: ov.h:663
static std::string Vhistory_timestamp_format_string
Definition: oct-hist.cc:124
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:730
static string_vector do_history(const octave_value_list &args, int nargout)
Definition: oct-hist.cc:133
static void unlink_cleanup(const char *file)
Definition: oct-hist.cc:465
static std::string file(void)
Definition: cmd-hist.cc:564
void protect_var(T &var)
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
void error(const char *fmt,...)
Definition: error.cc:476
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:120
static std::string default_history_timestamp_format(void)
Definition: oct-hist.cc:111
static void append(const std::string &=std::string())
Definition: cmd-hist.cc:739
static void read(bool=true)
Definition: cmd-hist.cc:705
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:769
static void clear(void)
Definition: cmd-hist.cc:628
static void set_file(const std::string &)
Definition: cmd-hist.cc:553
void usage(const char *fmt,...)
Definition: error.cc:418
static string_vector list(int=-1, bool=false)
Definition: cmd-hist.cc:753
static void do_run_history(const octave_value_list &args)
Definition: oct-hist.cc:541
static void edit_history_add_hist(const std::string &line)
Definition: oct-hist.cc:319
static bool add(const std::string &)
Definition: cmd-hist.cc:613
void initialize_history(bool read_history_file)
Definition: oct-hist.cc:563
static std::string concat(const std::string &, const std::string &)
Definition: file-ops.cc:360
void add_fcn(void(*fcn)(void))
void octave_history_write_timestamp(void)
Definition: oct-hist.cc:574
std::string string_value(bool force=false) const
Definition: ov.h:897
static std::string mk_tmp_hist_file(const octave_value_list &args, bool insert_curr, const char *warn_for)
Definition: oct-hist.cc:356
static int size(void)
Definition: cmd-hist.cc:592
bool is_string(void) const
Definition: ov.h:562
static std::string getenv(const std::string &name)
Definition: oct-env.cc:238
#define panic_impossible()
Definition: error.h:33
size_t size(T const (&)[z])
Definition: help.cc:103
std::string VEDITOR
Definition: defaults.cc:91
#define OCTAVE_VERSION
Definition: main.cc:46
octave_interrupt_handler octave_ignore_interrupts(void)
Definition: sighandlers.cc:583
double arg(double x)
Definition: lo-mappers.h:37
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:233
octave_idx_type length(void) const
Number of elements in the array.
Definition: Array.h:267
int Vecho_executing_commands
Definition: input.cc:94
static void write(const std::string &=std::string())
Definition: cmd-hist.cc:732
#define octave_stdout
Definition: pager.h:144
bool input_from_tmp_history_file
Definition: oct-hist.cc:73
static bool get_int_arg(const octave_value &arg, int &val)
Definition: oct-hist.cc:337
static std::string get_user_name(void)
Definition: oct-env.cc:181
static std::string histcontrol(void)
Definition: cmd-hist.cc:578
static void initialize(bool, const std::string &, int, const std::string &)
Definition: cmd-hist.cc:536
static int default_history_size(void)
Definition: oct-hist.cc:93
static std::string default_history_file(void)
Definition: oct-hist.cc:76
static char * edit_history_readline(std::fstream &stream)
Definition: oct-hist.cc:269
static void set_size(int)
Definition: cmd-hist.cc:585
std::string octave_tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:671
static std::string get_host_name(void)
Definition: oct-env.cc:188
static void do_edit_history(const octave_value_list &args)
Definition: oct-hist.cc:471
static void remove(int)
Definition: cmd-hist.cc:621
static void process_histcontrol(const std::string &)
Definition: cmd-hist.cc:571
static void ignore_entries(bool=true)
Definition: cmd-hist.cc:599
static void read_range(int=-1, int=-1, bool=true)
Definition: cmd-hist.cc:718
static bool read_history_file
Definition: octave.cc:142
static std::string get_home_directory(void)
Definition: oct-env.cc:146