GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-hist.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2022 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/*
27
28The functions listed below were adapted from similar functions from
29GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
30Software Foundation, Inc.
31
32 do_history edit_history_readline
33 do_edit_history edit_history_add_hist
34
35*/
36
37#if defined (HAVE_CONFIG_H)
38# include "config.h"
39#endif
40
41#include <cstdlib>
42#include <cstring>
43
44#include <fstream>
45#include <string>
46
47#include "cmd-hist.h"
48#include "file-ops.h"
49#include "lo-mappers.h"
50#include "lo-sysdep.h"
51#include "oct-env.h"
52#include "oct-time.h"
53#include "str-vec.h"
54#include "unistd-wrappers.h"
55
56#include "defun.h"
57#include "error.h"
58#include "errwarn.h"
59#include "event-manager.h"
60#include "input.h"
61#include "oct-hist.h"
62#include "ovl.h"
63#include "pager.h"
64#include "parse.h"
65#include "sighandlers.h"
66#include "sysdep.h"
67#include "interpreter.h"
68#include "interpreter-private.h"
69#include "unwind-prot.h"
70#include "utils.h"
71#include "variables.h"
72
73OCTAVE_NAMESPACE_BEGIN
74
75 // Read the edited history lines from STREAM and return them
76 // one at a time. This can read unlimited length lines. The
77 // caller should free the storage.
78
79 static char *
81 {
82 char c;
83 int line_len = 128;
84 int lindex = 0;
85 char *line = new char [line_len];
86 line[0] = '\0';
87
88 while (stream.get (c))
89 {
90 if (lindex + 2 >= line_len)
91 {
92 char *tmp_line = new char [line_len += 128];
93 strcpy (tmp_line, line);
94 delete [] line;
95 line = tmp_line;
96 }
97
98 if (c == '\n')
99 {
100 line[lindex++] = '\n';
101 line[lindex++] = '\0';
102 return line;
103 }
104 else
105 line[lindex++] = c;
106 }
107
108 if (! lindex)
109 {
110 delete [] line;
111 return nullptr;
112 }
113
114 if (lindex + 2 >= line_len)
115 {
116 char *tmp_line = new char [lindex+3];
117 strcpy (tmp_line, line);
118 delete [] line;
119 line = tmp_line;
120 }
121
122 // Finish with newline if none in file.
123
124 line[lindex++] = '\n';
125 line[lindex++] = '\0';
126 return line;
127 }
128
129 static void
130 edit_history_add_hist (const std::string& line)
131 {
132 if (! line.empty ())
133 {
134 std::string tmp = line;
135
136 int len = tmp.length ();
137
138 if (len > 0 && tmp[len-1] == '\n')
139 tmp.resize (len - 1);
140
141 if (! tmp.empty ())
142 {
143 if (command_history::add (tmp))
144 {
145 event_manager& evmgr
146 = __get_event_manager__ ("edit_history_add_hist");
147
148 evmgr.append_history (tmp);
149 }
150 }
151 }
152 }
153
154 static bool
155 get_int_arg (const octave_value& arg, int& val)
156 {
157 bool ok = true;
158
159 if (arg.is_string ())
160 {
161 std::string tmp = arg.string_value ();
162
163 ok = sscanf (tmp.c_str (), "%d", &val) == 1;
164 }
165 else if (arg.isnumeric ())
166 val = arg.int_value ();
167 else
168 ok = false;
169
170 return ok;
171 }
172
173 static std::string
175 bool insert_curr, const char *warn_for)
176 {
177 string_vector hlist = command_history::list ();
178
179 int hist_count = hlist.numel () - 1; // switch to zero-based indexing
180
181 // The current command line is already part of the history list by
182 // the time we get to this point. Delete the cmd from the list when
183 // executing 'edit_history' so that it doesn't show up in the history
184 // but the actual commands performed will.
185
186 if (! insert_curr)
187 command_history::remove (hist_count);
188
189 hist_count--; // skip last entry in history list
190
191 // If no numbers have been specified, the default is to edit the
192 // last command in the history list.
193
194 int hist_beg = hist_count;
195 int hist_end = hist_count;
196
197 bool reverse = false;
198
199 // Process options.
200
201 int nargin = args.length ();
202
203 if (nargin == 2)
204 {
205 if (! get_int_arg (args(0), hist_beg)
206 || ! get_int_arg (args(1), hist_end))
207 error ("%s: arguments must be integers", warn_for);
208
209 if (hist_beg < 0)
210 hist_beg += (hist_count + 1);
211 else
212 hist_beg--;
213 if (hist_end < 0)
214 hist_end += (hist_count + 1);
215 else
216 hist_end--;
217 }
218 else if (nargin == 1)
219 {
220 if (! get_int_arg (args(0), hist_beg))
221 error ("%s: argument must be an integer", warn_for);
222
223 if (hist_beg < 0)
224 hist_beg += (hist_count + 1);
225 else
226 hist_beg--;
227
228 hist_end = hist_beg;
229 }
230
231 if (hist_beg > hist_count || hist_end > hist_count)
232 error ("%s: history specification out of range", warn_for);
233
234 if (hist_end < hist_beg)
235 {
236 std::swap (hist_end, hist_beg);
237 reverse = true;
238 }
239
240 std::string name = sys::tempnam ("", "oct-");
241
242 std::ofstream file = sys::ofstream (name.c_str (), std::ios::out);
243
244 if (! file)
245 error ("%s: couldn't open temporary file '%s'", warn_for,
246 name.c_str ());
247
248 if (reverse)
249 {
250 for (int i = hist_end; i >= hist_beg; i--)
251 file << hlist[i] << "\n";
252 }
253 else
254 {
255 for (int i = hist_beg; i <= hist_end; i++)
256 file << hlist[i] << "\n";
257 }
258
259 file.close ();
260
261 return name;
262 }
263
265 : m_interpreter (interp), m_input_from_tmp_file (false),
266 m_timestamp_format_string (default_timestamp_format ())
267 { }
268
269 void history_system::initialize (bool read_history_file)
270 {
271 command_history::initialize (read_history_file, default_file (),
272 default_size (),
273 sys::env::getenv ("OCTAVE_HISTCONTROL"));
274
276
277 evmgr.set_history (command_history::list ());
278 }
279
281 {
282 sys::localtime now;
283
284 std::string timestamp = now.strftime (m_timestamp_format_string);
285
286 if (! timestamp.empty ())
287 {
288 if (command_history::add (timestamp))
289 {
291
292 evmgr.append_history (timestamp);
293 }
294 }
295 }
296
299 int nargout)
300 {
301 return set_internal_variable (m_input_from_tmp_file, args, nargout,
302 "input_from_tmp_file");
303 }
304
307 int nargout)
308 {
310 "timestamp_format_string");
311 }
312
313 // Display, save, or load history. Stolen and modified from bash.
314 //
315 // Arg of -w FILENAME means write file, arg of -r FILENAME
316 // means read file, arg of -q means don't number lines. Arg of N
317 // means only display that many items.
318
320 int nargout)
321 {
322 bool numbered_output = nargout == 0;
323
324 unwind_action restore_history_filename
325 ([] (const std::string& old_filename)
326 {
327 command_history::set_file (old_filename);
328 }, command_history::file ());
329
330 string_vector hlist;
331
332 int nargin = args.length ();
333
334 // Number of history lines to show (-1 = all)
335 int limit = -1;
336
337 for (octave_idx_type i = 0; i < nargin; i++)
338 {
339 octave_value arg = args(i);
340
341 std::string option;
342
343 if (arg.is_string ())
344 option = arg.string_value ();
345 else if (arg.isnumeric ())
346 {
347 limit = arg.int_value ();
348 if (limit < 0)
349 limit = -limit;
350 continue;
351 }
352 else
353 err_wrong_type_arg ("history", arg);
354
356
357 if (option == "-r" || option == "-w" || option == "-a"
358 || option == "-n")
359 {
360 if (i < nargin - 1)
361 {
362 std::string fname
363 = args(++i).xstring_value ("history: filename must be a string for %s option",
364 option.c_str ());
365
366 command_history::set_file (fname);
367 }
368 else
369 command_history::set_file (default_file ());
370
371 if (option == "-a")
372 // Append 'new' lines to file.
373 command_history::append ();
374
375 else if (option == "-w")
376 // Write entire history.
377 command_history::write ();
378
379 else if (option == "-r")
380 {
381 // Read entire file.
382 command_history::read ();
383 evmgr.set_history (command_history::list ());
384 }
385
386 else if (option == "-n")
387 {
388 // Read 'new' history from file.
389 command_history::read_range ();
390 evmgr.set_history (command_history::list ());
391 }
392
393 else
395
396 return hlist;
397 }
398 else if (option == "-c")
399 {
400 command_history::clear ();
401 evmgr.clear_history ();
402 }
403 else if (option == "-q")
404 numbered_output = false;
405 else if (option == "--")
406 {
407 i++;
408 break;
409 }
410 else
411 {
412 // The last argument found in the command list that looks like
413 // an integer will be used
414 int tmp;
415
416 if (sscanf (option.c_str (), "%d", &tmp) == 1)
417 {
418 if (tmp > 0)
419 limit = tmp;
420 else
421 limit = -tmp;
422 }
423
424 else
425 {
426 if (option.length () > 0 && option[0] == '-')
427 error ("history: unrecognized option '%s'", option.c_str ());
428 else
429 error ("history: bad non-numeric arg '%s'", option.c_str ());
430 }
431 }
432 }
433
434 hlist = command_history::list (limit, numbered_output);
435
436 int len = hlist.numel ();
437
438 if (nargout == 0)
439 {
440 for (octave_idx_type i = 0; i < len; i++)
441 octave_stdout << hlist[i] << "\n";
442 }
443
444 return hlist;
445 }
446
448 {
449 std::string name = mk_tmp_hist_file (args, false, "edit_history");
450
451 if (name.empty ())
452 return;
453
454 // Call up our favorite editor on the file of commands.
455
457 std::string cmd = env.editor ();
458 cmd.append (R"( ")" + name + '"');
459
460 // Ignore interrupts while we are off editing commands. Should we
461 // maybe avoid using system()?
462
463 volatile interrupt_handler old_interrupt_handler
465
466 int status = sys::system (cmd);
467
468 set_interrupt_handler (old_interrupt_handler);
469
470 // Check if text edition was successful. Abort the operation
471 // in case of failure.
472 if (status != EXIT_SUCCESS)
473 error ("edit_history: text editor command failed");
474
475 // Write the commands to the history file since source_file
476 // disables command line history while it executes.
477
478 std::fstream file = sys::fstream (name.c_str (), std::ios::in);
479
480 char *line;
481 //int first = 1;
482 while ((line = edit_history_readline (file)) != nullptr)
483 {
484 // Skip blank lines.
485
486 if (line[0] == '\n')
487 {
488 delete [] line;
489 continue;
490 }
491
493
494 delete [] line;
495 }
496
497 file.close ();
498
499 int(*unlink_fptr)(const std::string&) = sys::unlink;
500 unwind_action unlink_action (unlink_fptr, name);
501 unwind_protect_var<bool> upv (m_input_from_tmp_file, true);
502
503 // FIXME: instead of sourcing a file, we should just iterate through
504 // the list of commands, parsing and executing them one at a time as
505 // if they were entered interactively.
506
508 }
509
511 {
512 std::string name = mk_tmp_hist_file (args, false, "run_history");
513
514 if (name.empty ())
515 return;
516
517 int(*unlink_fptr)(const std::string&) = sys::unlink;
518 unwind_action unlink_action (unlink_fptr, name);
519 unwind_protect_var<bool> upv (m_input_from_tmp_file, true);
520
521 // FIXME: instead of sourcing a file, we should just iterate through
522 // the list of commands, parsing and executing them one at a time as
523 // if they were entered interactively.
524
526 }
527
529 {
530 std::string file;
531
532 std::string env_file = sys::env::getenv ("OCTAVE_HISTFILE");
533
534 if (! env_file.empty ())
535 file = env_file;
536
537 if (file.empty ())
538 {
539 // Default to $DATA/octave/history, where $DATA is the platform-
540 // dependent location for (roaming) user data files.
541
542 std::string user_data_dir = sys::env::get_user_data_directory ();
543
544 std::string hist_dir = user_data_dir + sys::file_ops::dir_sep_str ()
545 + "octave";
546
547 file = sys::env::make_absolute ("history", hist_dir);
548 }
549
550
551 return file;
552 }
553
555 {
556 int size = 1000;
557
558 std::string env_size = sys::env::getenv ("OCTAVE_HISTSIZE");
559
560 if (! env_size.empty ())
561 {
562 int val;
563
564 if (sscanf (env_size.c_str (), "%d", &val) == 1)
565 size = (val > 0 ? val : 0);
566 }
567
568 return size;
569 }
570
572 {
573 return
574 "# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <"
575 + sys::env::get_user_name ()
576 + '@'
577 + sys::env::get_host_name ()
578 + '>';
579 }
580
581DEFMETHOD (edit_history, interp, args, ,
582 doc: /* -*- texinfo -*-
583@deftypefn {} {} edit_history
584@deftypefnx {} {} edit_history @var{cmd_number}
585@deftypefnx {} {} edit_history @var{first} @var{last}
586Edit the history list using the editor named by the variable @env{EDITOR}.
587
588The commands to be edited are first copied to a temporary file. When you
589exit the editor, Octave executes the commands that remain in the file. It
590is often more convenient to use @code{edit_history} to define functions
591rather than attempting to enter them directly on the command line.
592The block of commands is executed as soon as you exit the editor.
593To avoid executing any commands, simply delete all the lines from the buffer
594before leaving the editor.
595
596When invoked with no arguments, edit the previously executed command;
597With one argument, edit the specified command @var{cmd_number};
598With two arguments, edit the list of commands between @var{first} and
599@var{last}. Command number specifiers may also be negative where -1
600refers to the most recently executed command.
601The following are equivalent and edit the most recently executed command.
602
603@example
604@group
605edit_history
606edit_history -1
607@end group
608@end example
609
610When using ranges, specifying a larger number for the first command than the
611last command reverses the list of commands before they are placed in the
612buffer to be edited.
613@seealso{run_history, history}
614@end deftypefn */)
615{
616 // FIXME: should this be limited to the top-level context?
617
618 if (args.length () > 2)
619 print_usage ();
620
621 history_system& history_sys = interp.get_history_system ();
622
623 history_sys.do_edit_history (args);
624
625 return ovl ();
626}
627
628DEFMETHOD (history, interp, args, nargout,
629 doc: /* -*- texinfo -*-
630@deftypefn {} {} history
631@deftypefnx {} {} history @var{opt1} @dots{}
632@deftypefnx {} {@var{h} =} history ()
633@deftypefnx {} {@var{h} =} history (@var{opt1}, @dots{})
634If invoked with no arguments, @code{history} displays a list of commands
635that you have executed.
636
637Valid options are:
638
639@table @code
640@item @var{n}
641@itemx -@var{n}
642Display only the most recent @var{n} lines of history.
643
644@item -c
645Clear the history list.
646
647@item -q
648Don't number the displayed lines of history. This is useful for cutting
649and pasting commands using the X Window System.
650
651@item -r @var{file}
652Read the file @var{file}, appending its contents to the current
653history list. If the name is omitted, use the default history file
654(normally @file{~/.octave_hist}).
655
656@item -w @var{file}
657Write the current history to the file @var{file}. If the name is
658omitted, use the default history file (normally @file{~/.octave_hist}).
659@end table
660
661For example, to display the five most recent commands that you have
662typed without displaying line numbers, use the command
663@kbd{history -q 5}.
664
665If invoked with a single output argument, the history will be saved to that
666argument as a cell string and will not be output to screen.
667@seealso{edit_history, run_history}
668@end deftypefn */)
669{
670 // FIXME: should this be limited to the top-level context?
671
672 history_system& history_sys = interp.get_history_system ();
673
674 // Call do_history even if nargout is zero to display history list.
675
676 string_vector hlist = history_sys.do_history (args, nargout);
677
678 return nargout > 0 ? ovl (Cell (hlist)) : ovl ();
679}
680
681DEFMETHOD (run_history, interp, args, ,
682 doc: /* -*- texinfo -*-
683@deftypefn {} {} run_history
684@deftypefnx {} {} run_history @var{cmd_number}
685@deftypefnx {} {} run_history @var{first} @var{last}
686Run commands from the history list.
687
688When invoked with no arguments, run the previously executed command;
689
690With one argument, run the specified command @var{cmd_number};
691
692With two arguments, run the list of commands between @var{first} and
693@var{last}. Command number specifiers may also be negative where -1
694refers to the most recently executed command. For example, the command
695
696@example
697@group
698run_history
699 OR
700run_history -1
701@end group
702@end example
703
704@noindent
705executes the most recent command again.
706The command
707
708@example
709run_history 13 169
710@end example
711
712@noindent
713executes commands 13 through 169.
714
715Specifying a larger number for the first command than the last command
716reverses the list of commands before executing them.
717For example:
718
719@example
720@group
721disp (1)
722disp (2)
723run_history -1 -2
724@result{}
725 2
726 1
727@end group
728@end example
729
730@seealso{edit_history, history}
731@end deftypefn */)
732{
733 // FIXME: should this be limited to the top-level context?
734
735 history_system& history_sys = interp.get_history_system ();
736
737 if (args.length () > 2)
738 print_usage ();
739
740 history_sys.do_run_history (args);
741
742 return ovl ();
743}
744
745DEFUN (history_control, args, nargout,
746 doc: /* -*- texinfo -*-
747@deftypefn {} {@var{val} =} history_control ()
748@deftypefnx {} {@var{old_val} =} history_control (@var{new_val})
749Query or set the internal variable that specifies how commands are saved
750to the history list.
751
752The default value is an empty character string, but may be overridden by the
753environment variable @w{@env{OCTAVE_HISTCONTROL}}.
754
755The value of @code{history_control} is a colon-separated list of values
756controlling how commands are saved on the history list. If the list
757of values includes @code{ignorespace}, lines which begin with a space
758character are not saved in the history list. A value of @code{ignoredups}
759causes lines matching the previous history entry to not be saved.
760A value of @code{ignoreboth} is shorthand for @code{ignorespace} and
761@code{ignoredups}. A value of @code{erasedups} causes all previous lines
762matching the current line to be removed from the history list before that
763line is saved. Any value not in the above list is ignored. If
764@code{history_control} is the empty string, all commands are saved on
765the history list, subject to the value of @code{history_save}.
766@seealso{history_file, history_size, history_timestamp_format_string,
767history_save}
768@end deftypefn */)
769{
770 octave_value retval;
771
772 std::string old_history_control = command_history::histcontrol ();
773
774 std::string tmp = old_history_control;
775
776 retval = set_internal_variable (tmp, args, nargout, "history_control");
777
778 if (tmp != old_history_control)
779 command_history::process_histcontrol (tmp);
780
781 return retval;
782}
783
784DEFUN (history_size, args, nargout,
785 doc: /* -*- texinfo -*-
786@deftypefn {} {@var{val} =} history_size ()
787@deftypefnx {} {@var{old_val} =} history_size (@var{new_val})
788Query or set the internal variable that specifies how many entries
789to store in the history file.
790
791The default value is @code{1000}, but may be overridden by the environment
792variable @w{@env{OCTAVE_HISTSIZE}}.
793@seealso{history_file, history_timestamp_format_string, history_save}
794@end deftypefn */)
795{
796 octave_value retval;
797
798 int old_history_size = command_history::size ();
799
800 int tmp = old_history_size;
801
802 retval = set_internal_variable (tmp, args, nargout,
803 "history_size", -1,
805
806 if (tmp != old_history_size)
807 command_history::set_size (tmp);
808
809 return retval;
810}
811
812DEFUN (history_file, args, nargout,
813 doc: /* -*- texinfo -*-
814@deftypefn {} {@var{val} =} history_file ()
815@deftypefnx {} {@var{old_val} =} history_file (@var{new_val})
816Query or set the internal variable that specifies the name of the file used to
817store command history.
818
819All future commands issued during the current Octave session will be written to
820this new file (if the current setting of @code{history_save} allows for this).
821
822The default value is @file{@w{@env{$DATA}}/octave/history}, where
823@w{@env{$DATA}} is the platform-specific location for (roaming) user data files
824(e.g., @w{@env{$XDG_DATA_HOME}} or, if that is not set, @file{~/.local/share} on
825Unix-like operating systems or @w{@env{%APPDATA%}} on Windows). The default
826value may be overridden by the environment variable @w{@env{OCTAVE_HISTFILE}}.
827
828Programming Notes:
829
830If you want to permanently change the location of Octave's history file you
831need to issue the @code{history_file} command in every new Octave session.
832This can be achieved by using Octave's @file{.octaverc} startup file.
833
834If you also want to read the saved history commands of past Octave sessions
835from this different history file, then you need to use the additional command
836@code{history -r} after setting the new value of the history file. Example
837code in Octave's startup file to do this might look like this:
838
839@example
840@group
841history_file ("~/new/.octave_hist");
842if (exist (history_file ()))
843 history ("-r", history_file());
844endif
845@end group
846@end example
847
848@seealso{history, history_control, history_save, history_size,
849history_timestamp_format_string}
850@end deftypefn */)
851{
852 octave_value retval;
853
854 std::string old_history_file = command_history::file ();
855
856 std::string tmp = old_history_file;
857
858 retval = set_internal_variable (tmp, args, nargout, "history_file");
859
860 if (tmp != old_history_file)
861 command_history::set_file (tmp);
862
863 return retval;
864}
865
866DEFMETHOD (history_timestamp_format_string, interp, args, nargout,
867 doc: /* -*- texinfo -*-
868@deftypefn {} {@var{val} =} history_timestamp_format_string ()
869@deftypefnx {} {@var{old_val} =} history_timestamp_format_string (@var{new_val})
870@deftypefnx {} {} history_timestamp_format_string (@var{new_val}, "local")
871Query or set the internal variable that specifies the format string
872for the comment line that is written to the history file when Octave
873exits.
874
875The format string is passed to @code{strftime}. The default value is
876
877@example
878"# Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>"
879@end example
880
881When called from inside a function with the @qcode{"local"} option, the
882variable is changed locally for the function and any subroutines it calls.
883The original variable value is restored when exiting the function.
884@seealso{strftime, history_file, history_size, history_save}
885@end deftypefn */)
886{
887 history_system& history_sys = interp.get_history_system ();
888
889 return history_sys.timestamp_format_string (args, nargout);
890}
891
892/*
893%!test
894%! history_timestamp_format_string ("# Example history marker", "local");
895%! assert (history_timestamp_format_string (), "# Example history marker")
896%!test <*57843>
897%! history_timestamp_format_string ("", "local");
898%! assert (history_timestamp_format_string (), "")
899*/
900
901DEFUN (history_save, args, nargout,
902 doc: /* -*- texinfo -*-
903@deftypefn {} {@var{val} =} history_save ()
904@deftypefnx {} {@var{old_val} =} history_save (@var{new_val})
905@deftypefnx {} {} history_save (@var{new_val}, "local")
906Query or set the internal variable that controls whether commands entered
907on the command line are saved in the history file.
908
909When called from inside a function with the @qcode{"local"} option, the
910variable is changed locally for the function and any subroutines it calls.
911The original variable value is restored when exiting the function.
912@seealso{history_control, history_file, history_size,
913history_timestamp_format_string}
914@end deftypefn */)
915{
916 octave_value retval;
917
918 bool old_history_save = ! command_history::ignoring_entries ();
919
920 bool tmp = old_history_save;
921
922 retval = set_internal_variable (tmp, args, nargout, "history_save");
923
924 if (tmp != old_history_save)
925 command_history::ignore_entries (! tmp);
926
927 return retval;
928}
929
930OCTAVE_NAMESPACE_END
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
Definition: Cell.h:43
octave_value editor(const octave_value_list &args, int nargout)
Definition: environment.cc:74
Provides threadsafe access to octave.
void append_history(const std::string &hist_entry)
void clear_history(void)
OCTINTERP_API void set_history(void)
void do_edit_history(const octave_value_list &args=octave_value_list())
Definition: oct-hist.cc:447
bool input_from_tmp_file(void) const
Definition: oct-hist.h:60
history_system(interpreter &interp)
Definition: oct-hist.cc:264
void do_run_history(const octave_value_list &args=octave_value_list())
Definition: oct-hist.cc:510
octave_value timestamp_format_string(const octave_value_list &args, int nargout)
Definition: oct-hist.cc:306
void initialize(bool read_history_file=false)
Definition: oct-hist.cc:269
bool m_input_from_tmp_file
Definition: oct-hist.h:96
static std::string default_timestamp_format(void)
Definition: oct-hist.cc:571
std::string timestamp_format_string(void) const
Definition: oct-hist.h:73
interpreter & m_interpreter
Definition: oct-hist.h:93
std::string m_timestamp_format_string
Definition: oct-hist.h:100
static int default_size(void)
Definition: oct-hist.cc:554
static std::string default_file(void)
Definition: oct-hist.cc:528
string_vector do_history(const octave_value_list &args=octave_value_list(), int nargout=0)
Definition: oct-hist.cc:319
void write_timestamp(void)
Definition: oct-hist.cc:280
event_manager & get_event_manager(void)
Definition: interpreter.h:328
environment & get_environment(void)
Definition: interpreter.h:241
octave_idx_type length(void) const
Definition: ovl.h:113
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:857
bool isnumeric(void) const
Definition: ov.h:795
bool is_string(void) const
Definition: ov.h:682
std::string string_value(bool force=false) const
Definition: ov.h:1019
octave_idx_type numel(void) const
Definition: str-vec.h:100
OCTINTERP_API void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
void error(const char *fmt,...)
Definition: error.cc:980
#define panic_impossible()
Definition: error.h:411
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:166
QString name
#define OCTAVE_VERSION
Definition: main.in.cc:63
std::string dir_sep_str(void)
Definition: file-ops.cc:238
std::fstream fstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:386
std::string tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:641
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:414
int unlink(const std::string &name)
Definition: file-ops.cc:621
int system(const std::string &cmd_str)
Definition: lo-sysdep.cc:59
event_manager & __get_event_manager__(const std::string &who)
static void edit_history_add_hist(const std::string &line)
Definition: oct-hist.cc:130
static std::string mk_tmp_hist_file(const octave_value_list &args, bool insert_curr, const char *warn_for)
Definition: oct-hist.cc:174
static OCTAVE_NAMESPACE_BEGIN char * edit_history_readline(std::fstream &stream)
Definition: oct-hist.cc:80
static bool get_int_arg(const octave_value &arg, int &val)
Definition: oct-hist.cc:155
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
Definition: oct-parse.cc:10249
static void initialize(void)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
#define octave_stdout
Definition: pager.h:314
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
Definition: sighandlers.cc:349
interrupt_handler ignore_interrupts(void)
Definition: sighandlers.cc:338
static string_vector make_absolute(const string_vector &sv)
Definition: utils.cc:535
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:587
F77_RET_T len
Definition: xerbla.cc:61