annotate libinterp/corefcn/oct-hist.cc @ 21301:40de9f8f23a6

Use '#include "config.h"' rather than <config.h>. * mk-octave-config-h.sh, mk-opts.pl, Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc, ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc, ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc, SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc, annotation-dialog.cc, gl-select.cc, module.mk, kpty.cpp, color-picker.cc, dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc, find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc, marker.cc, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc, octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc, octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc, settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc, thread-manager.cc, welcome-wizard.cc, workspace-model.cc, workspace-view.cc, build-env-features.sh, build-env.in.cc, Cell.cc, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, cdisplay.c, cellfun.cc, coct-hdf5-types.c, colloc.cc, comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc, errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc, help.cc, hess.cc, hex2num.cc, hook-fcn.cc, input.cc, inv.cc, jit-ir.cc, jit-typeinfo.cc, jit-util.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, ls-utils.cc, lsode.cc, lu.cc, luinc.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc, oct-hdf5-types.cc, oct-hist.cc, oct-iostrm.cc, oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc, oct-strstrm.cc, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, siglist.c, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc, xpow.cc, zfstream.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, mkbuiltins, mkops, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc, ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.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-dm-template.cc, op-dms-template.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-pm-template.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, lex.ll, oct-parse.in.yy, pt-arg-list.cc, pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc, pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc, pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc, pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc, token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, lo-error.c, quit.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc, chol.cc, eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc, lo-mappers.cc, lo-specfun.cc, lu.cc, oct-convn.cc, oct-fftw.cc, oct-norm.cc, oct-rand.cc, oct-spparms.cc, qr.cc, qrp.cc, randgamma.c, randmtzig.c, randpoisson.c, schur.cc, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc, mk-ops.awk, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-ieee.cc, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-locbuf.cc, oct-mutex.cc, oct-rl-edit.c, oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, str-vec.cc, unwind-prot.cc, url-transfer.cc, display-available.c, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-config.in.cc: Use '#include "config.h"' rather than <config.h>.
author Rik <rik@octave.org>
date Thu, 18 Feb 2016 13:34:50 -0800
parents fcac5dbbf9ed
children aba2e6293dd8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
2939
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2936
diff changeset
21 */
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2936
diff changeset
22
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2936
diff changeset
23 /*
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2936
diff changeset
24
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 The functions listed below were adapted from similar functions from
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26 GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27 Software Foundation, Inc.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29 do_history edit_history_readline
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30 do_edit_history edit_history_add_hist
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
31
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
32 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
33
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 217
diff changeset
34 #ifdef HAVE_CONFIG_H
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
35 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
36 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1321
diff changeset
38 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1321
diff changeset
39 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1321
diff changeset
40
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
41 #include <string>
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
42
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3499
diff changeset
43 #include <fstream>
1350
5f63d83dd694 [project @ 1995-09-05 07:37:59 by jwe]
jwe
parents: 1346
diff changeset
44
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 #include <sys/types.h>
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46 #include <unistd.h>
1350
5f63d83dd694 [project @ 1995-09-05 07:37:59 by jwe]
jwe
parents: 1346
diff changeset
47
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
48 #include "cmd-hist.h"
1802
8173b1fa052d [project @ 1996-01-29 06:10:18 by jwe]
jwe
parents: 1799
diff changeset
49 #include "file-ops.h"
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
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
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2897
diff changeset
52 #include "oct-env.h"
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
53 #include "oct-time.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
54 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
55
2492
06595bc7f2d0 [project @ 1996-11-09 00:13:50 by jwe]
jwe
parents: 2442
diff changeset
56 #include <defaults.h>
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
57 #include "defun.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
58 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20983
diff changeset
59 #include "errwarn.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60 #include "input.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1690
diff changeset
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
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
63 #include "pager.h"
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
64 #include "parse.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
65 #include "sighandlers.h"
1690
a38bd8df9d33 [project @ 1996-01-05 21:36:24 by jwe]
jwe
parents: 1670
diff changeset
66 #include "sysdep.h"
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
67 #include "toplev.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
68 #include "unwind-prot.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
69 #include "utils.h"
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
70 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
71
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
72 // TRUE means input is coming from temporary history file.
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
73 bool input_from_tmp_history_file = false;
168
a500c60e8f23 [project @ 1993-10-19 05:24:44 by jwe]
jwe
parents: 64
diff changeset
74
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
75 static std::string
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
76 default_history_file (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
77 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
78 std::string file;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
79
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
80 std::string env_file = octave_env::getenv ("OCTAVE_HISTFILE");
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
81
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2897
diff changeset
82 if (! env_file.empty ())
6141
f6c2d9276572 [project @ 2006-11-06 17:52:51 by jwe]
jwe
parents: 5872
diff changeset
83 file = env_file;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
84
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
85 if (file.empty ())
7272
05ee52d7fad6 [project @ 2007-12-10 07:06:00 by jwe]
jwe
parents: 7257
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
88
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
89 return file;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
90 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
91
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
92 static int
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
93 default_history_size (void)
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
94 {
16025
a78c1e445cfc Change default history size to 1000.
Rik <rik@octave.org>
parents: 16022
diff changeset
95 int size = 1000;
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
96
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
97 std::string env_size = octave_env::getenv ("OCTAVE_HISTSIZE");
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
98
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
99 if (! env_size.empty ())
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
100 {
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
101 int val;
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
102
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
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
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
105 }
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
106
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
107 return size;
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
108 }
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
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
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
111 default_history_timestamp_format (void)
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
112 {
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
113 return
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
114 std::string ("# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <")
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
115 + octave_env::get_user_name ()
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
116 + std::string ("@")
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
117 + octave_env::get_host_name ()
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
118 + std::string (">");
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
119 }
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
120
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
121 // The format of the timestamp marker written to the history file when
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
122 // Octave exits.
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
123 static std::string Vhistory_timestamp_format_string
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
124 = default_history_timestamp_format ();
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
125
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
126 // Display, save, or load history. Stolen and modified from bash.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
127 //
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
128 // Arg of -w FILENAME means write file, arg of -r FILENAME
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
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
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
21129
228b65504557 maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents: 21100
diff changeset
164 err_wrong_type_arg ("history", arg);
2435
3be97fe02051 [project @ 1996-10-27 21:31:29 by jwe]
jwe
parents: 2434
diff changeset
165
3be97fe02051 [project @ 1996-10-27 21:31:29 by jwe]
jwe
parents: 2434
diff changeset
166 if (option == "-r" || option == "-w" || option == "-a"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
167 || option == "-n")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
168 {
16685
5c5c46a81ad5 Added default name usage for history -r,-w option (Bug #38986)
John Donoghue <john.donoghue@ieee.org>
parents: 16431
diff changeset
169 if (i < nargin - 1)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
170 {
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
171 std::string fname
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20700
diff changeset
172 = 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
173 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
174
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
175 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
176 }
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
177 else
16687
f4d18d3f7fd7 * oct-hist.cc: Style fixes. Remove unused code.
John W. Eaton <jwe@octave.org>
parents: 16685
diff changeset
178 command_history::set_file (default_history_file ());
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
179
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
180 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
181 // Append 'new' lines to file.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
182 command_history::append ();
2435
3be97fe02051 [project @ 1996-10-27 21:31:29 by jwe]
jwe
parents: 2434
diff changeset
183
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
184 else if (option == "-w")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
185 // Write entire history.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
186 command_history::write ();
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 641
diff changeset
187
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
188 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
189 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
190 // Read entire file.
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
191 command_history::read ();
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
192 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
193 }
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 641
diff changeset
194
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
195 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
196 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
197 // 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
198 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
199 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
200 }
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 641
diff changeset
201
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
202 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
203 panic_impossible ();
2435
3be97fe02051 [project @ 1996-10-27 21:31:29 by jwe]
jwe
parents: 2434
diff changeset
204
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
205 return hlist;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
206 }
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
207 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
208 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
209 command_history::clear ();
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
210 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
211 }
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
212 else if (option == "-q")
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
213 numbered_output = false;
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
214 else if (option == "--")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
215 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
216 i++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
217 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
218 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
219 else
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
220 {
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
221 // 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
222 // an integer will be used
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
223 int tmp;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
224
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
225 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
226 {
2a81ce01c383 Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents: 16196
diff changeset
227 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
228 limit = tmp;
2a81ce01c383 Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents: 16196
diff changeset
229 else
2a81ce01c383 Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents: 16196
diff changeset
230 limit = -tmp;
2a81ce01c383 Fix history() so that it shows all commands when called with no arguments.
Rik <rik@octave.org>
parents: 16196
diff changeset
231 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
232
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
233 else
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
234 {
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
235 if (option.length () > 0 && option[0] == '-')
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
236 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
237 else
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
238 error ("history: bad non-numeric arg '%s'", option.c_str ());
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
239 }
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
240 }
15817
dbb7896f15c7 Fix argument passing to history() command
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15814
diff changeset
241 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
242
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
243 hlist = command_history::list (limit, numbered_output);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
244
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
245 int len = hlist.numel ();
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
246
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
247 if (nargout == 0)
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
248 {
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
249 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
250 octave_stdout << hlist[i] << "\n";
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
251 }
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
252
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
253 return hlist;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
254 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
255
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
256 // Read the edited history lines from STREAM and return them
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
257 // one at a time. This can read unlimited length lines. The
2434
ced642d8ba6a [project @ 1996-10-27 04:42:08 by jwe]
jwe
parents: 2205
diff changeset
258 // caller should free the storage.
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
259
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
260 static char *
3551
4833e231e05b [project @ 2000-02-03 02:30:44 by jwe]
jwe
parents: 3544
diff changeset
261 edit_history_readline (std::fstream& stream)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
262 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
263 char c;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
264 int line_len = 128;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
265 int lindex = 0;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
266 char *line = new char [line_len];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
267 line[0] = '\0';
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
269 while (stream.get (c))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
270 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271 if (lindex + 2 >= line_len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
272 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
273 char *tmp_line = new char [line_len += 128];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
274 strcpy (tmp_line, line);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
275 delete [] line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
276 line = tmp_line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
277 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
278
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
279 if (c == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
280 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
281 line[lindex++] = '\n';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
282 line[lindex++] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
283 return line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
284 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
285 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
286 line[lindex++] = c;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
287 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
288
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
289 if (! lindex)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
290 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
291 delete [] line;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
292 return 0;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
293 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
294
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
295 if (lindex + 2 >= line_len)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
296 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
297 char *tmp_line = new char [lindex+3];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
298 strcpy (tmp_line, line);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
299 delete [] line;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
300 line = tmp_line;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
301 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
302
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
303 // Finish with newline if none in file.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
304
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
305 line[lindex++] = '\n';
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
306 line[lindex++] = '\0';
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
307 return line;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
308 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
310 static void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
311 edit_history_add_hist (const std::string& line)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
312 {
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
313 if (! line.empty ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
315 std::string tmp = line;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
316
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
317 int len = tmp.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
318
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
319 if (len > 0 && tmp[len-1] == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
320 tmp.resize (len - 1);
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
321
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
322 if (! tmp.empty ())
17219
33ce8c381f2c make history widget respect history_control settings (bug #39728)
Torsten <ttl@justmail.de>
parents: 17215
diff changeset
323 if (command_history::add (tmp))
17215
7c06875c2dcc Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents: 17214
diff changeset
324 octave_link::append_history (tmp);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
326 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
327
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
328 static bool
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
329 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
330 {
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
331 bool ok = true;
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
332
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
333 if (arg.is_string ())
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
334 {
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
335 std::string tmp = arg.string_value ();
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
336
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
337 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
338 }
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
339 else if (arg.is_numeric_type ())
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
340 val = arg.int_value ();
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
341 else
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
342 ok = false;
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 return ok;
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
345 }
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
346
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
347 static std::string
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
348 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
349 bool insert_curr, const char *warn_for)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
350 {
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2897
diff changeset
351 string_vector hlist = command_history::list ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
352
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
353 int hist_count = hlist.numel () - 1; // switch to zero-based indexing
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
354
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
355 // 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
356 // 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
357 // 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
358 // but the actual commands performed will.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
359
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
360 if (! insert_curr)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2897
diff changeset
361 command_history::remove (hist_count);
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1766
diff changeset
362
16022
d8f216d241cf Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents: 16016
diff changeset
363 hist_count--; // skip last entry in history list
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
364
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
365 // If no numbers have been specified, the default is to edit the
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
366 // last command in the history list.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
367
16022
d8f216d241cf Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents: 16016
diff changeset
368 int hist_beg = hist_count;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
369 int hist_end = hist_count;
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
370
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
371 bool reverse = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
372
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
373 // Process options.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
374
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
375 int nargin = args.length ();
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
376
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
377 if (nargin == 2)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
378 {
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
379 if (! get_int_arg (args(0), hist_beg)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
380 || ! get_int_arg (args(1), hist_end))
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
381 error ("%s: arguments must be integers", warn_for);
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
382
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
383 if (hist_beg < 0)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
384 hist_beg += (hist_count + 1);
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
385 else
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
386 hist_beg--;
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
387 if (hist_end < 0)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
388 hist_end += (hist_count + 1);
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
389 else
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
390 hist_end--;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
391 }
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
392 else if (nargin == 1)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
393 {
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
394 if (! get_int_arg (args(0), hist_beg))
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
395 error ("%s: argument must be an integer", warn_for);
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
396
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
397 if (hist_beg < 0)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
398 hist_beg += (hist_count + 1);
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
399 else
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
400 hist_beg--;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
401
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
402 hist_end = hist_beg;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
403 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
404
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
405 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
406 error ("%s: history specification out of range", warn_for);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
408 if (hist_end < hist_beg)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
409 {
16022
d8f216d241cf Fix off-by-1 error in run_history when called with no arguments.
Rik <rik@octave.org>
parents: 16016
diff changeset
410 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
411 reverse = true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
412 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
413
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
414 std::string name = octave_tempnam ("", "oct-");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415
3551
4833e231e05b [project @ 2000-02-03 02:30:44 by jwe]
jwe
parents: 3544
diff changeset
416 std::fstream file (name.c_str (), std::ios::out);
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
417
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
418 if (! file)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
419 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
420 name.c_str ());
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
421
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
422 if (reverse)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
423 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
424 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
425 file << hlist[i] << "\n";
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
426 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
427 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429 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
430 file << hlist[i] << "\n";
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
431 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
432
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
433 file.close ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
434
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
435 return name;
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
436 }
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
437
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
438 static void
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
439 unlink_cleanup (const char *file)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
440 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
441 gnulib::unlink (file);
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
442 }
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
443
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
444 static void
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
445 do_edit_history (const octave_value_list& args)
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
446 {
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
447 std::string name = mk_tmp_hist_file (args, false, "edit_history");
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
448
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
449 if (name.empty ())
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
450 return;
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
451
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
452 // Call up our favorite editor on the file of commands.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
453
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
454 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
455 cmd.append (" \"" + name + "\"");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
456
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
457 // Ignore interrupts while we are off editing commands. Should we
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
458 // maybe avoid using system()?
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
459
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2554
diff changeset
460 volatile octave_interrupt_handler old_interrupt_handler
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2492
diff changeset
461 = octave_ignore_interrupts ();
1443
cd6c9be7337c [project @ 1995-09-19 21:54:56 by jwe]
jwe
parents: 1363
diff changeset
462
15990
696e82182eba Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents: 15823
diff changeset
463 int status = system (cmd.c_str ());
1443
cd6c9be7337c [project @ 1995-09-19 21:54:56 by jwe]
jwe
parents: 1363
diff changeset
464
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2492
diff changeset
465 octave_set_interrupt_handler (old_interrupt_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
466
15990
696e82182eba Check if history edition was successful, abort operation on failure.
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents: 15823
diff changeset
467 // 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
468 // 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
469 if (status != EXIT_SUCCESS)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
470 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
471
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
472 // Write the commands to the history file since source_file
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
473 // disables command line history while it executes.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
474
3551
4833e231e05b [project @ 2000-02-03 02:30:44 by jwe]
jwe
parents: 3544
diff changeset
475 std::fstream file (name.c_str (), std::ios::in);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
476
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
477 char *line;
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
478 //int first = 1;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
479 while ((line = edit_history_readline (file)) != 0)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
480 {
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
481 // Skip blank lines.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
482
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
483 if (line[0] == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
484 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
485 delete [] line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
486 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
487 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
488
16051
3a06aa956d96 Fix off-by-1 error in history list when running 'edit_history'.
Rik <rik@octave.org>
parents: 16025
diff changeset
489 edit_history_add_hist (line);
16016
9194bb707d63 Plug memory leak in edit_history.
Rik <rik@octave.org>
parents: 15990
diff changeset
490
9194bb707d63 Plug memory leak in edit_history.
Rik <rik@octave.org>
parents: 15990
diff changeset
491 delete [] line;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
492 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
493
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
494 file.close ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
495
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
496 // Turn on command echo, so the output from this will make better
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
497 // sense.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
498
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
499 unwind_protect frame;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
500
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
501 frame.add_fcn (unlink_cleanup, name.c_str ());
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
502 frame.protect_var (Vecho_executing_commands);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
503 frame.protect_var (input_from_tmp_history_file);
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
504
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
505 Vecho_executing_commands = ECHO_CMD_LINE;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
506 input_from_tmp_history_file = true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
507
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
508 source_file (name);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
509 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
510
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
511 static void
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
512 do_run_history (const octave_value_list& args)
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
513 {
16243
428da5debfe4 maint: Remove commented out lines from history fix in changeset 2a81ce01c383.
Rik <rik@octave.org>
parents: 16242
diff changeset
514 std::string name = mk_tmp_hist_file (args, false, "run_history");
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
515
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
516 if (name.empty ())
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
517 return;
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
518
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
519 // Turn on command echo so the output from this will make better sense.
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
520
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
521 unwind_protect frame;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
522
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
523 frame.add_fcn (unlink_cleanup, name.c_str ());
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
524 frame.protect_var (Vecho_executing_commands);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
525 frame.protect_var (input_from_tmp_history_file);
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
526
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
527 Vecho_executing_commands = ECHO_CMD_LINE;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
528 input_from_tmp_history_file = true;
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
529
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
530 source_file (name);
64
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
531 }
bd04d91a7a4a [project @ 1993-08-15 05:08:48 by jwe]
jwe
parents: 1
diff changeset
532
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
533 void
8273
2c1ba965b486 skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
534 initialize_history (bool read_history_file)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
535 {
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
536 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
537 default_history_file (),
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
538 default_history_size (),
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
539 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
540
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
541 octave_link::set_history (command_history::list ());
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
542 }
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
543
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
544 void
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
545 octave_history_write_timestamp (void)
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
546 {
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
547 octave_localtime now;
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
548
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
549 std::string timestamp = now.strftime (Vhistory_timestamp_format_string);
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
550
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
551 if (! timestamp.empty ())
17219
33ce8c381f2c make history widget respect history_control settings (bug #39728)
Torsten <ttl@justmail.de>
parents: 17215
diff changeset
552 if (command_history::add (timestamp))
17215
7c06875c2dcc Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents: 17214
diff changeset
553 octave_link::append_history (timestamp);
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
554 }
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
555
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8286
diff changeset
556 DEFUN (edit_history, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
557 "-*- 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
558 @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
559 @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
560 @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
561 Edit the history list using the editor named by the variable @env{EDITOR}.\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
562 \n\
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
563 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
564 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
565 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
566 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
567 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
568 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
569 before leaving the editor.\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
570 \n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
571 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
572 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
573 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
574 @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
575 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
576 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
577 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
578 @example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
579 @group\n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
580 edit_history\n\
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
581 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
582 @end group\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
583 @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
584 \n\
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
585 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
586 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
587 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
588 @seealso{run_history, history}\n\
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
589 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
590 {
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
591 if (args.length () > 2)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
592 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
593
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
594 do_edit_history (args);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
595
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
596 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
597 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
598
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
599 DEFUN (history, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
600 "-*- 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
601 @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
602 @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
603 @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
604 @deftypefnx {} {@var{h} =} history (@var{opt1}, @dots{})\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
605 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
606 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
607 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
608 Valid options are:\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
609 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
610 @table @code\n\
16052
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
611 @item @var{n}\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
612 @itemx -@var{n}\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
613 Display only the most recent @var{n} lines of history.\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
614 \n\
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
615 @item -c\n\
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16243
diff changeset
616 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
617 \n\
16052
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
618 @item -q\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
619 Don't number the displayed lines of history. This is useful for cutting\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
620 and pasting commands using the X Window System.\n\
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
621 \n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
622 @item -r @var{file}\n\
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
623 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
624 history list. If the name is omitted, use the default history file\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
625 (normally @file{~/.octave_hist}).\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
626 \n\
16052
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
627 @item -w @var{file}\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
628 Write the current history to the file @var{file}. If the name is\n\
a59cb5c06d79 doc: Update history() docstring.
Rik <rik@octave.org>
parents: 16051
diff changeset
629 omitted, use the default history file (normally @file{~/.octave_hist}).\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
630 @end table\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
631 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
632 For example, to display the five most recent commands that you have\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
633 typed without displaying line numbers, use the command\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
634 @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
635 \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
636 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
637 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
638 @seealso{edit_history, run_history}\n\
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
639 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
640 {
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
641 // Call do_history even if nargout is zero to display history list.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
642
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
643 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
644
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
645 return nargout > 0 ? ovl (Cell (hlist)) : ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
646 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
647
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8286
diff changeset
648 DEFUN (run_history, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
649 "-*- 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
650 @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
651 @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
652 @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
653 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
654 \n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
655 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
656 \n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
657 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
658 \n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
659 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
660 @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
661 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
662 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
663 @example\n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
664 @group\n\
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
665 run_history\n\
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
666 OR\n\
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
667 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
668 @end group\n\
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
669 @end example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
670 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
671 @noindent\n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
672 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
673 The command\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
674 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
675 @example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
676 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
677 @end example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
678 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
679 @noindent\n\
16189
2825897a0c27 doc: Fix docstrings for edit_history, run_history to match true behavior.
Rik <rik@octave.org>
parents: 16188
diff changeset
680 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
681 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
682 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
683 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
684 For example:\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
685 \n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
686 @example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
687 @group\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
688 disp (1)\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
689 disp (2)\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
690 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
691 @result{}\n\
16188
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
692 2\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
693 1\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
694 @end group\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
695 @end example\n\
8366bc871d45 Allow negative numbers to be used in specifying edit_history commands.
Rik <rik@octave.org>
parents: 16052
diff changeset
696 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
697 @seealso{edit_history, history}\n\
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
698 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
699 {
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
700 if (args.length () > 2)
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
701 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
702
15823
bc7a130bbdfb allow history commands to take numeric arguments
John W. Eaton <jwe@octave.org>
parents: 15817
diff changeset
703 do_run_history (args);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
704
20983
004fa31be0b7 use print_usage instead of usage
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
705 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
706 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 296
diff changeset
707
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
708 DEFUN (history_control, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
709 "-*- 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
710 @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
711 @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
712 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
713 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
714 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
715 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
716 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
717 \n\
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
718 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
719 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
720 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
721 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
722 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
723 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
724 @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
725 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
726 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
727 @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
728 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
729 @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
730 @end deftypefn")
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
731 {
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
732 octave_value retval;
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
733
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
734 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
735
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
736 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
737
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
738 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
739
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
740 if (tmp != old_history_control)
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
741 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
742
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
743 return retval;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
744 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11405
diff changeset
745
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
746 DEFUN (history_size, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
747 "-*- 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
748 @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
749 @deftypefnx {} {@var{old_val} =} history_size (@var{new_val})\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
750 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
751 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
752 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
753 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
754 variable @w{@env{OCTAVE_HISTSIZE}}.\n\
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
755 @seealso{history_file, history_timestamp_format_string, history_save}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
756 @end deftypefn")
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
757 {
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
758 octave_value retval;
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
759
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
760 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
761
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
762 int tmp = old_history_size;
5800
e8be7fe586f9 [project @ 2006-05-10 06:50:45 by jwe]
jwe
parents: 5794
diff changeset
763
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
764 retval = set_internal_variable (tmp, args, nargout,
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
765 "history_size", -1,
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
766 std::numeric_limits<int>::max ());
5800
e8be7fe586f9 [project @ 2006-05-10 06:50:45 by jwe]
jwe
parents: 5794
diff changeset
767
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
768 if (tmp != old_history_size)
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
769 command_history::set_size (tmp);
5800
e8be7fe586f9 [project @ 2006-05-10 06:50:45 by jwe]
jwe
parents: 5794
diff changeset
770
e8be7fe586f9 [project @ 2006-05-10 06:50:45 by jwe]
jwe
parents: 5794
diff changeset
771 return retval;
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
772 }
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
773
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
774 DEFUN (history_file, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
775 "-*- 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
776 @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
777 @deftypefnx {} {@var{old_val} =} history_file (@var{new_val})\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
778 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
779 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
780 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
781 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
782 environment variable @w{@env{OCTAVE_HISTFILE}}.\n\
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
783 @seealso{history_size, history_save, history_timestamp_format_string}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
784 @end deftypefn")
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
785 {
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
786 octave_value retval;
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
787
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
788 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
789
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
790 std::string tmp = old_history_file;
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
791
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
792 retval = set_internal_variable (tmp, args, nargout, "history_file");
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
793
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
794 if (tmp != old_history_file)
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
795 command_history::set_file (tmp);
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
796
5800
e8be7fe586f9 [project @ 2006-05-10 06:50:45 by jwe]
jwe
parents: 5794
diff changeset
797 return retval;
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
798 }
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
799
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
800 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
801 "-*- 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
802 @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
803 @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
804 @deftypefnx {} {} history_timestamp_format_string (@var{new_val}, \"local\")\n\
6653
673686daec87 [project @ 2007-05-22 15:36:09 by jwe]
jwe
parents: 6615
diff changeset
805 Query or set the internal variable that specifies the format string\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
806 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
807 exits.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
808 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
809 The format string is passed to @code{strftime}. The default value is\n\
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
810 \n\
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
811 @example\n\
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
812 \"# Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>\"\n\
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
813 @end example\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12990
diff changeset
814 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17219
diff changeset
815 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
816 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
817 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
818 @seealso{strftime, history_file, history_size, history_save}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
819 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
820 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
821 return SET_INTERNAL_VARIABLE (history_timestamp_format_string);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
822 }
5305
539428e4606a [project @ 2005-04-26 02:59:08 by jwe]
jwe
parents: 4469
diff changeset
823
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
824 DEFUN (history_save, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
825 "-*- 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
826 @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
827 @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
828 @deftypefnx {} {} history_save (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
829 Query or set the internal variable that controls whether commands entered\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
830 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
831 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17219
diff changeset
832 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
833 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
834 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
835 @seealso{history_control, history_file, history_size, history_timestamp_format_string}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
836 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
837 {
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
838 octave_value retval;
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
839
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
840 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
841
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
842 bool tmp = old_history_save;
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
843
17345
91691d74845d oct-hist.cc: Wrap code lines > 80 characters.
Rik <rik@octave.org>
parents: 17281
diff changeset
844 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
845
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16687
diff changeset
846 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
847 command_history::ignore_entries (! tmp);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
848
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
849 return retval;
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 2985
diff changeset
850 }