Mercurial > octave
annotate libinterp/corefcn/oct-hist.cc @ 20940:48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
* libinterp/corefcn/oct-obj.h: Replaced. Contains a #warning issued if used in
compilation and includes "ovl.h" instead. Original file renamed to
libinterp/octave-value/ovl.h
* libinterp/corefcn/oct-obj.cc: Renamed to libinterp/octave-value/ovl.cc.
* oct-obj.cc (ovl ()): Added new function to return empty octave_value_list.
* libinterp/corefcn/module.mk: Remove oct-obj.cc from build system.
* libinterp/octave-value/module.mk: Add ovl.h and ovl.cc to build system.
* mk-opts.pl, annotation-dialog.h, Cell.cc, __contourc__.cc, __dsearchn__.cc,
__lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc,
betainc.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, dlmread.cc, eig.cc,
error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc,
graphics.cc, gripes.cc, help.cc, hess.cc, hex2num.cc, hook-fcn.h, input.cc,
input.h, inv.cc, kron.cc, load-save.cc, lookup.cc, ls-hdf5.cc, ls-mat-ascii.cc,
ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lsode.cc, lu.cc,
luinc.cc, max.cc, mex.cc, oct-hist.cc, oct-lvalue.cc, oct-lvalue.h, oct-map.h,
oct-stream.cc, oct.h, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, quad.cc,
quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sparse-xpow.cc,
strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.h, syscalls.cc, sysdep.cc,
time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc,
variables.cc, xpow.cc, __delaunayn__.cc, __glpk__.cc, __voronoi__.cc,
audiodevinfo.cc, audioread.cc, chol.cc, convhulln.cc, dmperm.cc, qr.cc,
symbfact.cc, mkbuiltins, ov-base-diag.h, ov-base-int.cc, ov-base-mat.cc,
ov-base-mat.h, ov-base-scalar.cc, ov-base-sparse.cc, ov-base-sparse.h,
ov-base.cc, ov-bool-mat.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-colon.cc,
ov-complex.cc, ov-cs-list.h, ov-cx-mat.cc, ov-dld-fcn.cc, ov-fcn.cc, ov-fcn.h,
ov-float.cc, ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc,
ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.h, ov-mex-fcn.cc,
ov-perm.h, ov-range.cc, ov-re-mat.cc, ov-scalar.cc, ov-str-mat.cc,
ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, octave.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc,
op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc,
op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc,
op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc,
op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc,
op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc,
op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc,
op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc,
op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc,
op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc,
parse.h, pt-arg-list.cc, pt-assign.cc, pt-binop.cc, pt-cbinop.cc, pt-cell.cc,
pt-colon.cc, pt-const.cc, pt-eval.h, pt-fcn-handle.cc, pt-funcall.h, pt-id.cc,
pt-idx.cc, pt-jump.cc, pt-mat.cc, pt-select.cc, pt-unop.cc, token.cc,
Array-sym.cc: replace '#include "oct-obj.h"' with '#include "ovl.h"'.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Dec 2015 16:04:56 -0800 |
parents | 1142cf6abc0d |
children | 3aa293be0e8d |
rev | line source |
---|---|
1 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
3 Copyright (C) 1993-2015 John W. Eaton |
1 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
2939 | 21 */ |
22 | |
23 /* | |
24 | |
1 | 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 | |
240 | 34 #ifdef HAVE_CONFIG_H |
1192 | 35 #include <config.h> |
1 | 36 #endif |
37 | |
1343 | 38 #include <cstdlib> |
39 #include <cstring> | |
40 | |
1750 | 41 #include <string> |
42 | |
3503 | 43 #include <fstream> |
1350 | 44 |
1 | 45 #include <sys/types.h> |
46 #include <unistd.h> | |
1350 | 47 |
1799 | 48 #include "cmd-hist.h" |
1802 | 49 #include "file-ops.h" |
3016 | 50 #include "lo-mappers.h" |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
51 #include "octave-link.h" |
2926 | 52 #include "oct-env.h" |
5305 | 53 #include "oct-time.h" |
1755 | 54 #include "str-vec.h" |
55 | |
2492 | 56 #include <defaults.h> |
1352 | 57 #include "defun.h" |
1 | 58 #include "error.h" |
3016 | 59 #include "gripes.h" |
1 | 60 #include "input.h" |
1742 | 61 #include "oct-hist.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
62 #include "ovl.h" |
1352 | 63 #include "pager.h" |
3018 | 64 #include "parse.h" |
1352 | 65 #include "sighandlers.h" |
1690 | 66 #include "sysdep.h" |
1750 | 67 #include "toplev.h" |
1352 | 68 #include "unwind-prot.h" |
69 #include "utils.h" | |
2205 | 70 #include "variables.h" |
1 | 71 |
3018 | 72 // TRUE means input is coming from temporary history file. |
73 bool input_from_tmp_history_file = false; | |
168 | 74 |
5305 | 75 static std::string |
1 | 76 default_history_file (void) |
77 { | |
3523 | 78 std::string file; |
1 | 79 |
3523 | 80 std::string env_file = octave_env::getenv ("OCTAVE_HISTFILE"); |
1755 | 81 |
2926 | 82 if (! env_file.empty ()) |
6141 | 83 file = env_file; |
1 | 84 |
1755 | 85 if (file.empty ()) |
7272 | 86 file = file_ops::concat (octave_env::get_home_directory (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
87 ".octave_hist"); |
1 | 88 |
89 return file; | |
90 } | |
91 | |
5305 | 92 static int |
93 default_history_size (void) | |
94 { | |
16025
a78c1e445cfc
Change default history size to 1000.
Rik <rik@octave.org>
parents:
16022
diff
changeset
|
95 int size = 1000; |
5305 | 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) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
104 size = val > 0 ? val : 0; |
5305 | 105 } |
106 | |
107 return size; | |
108 } | |
109 | |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
110 static std::string |
5305 | 111 default_history_timestamp_format (void) |
112 { | |
113 return | |
114 std::string ("# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <") | |
115 + octave_env::get_user_name () | |
116 + std::string ("@") | |
117 + octave_env::get_host_name () | |
118 + std::string (">"); | |
119 } | |
120 | |
5794 | 121 // The format of the timestamp marker written to the history file when |
122 // Octave exits. | |
123 static std::string Vhistory_timestamp_format_string | |
124 = default_history_timestamp_format (); | |
125 | |
581 | 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 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
130 // means only display that many items. |
581 | 131 |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
132 static string_vector |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
133 do_history (const octave_value_list& args, int nargout) |
1 | 134 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
135 bool numbered_output = nargout == 0; |
1 | 136 |
12990
07dc4839c05f
properly save and restore command history file name in history command (bug #32524)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
137 unwind_protect frame; |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
138 |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
139 string_vector hlist; |
12990
07dc4839c05f
properly save and restore command history file name in history command (bug #32524)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
140 |
07dc4839c05f
properly save and restore command history file name in history command (bug #32524)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
141 frame.add_fcn (command_history::set_file, command_history::file ()); |
07dc4839c05f
properly save and restore command history file name in history command (bug #32524)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
142 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
143 int nargin = args.length (); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
144 |
16242
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
145 // Number of history lines to show (-1 = all) |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
146 int limit = -1; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
147 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
148 for (octave_idx_type i = 0; i < nargin; i++) |
1 | 149 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
150 octave_value arg = args(i); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
151 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
152 std::string option; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
153 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
154 if (arg.is_string ()) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
155 option = arg.string_value (); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
156 else if (arg.is_numeric_type ()) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
157 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
158 limit = arg.int_value (); |
16242
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
159 if (limit < 0) |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
160 limit = -limit; |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
161 continue; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
162 } |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
163 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
164 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
165 gripe_wrong_type_arg ("history", arg); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
166 return hlist; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
167 } |
2435 | 168 |
169 if (option == "-r" || option == "-w" || option == "-a" | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
170 || option == "-n") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
171 { |
16685
5c5c46a81ad5
Added default name usage for history -r,-w option (Bug #38986)
John Donoghue <john.donoghue@ieee.org>
parents:
16431
diff
changeset
|
172 if (i < nargin - 1) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
173 { |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
174 std::string fname |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
175 = args(++i).xstring_value ("history: filename must be a string for %s option", |
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
176 option.c_str ()); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
177 |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
178 command_history::set_file (fname); |
16685
5c5c46a81ad5
Added default name usage for history -r,-w option (Bug #38986)
John Donoghue <john.donoghue@ieee.org>
parents:
16431
diff
changeset
|
179 } |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
180 else |
16687
f4d18d3f7fd7
* oct-hist.cc: Style fixes. Remove unused code.
John W. Eaton <jwe@octave.org>
parents:
16685
diff
changeset
|
181 command_history::set_file (default_history_file ()); |
1 | 182 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
183 if (option == "-a") |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
184 // Append 'new' lines to file. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
185 command_history::append (); |
2435 | 186 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
187 else if (option == "-w") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
188 // Write entire history. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
189 command_history::write (); |
777 | 190 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
191 else if (option == "-r") |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
192 { |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
193 // Read entire file. |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
194 command_history::read (); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
195 octave_link::set_history (command_history::list ()); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
196 } |
777 | 197 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
198 else if (option == "-n") |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
199 { |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
200 // Read 'new' history from file. |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
201 command_history::read_range (); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
202 octave_link::set_history (command_history::list ()); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
203 } |
777 | 204 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
205 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
206 panic_impossible (); |
2435 | 207 |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
208 return hlist; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
209 } |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
210 else if (option == "-c") |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
211 { |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
212 command_history::clear (); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
213 octave_link::clear_history (); |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
214 } |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
215 else if (option == "-q") |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
216 numbered_output = false; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
217 else if (option == "--") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
218 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
219 i++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
220 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
221 } |
1 | 222 else |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
223 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
224 // The last argument found in the command list that looks like |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
225 // an integer will be used |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
226 int tmp; |
1 | 227 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
228 if (sscanf (option.c_str (), "%d", &tmp) == 1) |
16242
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
229 { |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
230 if (tmp > 0) |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
231 limit = tmp; |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
232 else |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
233 limit = -tmp; |
2a81ce01c383
Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents:
16196
diff
changeset
|
234 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
236 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
237 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
238 if (option.length () > 0 && option[0] == '-') |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
239 error ("history: unrecognized option '%s'", option.c_str ()); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
240 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
241 error ("history: bad non-numeric arg '%s'", option.c_str ()); |
1799 | 242 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
243 return hlist; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
244 } |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
245 } |
15817
dbb7896f15c7
Fix argument passing to history() command
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15814
diff
changeset
|
246 } |
1 | 247 |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
248 hlist = command_history::list (limit, numbered_output); |
1 | 249 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
250 int len = hlist.numel (); |
1799 | 251 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
252 if (nargout == 0) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
253 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
254 for (octave_idx_type i = 0; i < len; i++) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
255 octave_stdout << hlist[i] << "\n"; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
256 } |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
257 |
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
258 return hlist; |
1 | 259 } |
260 | |
581 | 261 // Read the edited history lines from STREAM and return them |
262 // one at a time. This can read unlimited length lines. The | |
2434 | 263 // caller should free the storage. |
581 | 264 |
1 | 265 static char * |
3551 | 266 edit_history_readline (std::fstream& stream) |
1 | 267 { |
268 char c; | |
269 int line_len = 128; | |
270 int lindex = 0; | |
271 char *line = new char [line_len]; | |
272 line[0] = '\0'; | |
273 | |
274 while (stream.get (c)) | |
275 { | |
276 if (lindex + 2 >= line_len) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
277 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
278 char *tmp_line = new char [line_len += 128]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
279 strcpy (tmp_line, line); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
280 delete [] line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
281 line = tmp_line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
282 } |
1 | 283 |
284 if (c == '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
285 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
286 line[lindex++] = '\n'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
287 line[lindex++] = '\0'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
288 return line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
289 } |
1 | 290 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
291 line[lindex++] = c; |
1 | 292 } |
293 | |
294 if (! lindex) | |
295 { | |
296 delete [] line; | |
529 | 297 return 0; |
1 | 298 } |
299 | |
300 if (lindex + 2 >= line_len) | |
301 { | |
302 char *tmp_line = new char [lindex+3]; | |
303 strcpy (tmp_line, line); | |
304 delete [] line; | |
305 line = tmp_line; | |
306 } | |
307 | |
1358 | 308 // Finish with newline if none in file. |
1 | 309 |
310 line[lindex++] = '\n'; | |
311 line[lindex++] = '\0'; | |
312 return line; | |
313 } | |
314 | |
315 static void | |
3523 | 316 edit_history_add_hist (const std::string& line) |
1 | 317 { |
1799 | 318 if (! line.empty ()) |
1 | 319 { |
3523 | 320 std::string tmp = line; |
1 | 321 |
1799 | 322 int len = tmp.length (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
323 |
1799 | 324 if (len > 0 && tmp[len-1] == '\n') |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
325 tmp.resize (len - 1); |
1799 | 326 |
327 if (! tmp.empty ()) | |
17219
33ce8c381f2c
make history widget respect history_control settings (bug #39728)
Torsten <ttl@justmail.de>
parents:
17215
diff
changeset
|
328 if (command_history::add (tmp)) |
17215
7c06875c2dcc
Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents:
17214
diff
changeset
|
329 octave_link::append_history (tmp); |
1 | 330 } |
331 } | |
332 | |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
333 static bool |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
334 get_int_arg (const octave_value& arg, int& val) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
335 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
336 bool ok = true; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
337 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
338 if (arg.is_string ()) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
339 { |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
340 std::string tmp = arg.string_value (); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
341 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
342 ok = sscanf (tmp.c_str (), "%d", &val) == 1; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
343 } |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
344 else if (arg.is_numeric_type ()) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
345 val = arg.int_value (); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
346 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
347 ok = false; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
348 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
349 return ok; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
350 } |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
351 |
3536 | 352 static std::string |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
353 mk_tmp_hist_file (const octave_value_list& args, |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
354 bool insert_curr, const char *warn_for) |
1 | 355 { |
3523 | 356 std::string retval; |
1 | 357 |
2926 | 358 string_vector hlist = command_history::list (); |
1 | 359 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
360 int hist_count = hlist.numel () - 1; // switch to zero-based indexing |
1 | 361 |
1358 | 362 // The current command line is already part of the history list by |
16051
3a06aa956d96
Fix off-by-1 error in history list when running 'edit_history'.
Rik <rik@octave.org>
parents:
16025
diff
changeset
|
363 // the time we get to this point. Delete the cmd from the list when |
3a06aa956d96
Fix off-by-1 error in history list when running 'edit_history'.
Rik <rik@octave.org>
parents:
16025
diff
changeset
|
364 // executing 'edit_history' so that it doesn't show up in the history |
3a06aa956d96
Fix off-by-1 error in history list when running 'edit_history'.
Rik <rik@octave.org>
parents:
16025
diff
changeset
|
365 // but the actual commands performed will. |
1 | 366 |
64 | 367 if (! insert_curr) |
2926 | 368 command_history::remove (hist_count); |
1799 | 369 |
16022
d8f216d241cf
Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents:
16016
diff
changeset
|
370 hist_count--; // skip last entry in history list |
1 | 371 |
1358 | 372 // If no numbers have been specified, the default is to edit the |
373 // last command in the history list. | |
1 | 374 |
16022
d8f216d241cf
Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents:
16016
diff
changeset
|
375 int hist_beg = hist_count; |
1 | 376 int hist_end = hist_count; |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
377 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
378 bool reverse = false; |
1 | 379 |
1358 | 380 // Process options. |
1 | 381 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
382 int nargin = args.length (); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
383 |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
384 bool usage_error = false; |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
385 if (nargin == 2) |
1 | 386 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
387 if (get_int_arg (args(0), hist_beg) |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
388 && get_int_arg (args(1), hist_end)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
389 { |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
390 if (hist_beg < 0) |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
391 hist_beg += (hist_count + 1); |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
392 else |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
393 hist_beg--; |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
394 if (hist_end < 0) |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
395 hist_end += (hist_count + 1); |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
396 else |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
397 hist_end--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
398 } |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
399 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
400 usage_error = true; |
1 | 401 } |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
402 else if (nargin == 1) |
1 | 403 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
404 if (get_int_arg (args(0), hist_beg)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
405 { |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
406 if (hist_beg < 0) |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
407 hist_beg += (hist_count + 1); |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
408 else |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
409 hist_beg--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
410 hist_end = hist_beg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
411 } |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
412 else |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
413 usage_error = true; |
1 | 414 } |
415 | |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
416 if (usage_error) |
1 | 417 { |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
418 usage ("%s [first] [last]", warn_for); |
1799 | 419 return retval; |
1 | 420 } |
421 | |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
422 if (hist_beg > hist_count || hist_end > hist_count) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
423 error ("%s: history specification out of range", warn_for); |
1 | 424 |
425 if (hist_end < hist_beg) | |
426 { | |
16022
d8f216d241cf
Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents:
16016
diff
changeset
|
427 std::swap (hist_end, hist_beg); |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
428 reverse = true; |
1 | 429 } |
430 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
431 std::string name = octave_tempnam ("", "oct-"); |
1 | 432 |
3551 | 433 std::fstream file (name.c_str (), std::ios::out); |
64 | 434 |
1 | 435 if (! file) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
436 error ("%s: couldn't open temporary file '%s'", warn_for, |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
437 name.c_str ()); |
1 | 438 |
439 if (reverse) | |
440 { | |
441 for (int i = hist_end; i >= hist_beg; i--) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
442 file << hlist[i] << "\n"; |
1 | 443 } |
444 else | |
445 { | |
446 for (int i = hist_beg; i <= hist_end; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
447 file << hlist[i] << "\n"; |
1 | 448 } |
449 | |
450 file.close (); | |
451 | |
1755 | 452 return name; |
64 | 453 } |
454 | |
10411 | 455 static void |
456 unlink_cleanup (const char *file) | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
457 { |
10411 | 458 gnulib::unlink (file); |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
459 } |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
460 |
1755 | 461 static void |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
462 do_edit_history (const octave_value_list& args) |
64 | 463 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
464 std::string name = mk_tmp_hist_file (args, false, "edit_history"); |
64 | 465 |
1755 | 466 if (name.empty ()) |
64 | 467 return; |
468 | |
1358 | 469 // Call up our favorite editor on the file of commands. |
1 | 470 |
5794 | 471 std::string cmd = VEDITOR; |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
472 cmd.append (" \"" + name + "\""); |
1 | 473 |
1358 | 474 // Ignore interrupts while we are off editing commands. Should we |
475 // maybe avoid using system()? | |
1 | 476 |
2705 | 477 volatile octave_interrupt_handler old_interrupt_handler |
2554 | 478 = octave_ignore_interrupts (); |
1443 | 479 |
15990
696e82182eba
Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
15823
diff
changeset
|
480 int status = system (cmd.c_str ()); |
1443 | 481 |
2554 | 482 octave_set_interrupt_handler (old_interrupt_handler); |
1 | 483 |
15990
696e82182eba
Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
15823
diff
changeset
|
484 // Check if text edition was successfull. Abort the operation |
696e82182eba
Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
15823
diff
changeset
|
485 // in case of failure. |
696e82182eba
Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
15823
diff
changeset
|
486 if (status != EXIT_SUCCESS) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
487 error ("edit_history: text editor command failed"); |
15990
696e82182eba
Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
15823
diff
changeset
|
488 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7272
diff
changeset
|
489 // Write the commands to the history file since source_file |
1358 | 490 // disables command line history while it executes. |
1 | 491 |
3551 | 492 std::fstream file (name.c_str (), std::ios::in); |
1 | 493 |
494 char *line; | |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
495 //int first = 1; |
529 | 496 while ((line = edit_history_readline (file)) != 0) |
1 | 497 { |
1358 | 498 // Skip blank lines. |
1 | 499 |
500 if (line[0] == '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
501 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
502 delete [] line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
503 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
504 } |
1 | 505 |
16051
3a06aa956d96
Fix off-by-1 error in history list when running 'edit_history'.
Rik <rik@octave.org>
parents:
16025
diff
changeset
|
506 edit_history_add_hist (line); |
16016 | 507 |
508 delete [] line; | |
1 | 509 } |
510 | |
511 file.close (); | |
512 | |
1358 | 513 // Turn on command echo, so the output from this will make better |
514 // sense. | |
1 | 515 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
516 unwind_protect frame; |
3018 | 517 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
518 frame.add_fcn (unlink_cleanup, name.c_str ()); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
519 frame.protect_var (Vecho_executing_commands); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
520 frame.protect_var (input_from_tmp_history_file); |
3018 | 521 |
2205 | 522 Vecho_executing_commands = ECHO_CMD_LINE; |
3018 | 523 input_from_tmp_history_file = true; |
1 | 524 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7272
diff
changeset
|
525 source_file (name); |
1 | 526 } |
527 | |
1755 | 528 static void |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
529 do_run_history (const octave_value_list& args) |
64 | 530 { |
16243
428da5debfe4
maint: Remove commented out lines from history fix in changeset 2a81ce01c383.
Rik <rik@octave.org>
parents:
16242
diff
changeset
|
531 std::string name = mk_tmp_hist_file (args, false, "run_history"); |
64 | 532 |
1755 | 533 if (name.empty ()) |
64 | 534 return; |
535 | |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
536 // Turn on command echo so the output from this will make better sense. |
64 | 537 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
538 unwind_protect frame; |
3018 | 539 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
540 frame.add_fcn (unlink_cleanup, name.c_str ()); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
541 frame.protect_var (Vecho_executing_commands); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
542 frame.protect_var (input_from_tmp_history_file); |
3018 | 543 |
2205 | 544 Vecho_executing_commands = ECHO_CMD_LINE; |
3018 | 545 input_from_tmp_history_file = true; |
64 | 546 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7272
diff
changeset
|
547 source_file (name); |
64 | 548 } |
549 | |
5305 | 550 void |
8273
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
551 initialize_history (bool read_history_file) |
5794 | 552 { |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
553 command_history::initialize (read_history_file, |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
554 default_history_file (), |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
555 default_history_size (), |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
556 octave_env::getenv ("OCTAVE_HISTCONTROL")); |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
557 |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
558 octave_link::set_history (command_history::list ()); |
5794 | 559 } |
560 | |
561 void | |
5305 | 562 octave_history_write_timestamp (void) |
563 { | |
564 octave_localtime now; | |
565 | |
566 std::string timestamp = now.strftime (Vhistory_timestamp_format_string); | |
567 | |
568 if (! timestamp.empty ()) | |
17219
33ce8c381f2c
make history widget respect history_control settings (bug #39728)
Torsten <ttl@justmail.de>
parents:
17215
diff
changeset
|
569 if (command_history::add (timestamp)) |
17215
7c06875c2dcc
Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents:
17214
diff
changeset
|
570 octave_link::append_history (timestamp); |
5305 | 571 } |
572 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8286
diff
changeset
|
573 DEFUN (edit_history, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
574 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
575 @deftypefn {} {} edit_history\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
576 @deftypefnx {} {} edit_history @var{cmd_number}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
577 @deftypefnx {} {} edit_history @var{first} @var{last}\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
578 Edit the history list using the editor named by the variable @env{EDITOR}.\n\ |
3332 | 579 \n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
580 The commands to be edited are first copied to a temporary file. When you\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
581 exit the editor, Octave executes the commands that remain in the file. It\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
582 is often more convenient to use @code{edit_history} to define functions\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
583 rather than attempting to enter them directly on the command line.\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
584 The block of commands is executed as soon as you exit the editor.\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
585 To avoid executing any commands, simply delete all the lines from the buffer\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
586 before leaving the editor.\n\ |
3332 | 587 \n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
588 When invoked with no arguments, edit the previously executed command;\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
589 With one argument, edit the specified command @var{cmd_number};\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
590 With two arguments, edit the list of commands between @var{first} and\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
591 @var{last}. Command number specifiers may also be negative where -1\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
592 refers to the most recently executed command.\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
593 The following are equivalent and edit the most recently executed command.\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
594 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
595 @example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
596 @group\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
597 edit_history\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
598 edit_history -1\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
599 @end group\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
600 @end example\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
601 \n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
602 When using ranges, specifying a larger number for the first command than the\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
603 last command reverses the list of commands before they are placed in the\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
604 buffer to be edited.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
605 @seealso{run_history, history}\n\ |
11547 | 606 @end deftypefn") |
529 | 607 { |
2086 | 608 octave_value_list retval; |
529 | 609 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
610 do_edit_history (args); |
529 | 611 |
612 return retval; | |
613 } | |
614 | |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
615 DEFUN (history, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
616 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
617 @deftypefn {} {} history\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
618 @deftypefnx {} {} history @var{opt1} @dots{}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
619 @deftypefnx {} {@var{h} =} history ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
620 @deftypefnx {} {@var{h} =} history (@var{opt1}, @dots{})\n\ |
3332 | 621 If invoked with no arguments, @code{history} displays a list of commands\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
622 that you have executed.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
623 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
624 Valid options are:\n\ |
3332 | 625 \n\ |
626 @table @code\n\ | |
16052 | 627 @item @var{n}\n\ |
628 @itemx -@var{n}\n\ | |
629 Display only the most recent @var{n} lines of history.\n\ | |
630 \n\ | |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
631 @item -c\n\ |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
632 Clear the history list.\n\ |
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16243
diff
changeset
|
633 \n\ |
16052 | 634 @item -q\n\ |
635 Don't number the displayed lines of history. This is useful for cutting\n\ | |
636 and pasting commands using the X Window System.\n\ | |
529 | 637 \n\ |
3332 | 638 @item -r @var{file}\n\ |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
639 Read the file @var{file}, appending its contents to the current\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11368
diff
changeset
|
640 history list. If the name is omitted, use the default history file\n\ |
3332 | 641 (normally @file{~/.octave_hist}).\n\ |
642 \n\ | |
16052 | 643 @item -w @var{file}\n\ |
644 Write the current history to the file @var{file}. If the name is\n\ | |
645 omitted, use the default history file (normally @file{~/.octave_hist}).\n\ | |
3332 | 646 @end table\n\ |
647 \n\ | |
648 For example, to display the five most recent commands that you have\n\ | |
649 typed without displaying line numbers, use the command\n\ | |
650 @kbd{history -q 5}.\n\ | |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
651 \n\ |
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
652 If invoked with a single output argument, the history will be saved to that\n\ |
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
653 argument as a cell string and will not be output to screen.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
654 @seealso{edit_history, run_history}\n\ |
11547 | 655 @end deftypefn") |
529 | 656 { |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
657 octave_value retval; |
529 | 658 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
659 string_vector hlist = do_history (args, nargout); |
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
660 |
15814
1eee8d8c59fd
Return history as a cell string when called with an output argument (bug #37947)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15467
diff
changeset
|
661 if (nargout > 0) |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
662 retval = Cell (hlist); |
529 | 663 |
664 return retval; | |
665 } | |
666 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8286
diff
changeset
|
667 DEFUN (run_history, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
668 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
669 @deftypefn {} {} run_history\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
670 @deftypefnx {} {} run_history @var{cmd_number}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
671 @deftypefnx {} {} run_history @var{first} @var{last}\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
672 Run commands from the history list.\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
673 \n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
674 When invoked with no arguments, run the previously executed command;\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
675 \n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
676 With one argument, run the specified command @var{cmd_number};\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
677 \n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
678 With two arguments, run the list of commands between @var{first} and\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
679 @var{last}. Command number specifiers may also be negative where -1\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
680 refers to the most recently executed command. For example, the command\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
681 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
682 @example\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
683 @group\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
684 run_history\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
685 OR\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
686 run_history -1\n\ |
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
687 @end group\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
688 @end example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
689 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
690 @noindent\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
691 executes the most recent command again.\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
692 The command\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
693 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
694 @example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
695 run_history 13 169\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
696 @end example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
697 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
698 @noindent\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
699 executes commands 13 through 169.\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
700 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
701 Specifying a larger number for the first command than the last command\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
702 reverses the list of commands before executing them.\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
703 For example:\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
704 \n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
705 @example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
706 @group\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
707 disp (1)\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
708 disp (2)\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
709 run_history -1 -2\n\ |
16189
2825897a0c27
doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents:
16188
diff
changeset
|
710 @result{}\n\ |
16188
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
711 2\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
712 1\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
713 @end group\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
714 @end example\n\ |
8366bc871d45
Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents:
16052
diff
changeset
|
715 \n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
716 @seealso{edit_history, history}\n\ |
11547 | 717 @end deftypefn") |
529 | 718 { |
2086 | 719 octave_value_list retval; |
529 | 720 |
15823
bc7a130bbdfb
allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents:
15817
diff
changeset
|
721 do_run_history (args); |
529 | 722 |
723 return retval; | |
724 } | |
725 | |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
726 DEFUN (history_control, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
727 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
728 @deftypefn {} {@var{val} =} history_control ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
729 @deftypefnx {} {@var{old_val} =} history_control (@var{new_val})\n\ |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
730 Query or set the internal variable that specifies how commands are saved\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
731 to the history list.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
732 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
733 The default value is an empty character string, but may be overridden by the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
734 environment variable @w{@env{OCTAVE_HISTCONTROL}}.\n\ |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
735 \n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
736 The value of @code{history_control} is a colon-separated list of values\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
737 controlling how commands are saved on the history list. If the list\n\ |
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
738 of values includes @code{ignorespace}, lines which begin with a space\n\ |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
739 character are not saved in the history list. A value of @code{ignoredups}\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
740 causes lines matching the previous history entry to not be saved.\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
741 A value of @code{ignoreboth} is shorthand for @code{ignorespace} and\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
742 @code{ignoredups}. A value of @code{erasedups} causes all previous lines\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
743 matching the current line to be removed from the history list before that\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
744 line is saved. Any value not in the above list is ignored. If\n\ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
745 @code{history_control} is the empty string, all commands are saved on\n\ |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
746 the history list, subject to the value of @code{history_save}.\n\ |
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
747 @seealso{history_file, history_size, history_timestamp_format_string, history_save}\n\ |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
748 @end deftypefn") |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
749 { |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
750 octave_value retval; |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
751 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
752 std::string old_history_control = command_history::histcontrol (); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
753 |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
754 std::string tmp = old_history_control; |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
755 |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
756 retval = set_internal_variable (tmp, args, nargout, "history_control"); |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
757 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
758 if (tmp != old_history_control) |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
759 command_history::process_histcontrol (tmp); |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
760 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
761 return retval; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
762 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
763 |
5794 | 764 DEFUN (history_size, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
765 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
766 @deftypefn {} {@var{val} =} history_size ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
767 @deftypefnx {} {@var{old_val} =} history_size (@var{new_val})\n\ |
5794 | 768 Query or set the internal variable that specifies how many entries\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
769 to store in the history file.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
770 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
771 The default value is @code{1000}, but may be overridden by the environment\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
772 variable @w{@env{OCTAVE_HISTSIZE}}.\n\ |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
773 @seealso{history_file, history_timestamp_format_string, history_save}\n\ |
5794 | 774 @end deftypefn") |
3016 | 775 { |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
776 octave_value retval; |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
777 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
778 int old_history_size = command_history::size (); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
779 |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
780 int tmp = old_history_size; |
5800 | 781 |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
782 retval = set_internal_variable (tmp, args, nargout, |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
783 "history_size", -1, |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
784 std::numeric_limits<int>::max ()); |
5800 | 785 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
786 if (tmp != old_history_size) |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
787 command_history::set_size (tmp); |
5800 | 788 |
789 return retval; | |
3016 | 790 } |
791 | |
5794 | 792 DEFUN (history_file, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
793 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
794 @deftypefn {} {@var{val} =} history_file ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
795 @deftypefnx {} {@var{old_val} =} history_file (@var{new_val})\n\ |
5794 | 796 Query or set the internal variable that specifies the name of the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
797 file used to store command history.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
798 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
799 The default value is @file{~/.octave_hist}, but may be overridden by the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
800 environment variable @w{@env{OCTAVE_HISTFILE}}.\n\ |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
801 @seealso{history_size, history_save, history_timestamp_format_string}\n\ |
5794 | 802 @end deftypefn") |
5305 | 803 { |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
804 octave_value retval; |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
805 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
806 std::string old_history_file = command_history::file (); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
807 |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
808 std::string tmp = old_history_file; |
5305 | 809 |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
810 retval = set_internal_variable (tmp, args, nargout, "history_file"); |
5305 | 811 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
812 if (tmp != old_history_file) |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
813 command_history::set_file (tmp); |
5305 | 814 |
5800 | 815 return retval; |
3016 | 816 } |
817 | |
5794 | 818 DEFUN (history_timestamp_format_string, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
819 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
820 @deftypefn {} {@var{val} =} history_timestamp_format_string ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
821 @deftypefnx {} {@var{old_val} =} history_timestamp_format_string (@var{new_val})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
822 @deftypefnx {} {} history_timestamp_format_string (@var{new_val}, \"local\")\n\ |
6653 | 823 Query or set the internal variable that specifies the format string\n\ |
5794 | 824 for the comment line that is written to the history file when Octave\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
825 exits.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
826 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
827 The format string is passed to @code{strftime}. The default value is\n\ |
5305 | 828 \n\ |
829 @example\n\ | |
830 \"# Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>\"\n\ | |
831 @end example\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12990
diff
changeset
|
832 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
833 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
834 variable is changed locally for the function and any subroutines it calls.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
835 The original variable value is restored when exiting the function.\n\ |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
836 @seealso{strftime, history_file, history_size, history_save}\n\ |
5794 | 837 @end deftypefn") |
838 { | |
839 return SET_INTERNAL_VARIABLE (history_timestamp_format_string); | |
840 } | |
5305 | 841 |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
842 DEFUN (history_save, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
843 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
844 @deftypefn {} {@var{val} =} history_save ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
845 @deftypefnx {} {@var{old_val} =} history_save (@var{new_val})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
846 @deftypefnx {} {} history_save (@var{new_val}, \"local\")\n\ |
5794 | 847 Query or set the internal variable that controls whether commands entered\n\ |
848 on the command line are saved in the history file.\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12990
diff
changeset
|
849 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
850 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
851 variable is changed locally for the function and any subroutines it calls.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
852 The original variable value is restored when exiting the function.\n\ |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
11405
diff
changeset
|
853 @seealso{history_control, history_file, history_size, history_timestamp_format_string}\n\ |
5794 | 854 @end deftypefn") |
855 { | |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
856 octave_value retval; |
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
857 |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
858 bool old_history_save = ! command_history::ignoring_entries (); |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
859 |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
860 bool tmp = old_history_save; |
5794 | 861 |
17345
91691d74845d
oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
862 retval = set_internal_variable (tmp, args, nargout, "history_save"); |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
863 |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16687
diff
changeset
|
864 if (tmp != old_history_save) |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
865 command_history::ignore_entries (! tmp); |
5794 | 866 |
867 return retval; | |
3016 | 868 } |