annotate liboctave/util/cmd-edit.cc @ 17769:49a5a4be04a1

maint: Use GNU style coding conventions for code in liboctave/ * liboctave/array/Array-C.cc, liboctave/array/Array-b.cc, liboctave/array/Array-ch.cc, liboctave/array/Array-d.cc, liboctave/array/Array-f.cc, liboctave/array/Array-fC.cc, liboctave/array/Array-util.cc, liboctave/array/Array-util.h, liboctave/array/Array.cc, liboctave/array/Array.h, liboctave/array/Array3.h, liboctave/array/CColVector.cc, liboctave/array/CColVector.h, liboctave/array/CDiagMatrix.cc, liboctave/array/CDiagMatrix.h, liboctave/array/CMatrix.cc, liboctave/array/CMatrix.h, liboctave/array/CNDArray.cc, liboctave/array/CNDArray.h, liboctave/array/CRowVector.cc, liboctave/array/CRowVector.h, liboctave/array/CSparse.cc, liboctave/array/CSparse.h, liboctave/array/DiagArray2.h, liboctave/array/MArray.cc, liboctave/array/MArray.h, liboctave/array/MDiagArray2.cc, liboctave/array/MDiagArray2.h, liboctave/array/MSparse.cc, liboctave/array/MSparse.h, liboctave/array/MatrixType.cc, liboctave/array/MatrixType.h, liboctave/array/PermMatrix.h, liboctave/array/Range.cc, liboctave/array/Range.h, liboctave/array/Sparse.cc, liboctave/array/Sparse.h, liboctave/array/boolMatrix.cc, liboctave/array/boolMatrix.h, liboctave/array/boolNDArray.cc, liboctave/array/boolNDArray.h, liboctave/array/boolSparse.cc, liboctave/array/boolSparse.h, liboctave/array/chMatrix.cc, liboctave/array/chMatrix.h, liboctave/array/chNDArray.cc, liboctave/array/chNDArray.h, liboctave/array/dColVector.h, liboctave/array/dDiagMatrix.cc, liboctave/array/dDiagMatrix.h, liboctave/array/dMatrix.cc, liboctave/array/dMatrix.h, liboctave/array/dNDArray.cc, liboctave/array/dNDArray.h, liboctave/array/dRowVector.h, liboctave/array/dSparse.cc, liboctave/array/dSparse.h, liboctave/array/dim-vector.cc, liboctave/array/dim-vector.h, liboctave/array/fCColVector.cc, liboctave/array/fCColVector.h, liboctave/array/fCDiagMatrix.cc, liboctave/array/fCDiagMatrix.h, liboctave/array/fCMatrix.cc, liboctave/array/fCMatrix.h, liboctave/array/fCNDArray.cc, liboctave/array/fCNDArray.h, liboctave/array/fCRowVector.cc, liboctave/array/fCRowVector.h, liboctave/array/fColVector.h, liboctave/array/fDiagMatrix.cc, liboctave/array/fDiagMatrix.h, liboctave/array/fMatrix.cc, liboctave/array/fMatrix.h, liboctave/array/fNDArray.cc, liboctave/array/fNDArray.h, liboctave/array/fRowVector.h, liboctave/array/idx-vector.cc, liboctave/array/idx-vector.h, liboctave/array/intNDArray.cc, liboctave/array/intNDArray.h, liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/quit.cc, liboctave/numeric/CmplxCHOL.cc, liboctave/numeric/CmplxCHOL.h, liboctave/numeric/CmplxGEPBAL.cc, liboctave/numeric/CmplxGEPBAL.h, liboctave/numeric/CmplxHESS.h, liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxLU.h, liboctave/numeric/CmplxQR.cc, liboctave/numeric/CmplxQRP.cc, liboctave/numeric/CmplxQRP.h, liboctave/numeric/CmplxSCHUR.h, liboctave/numeric/CmplxSVD.cc, liboctave/numeric/CmplxSVD.h, liboctave/numeric/CollocWt.h, liboctave/numeric/DAE.h, liboctave/numeric/DAEFunc.h, liboctave/numeric/DAERT.h, liboctave/numeric/DAERTFunc.h, liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc, liboctave/numeric/DASRT.h, liboctave/numeric/DASSL.cc, liboctave/numeric/DET.h, liboctave/numeric/EIG.cc, liboctave/numeric/EIG.h, liboctave/numeric/LSODE.cc, liboctave/numeric/ODE.h, liboctave/numeric/ODEFunc.h, liboctave/numeric/ODES.h, liboctave/numeric/ODESFunc.h, liboctave/numeric/Quad.cc, liboctave/numeric/Quad.h, liboctave/numeric/SparseCmplxCHOL.h, liboctave/numeric/SparseCmplxLU.cc, liboctave/numeric/SparseCmplxLU.h, liboctave/numeric/SparseCmplxQR.cc, liboctave/numeric/SparseCmplxQR.h, liboctave/numeric/SparseQR.cc, liboctave/numeric/SparseQR.h, liboctave/numeric/SparsedbleCHOL.h, liboctave/numeric/SparsedbleLU.cc, liboctave/numeric/SparsedbleLU.h, liboctave/numeric/base-aepbal.h, liboctave/numeric/base-dae.h, liboctave/numeric/base-de.h, liboctave/numeric/base-lu.cc, liboctave/numeric/base-lu.h, liboctave/numeric/base-min.h, liboctave/numeric/base-qr.h, liboctave/numeric/bsxfun.h, liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleCHOL.h, liboctave/numeric/dbleGEPBAL.h, liboctave/numeric/dbleHESS.h, liboctave/numeric/dbleLU.cc, liboctave/numeric/dbleLU.h, liboctave/numeric/dbleQR.cc, liboctave/numeric/dbleQRP.cc, liboctave/numeric/dbleQRP.h, liboctave/numeric/dbleSCHUR.cc, liboctave/numeric/dbleSCHUR.h, liboctave/numeric/dbleSVD.cc, liboctave/numeric/dbleSVD.h, liboctave/numeric/eigs-base.cc, liboctave/numeric/fCmplxAEPBAL.cc, liboctave/numeric/fCmplxAEPBAL.h, liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxCHOL.h, liboctave/numeric/fCmplxGEPBAL.cc, liboctave/numeric/fCmplxGEPBAL.h, liboctave/numeric/fCmplxHESS.h, liboctave/numeric/fCmplxLU.cc, liboctave/numeric/fCmplxLU.h, liboctave/numeric/fCmplxQR.cc, liboctave/numeric/fCmplxQR.h, liboctave/numeric/fCmplxQRP.cc, liboctave/numeric/fCmplxQRP.h, liboctave/numeric/fCmplxSCHUR.cc, liboctave/numeric/fCmplxSCHUR.h, liboctave/numeric/fCmplxSVD.h, liboctave/numeric/fEIG.cc, liboctave/numeric/fEIG.h, liboctave/numeric/floatCHOL.cc, liboctave/numeric/floatCHOL.h, liboctave/numeric/floatGEPBAL.cc, liboctave/numeric/floatGEPBAL.h, liboctave/numeric/floatHESS.h, liboctave/numeric/floatLU.cc, liboctave/numeric/floatLU.h, liboctave/numeric/floatQR.cc, liboctave/numeric/floatQRP.cc, liboctave/numeric/floatQRP.h, liboctave/numeric/floatSCHUR.cc, liboctave/numeric/floatSCHUR.h, liboctave/numeric/floatSVD.cc, liboctave/numeric/floatSVD.h, liboctave/numeric/lo-mappers.cc, liboctave/numeric/lo-mappers.h, liboctave/numeric/lo-specfun.cc, liboctave/numeric/lo-specfun.h, liboctave/numeric/oct-convn.cc, liboctave/numeric/oct-fftw.cc, liboctave/numeric/oct-fftw.h, liboctave/numeric/oct-norm.cc, liboctave/numeric/oct-rand.cc, liboctave/numeric/oct-rand.h, liboctave/numeric/randgamma.c, liboctave/numeric/randgamma.h, liboctave/numeric/randmtzig.c, liboctave/numeric/randpoisson.c, liboctave/numeric/randpoisson.h, liboctave/numeric/sparse-base-chol.h, liboctave/numeric/sparse-base-lu.h, liboctave/numeric/sparse-dmsolve.cc, liboctave/operators/Sparse-diag-op-defs.h, liboctave/operators/Sparse-op-defs.h, liboctave/operators/mx-inlines.cc, liboctave/system/dir-ops.h, liboctave/system/file-ops.cc, liboctave/system/file-stat.cc, liboctave/system/file-stat.h, liboctave/system/lo-sysdep.cc, liboctave/system/lo-sysdep.h, liboctave/system/mach-info.cc, liboctave/system/mach-info.h, liboctave/system/oct-env.cc, liboctave/system/oct-group.cc, liboctave/system/oct-syscalls.cc, liboctave/system/oct-syscalls.h, liboctave/system/oct-time.h, liboctave/system/tempname.c, liboctave/util/action-container.h, liboctave/util/base-list.h, liboctave/util/cmd-edit.cc, liboctave/util/cmd-edit.h, liboctave/util/cmd-hist.cc, liboctave/util/cmd-hist.h, liboctave/util/data-conv.cc, liboctave/util/data-conv.h, liboctave/util/kpse.cc, liboctave/util/lo-array-gripes.cc, liboctave/util/lo-cieee.c, liboctave/util/lo-regexp.cc, liboctave/util/lo-utils.cc, liboctave/util/oct-alloc.cc, liboctave/util/oct-base64.cc, liboctave/util/oct-binmap.h, liboctave/util/oct-cmplx.h, liboctave/util/oct-glob.cc, liboctave/util/oct-inttypes.cc, liboctave/util/oct-inttypes.h, liboctave/util/oct-locbuf.cc, liboctave/util/oct-locbuf.h, liboctave/util/oct-mem.h, liboctave/util/oct-mutex.cc, liboctave/util/oct-refcount.h, liboctave/util/oct-shlib.cc, liboctave/util/oct-shlib.h, liboctave/util/oct-sort.cc, liboctave/util/oct-sort.h, liboctave/util/pathsearch.cc, liboctave/util/pathsearch.h, liboctave/util/sparse-util.cc, liboctave/util/str-vec.cc, liboctave/util/str-vec.h, liboctave/util/unwind-prot.h, liboctave/util/url-transfer.cc, liboctave/util/url-transfer.h: Use GNU style coding conventions.
author Rik <rik@octave.org>
date Sat, 26 Oct 2013 18:57:05 -0700
parents d63878346099
children d7f642d68817 37159a873c96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1 /*
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17644
diff changeset
3 Copyright (C) 1996-2013 John W. Eaton
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
4
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
6
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
66ef74ee5d9f [project @ 1997-05-05 03:20:52 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: 6979
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: 6979
diff changeset
10 option) any later version.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
11
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
15 for more details.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
16
66ef74ee5d9f [project @ 1997-05-05 03:20:52 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: 6979
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: 6979
diff changeset
19 <http://www.gnu.org/licenses/>.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
20
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
21 */
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
22
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
25 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
26
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
27 #include <cstdlib>
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
28 #include <cstring>
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
29
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
30 #include <string>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
31
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
32 #include <sys/types.h>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
33 #include <unistd.h>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
34
5247
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
35 #include "quit.h"
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
36
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
37 #include "cmd-edit.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
38 #include "cmd-hist.h"
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
39 #include "file-ops.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
40 #include "lo-error.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
41 #include "lo-utils.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
42 #include "oct-env.h"
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
43 #include "oct-mutex.h"
3260
cd454a6fa1a4 [project @ 1999-08-02 21:55:15 by jwe]
jwe
parents: 3225
diff changeset
44 #include "oct-time.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
45 #include "singleton-cleanup.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
46
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
47 command_editor *command_editor::instance = 0;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
48
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
49 std::set<command_editor::startup_hook_fcn> command_editor::startup_hook_set;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
50
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
51 std::set<command_editor::pre_input_hook_fcn> command_editor::pre_input_hook_set;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
52
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
53 std::set<command_editor::event_hook_fcn> command_editor::event_hook_set;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
54
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
55 static octave_mutex event_hook_lock;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
56
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
57 #if defined (USE_READLINE)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
58
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
59 #include <cstdio>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
60 #include <cstdlib>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
61
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
62 #include "oct-rl-edit.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
63
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
64 class
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
65 gnu_readline : public command_editor
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
66 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
67 public:
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
68
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
69 typedef command_editor::startup_hook_fcn startup_hook_fcn;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
70
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
71 typedef command_editor::pre_input_hook_fcn pre_input_hook_fcn;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
72
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
73 typedef command_editor::event_hook_fcn event_hook_fcn;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
74
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
75 typedef command_editor::completion_fcn completion_fcn;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
76
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
77 gnu_readline (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
78
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
79 ~gnu_readline (void) { }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
80
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
81 void do_set_name (const std::string& n);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
82
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
83 std::string do_readline (const std::string& prompt, bool& eof);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
84
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
85 void do_set_input_stream (FILE *f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
86
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
87 FILE *do_get_input_stream (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
88
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
89 void do_set_output_stream (FILE *f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
90
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
91 FILE *do_get_output_stream (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
92
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
93 void do_redisplay (void);
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
94
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
95 int do_terminal_rows (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
96
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
97 int do_terminal_cols (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
98
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16535
diff changeset
99 void do_clear_screen (bool skip_redisplay);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
100
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
101 void do_resize_terminal (void);
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
102
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
103 std::string newline_chars (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
104
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
105 void do_restore_terminal_state (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
106
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
107 void do_blink_matching_paren (bool flag);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
108
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
109 void do_set_basic_word_break_characters (const std::string& s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
110
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
111 void do_set_completer_word_break_characters (const std::string& s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
112
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
113 void do_set_basic_quote_characters (const std::string& s);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
114
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
115 void do_set_filename_quote_characters (const std::string& s);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
116
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
117 void do_set_completer_quote_characters (const std::string& s);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
118
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
119 void do_set_completion_append_character (char c);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
120
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
121 void do_set_completion_function (completion_fcn f);
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
122
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
123 void do_set_quoting_function (quoting_fcn f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
124
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
125 void do_set_dequoting_function (dequoting_fcn f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
126
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
127 void do_set_char_is_quoted_function (char_is_quoted_fcn f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
128
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
129 void do_set_user_accept_line_function (user_accept_line_fcn f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
130
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
131 completion_fcn do_get_completion_function (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
132
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
133 quoting_fcn do_get_quoting_function (void) const;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
134
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
135 dequoting_fcn do_get_dequoting_function (void) const;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
136
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
137 char_is_quoted_fcn do_get_char_is_quoted_function (void) const;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
138
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
139 user_accept_line_fcn do_get_user_accept_line_function (void) const;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
140
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
141 string_vector
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
142 do_generate_filename_completions (const std::string& text);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
143
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
144 std::string do_get_line_buffer (void) const;
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
145
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
146 std::string do_get_current_line (void) const;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
147
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
148 void do_replace_line (const std::string& text, bool clear_undo);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
149
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
150 void do_insert_text (const std::string& text);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
151
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
152 void do_newline (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
153
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
154 void do_accept_line (void);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
155
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
156 bool do_undo (void);
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
157
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
158 void do_clear_undo_list (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
159
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
160 void set_startup_hook (startup_hook_fcn f);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
161
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
162 void restore_startup_hook (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
163
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
164 void set_pre_input_hook (pre_input_hook_fcn f);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
165
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
166 void restore_pre_input_hook (void);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
167
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
168 void set_event_hook (event_hook_fcn f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
169
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
170 void restore_event_hook (void);
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
171
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
172 void do_restore_event_hook (void);
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
173
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
174 void do_read_init_file (const std::string& file);
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
175
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
176 void do_re_read_init_file (void);
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
177
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
178 bool do_filename_completion_desired (bool);
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
179
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
180 bool do_filename_quoting_desired (bool);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
181
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
182 void do_interrupt (bool);
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
183
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
184 static int operate_and_get_next (int, int);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
185
3951
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
186 static int history_search_backward (int, int);
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
187
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
188 static int history_search_forward (int, int);
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
189
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
190 private:
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
191
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
192 startup_hook_fcn previous_startup_hook;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
193
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
194 pre_input_hook_fcn previous_pre_input_hook;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
195
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
196 event_hook_fcn previous_event_hook;
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
197
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
198 completion_fcn completion_function;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
199
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
200 quoting_fcn quoting_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
201
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
202 dequoting_fcn dequoting_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
203
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
204 char_is_quoted_fcn char_is_quoted_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
205
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
206 user_accept_line_fcn user_accept_line_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
207
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
208 static char *command_generator (const char *text, int state);
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
209
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
210 static char *command_quoter (char *text, int match_type, char *quote_pointer);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
211 static char *command_dequoter (char *text, int match_type);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
212
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
213 static int command_char_is_quoted (char *text, int index);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
214
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
215 static int command_accept_line (int count, int key);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
216
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
217 static char **command_completer (const char *text, int start, int end);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
218 };
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
219
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
220 gnu_readline::gnu_readline ()
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
221 : command_editor (), previous_startup_hook (0),
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
222 previous_pre_input_hook (0),
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
223 previous_event_hook (0), completion_function (0),
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
224 quoting_function (0), dequoting_function (0),
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
225 char_is_quoted_function (0), user_accept_line_function (0)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
226 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
227 // FIXME: need interface to rl_add_defun, rl_initialize, and
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
228 // a function to set rl_terminal_name
3225
7aae2c3636a7 [project @ 1998-12-04 23:20:12 by jwe]
jwe
parents: 3219
diff changeset
229
3520
b153b9fa7f1a [project @ 2000-02-02 06:04:27 by jwe]
jwe
parents: 3519
diff changeset
230 std::string term = octave_env::getenv ("TERM");
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
231
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
232 octave_rl_set_terminal_name (term.c_str ());
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
233
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
234 octave_rl_initialize ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
235
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
236 do_blink_matching_paren (true);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
237
5452
5a70e4162b25 [project @ 2005-09-16 15:11:12 by jwe]
jwe
parents: 5442
diff changeset
238 // Bind operate-and-get-next.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
239
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
240 octave_rl_add_defun ("operate-and-get-next",
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
241 gnu_readline::operate_and_get_next,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
242 octave_rl_ctrl ('O'));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
243
5452
5a70e4162b25 [project @ 2005-09-16 15:11:12 by jwe]
jwe
parents: 5442
diff changeset
244 // And the history search functions.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
245
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
246 octave_rl_add_defun ("history-search-backward",
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
247 gnu_readline::history_search_backward,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
248 octave_rl_meta ('P'));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
249
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
250 octave_rl_add_defun ("history-search-forward",
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
251 gnu_readline::history_search_forward,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
252 octave_rl_meta ('N'));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
253 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
254
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
255 void
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
256 gnu_readline::do_set_name (const std::string& nm)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
257 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
258 ::octave_rl_set_name (nm.c_str ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
259 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
260
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
261 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
262 gnu_readline::do_readline (const std::string& prompt, bool& eof)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
263 {
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
264 std::string retval;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
265
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
266 eof = false;
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
267
5247
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
268 char *line = 0;
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
269
5336
6ba182a85dea [project @ 2005-05-04 18:12:16 by jwe]
jwe
parents: 5307
diff changeset
270 const char *p = prompt.c_str ();
6ba182a85dea [project @ 2005-05-04 18:12:16 by jwe]
jwe
parents: 5307
diff changeset
271
5452
5a70e4162b25 [project @ 2005-09-16 15:11:12 by jwe]
jwe
parents: 5442
diff changeset
272 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
5247
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
273
5336
6ba182a85dea [project @ 2005-05-04 18:12:16 by jwe]
jwe
parents: 5307
diff changeset
274 line = ::octave_rl_readline (p);
5247
3d5b7114da82 [project @ 2005-03-26 17:56:02 by jwe]
jwe
parents: 4663
diff changeset
275
5452
5a70e4162b25 [project @ 2005-09-16 15:11:12 by jwe]
jwe
parents: 5442
diff changeset
276 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
277
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
278 if (line)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
279 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
280 retval = line;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
281
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
282 free (line);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
283 }
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
284 else
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
285 eof = true;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
286
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
287 return retval;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
288 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
289
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
290 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
291 gnu_readline::do_set_input_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
292 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
293 ::octave_rl_set_input_stream (f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
294 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
295
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
296 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
297 gnu_readline::do_get_input_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
298 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
299 return ::octave_rl_get_input_stream ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
300 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
301
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
302 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
303 gnu_readline::do_set_output_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
304 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
305 ::octave_rl_set_output_stream (f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
306 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
307
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
308 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
309 gnu_readline::do_get_output_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
310 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
311 return ::octave_rl_get_output_stream ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
312 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
313
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
314 void
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
315 gnu_readline::do_redisplay (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
316 {
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
317 ::octave_rl_redisplay ();
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
318 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
319
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
320 // GNU readline handles SIGWINCH, so these values have a good chance
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
321 // of being correct even if the window changes size (they may be
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
322 // wrong if, for example, the luser changes the window size while the
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
323 // pager is running, and the signal is handled by the pager instead of
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
324 // us.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
325
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
326 int
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
327 gnu_readline::do_terminal_rows (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
328 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
329 int sh = ::octave_rl_screen_height ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
330
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
331 return sh > 0 ? sh : 24;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
332 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
333
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
334 int
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
335 gnu_readline::do_terminal_cols (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
336 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
337 int sw = ::octave_rl_screen_width ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
338
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
339 return sw > 0 ? sw : 80;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
340 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
341
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
342 void
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16535
diff changeset
343 gnu_readline::do_clear_screen (bool skip_redisplay)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
344 {
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16535
diff changeset
345 ::octave_rl_clear_screen (skip_redisplay);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
346 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
347
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
348 void
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
349 gnu_readline::do_resize_terminal (void)
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
350 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
351 ::octave_rl_resize_terminal ();
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
352 }
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
353
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
354 std::string
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
355 gnu_readline::newline_chars (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
356 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
357 return "\r\n";
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
358 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
359
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
360 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
361 gnu_readline::do_restore_terminal_state (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
362 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
363 ::octave_rl_restore_terminal_state ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
364 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
365
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
366 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
367 gnu_readline::do_blink_matching_paren (bool flag)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
368 {
3779
3001e15555e9 [project @ 2001-02-07 04:47:51 by jwe]
jwe
parents: 3520
diff changeset
369 ::octave_rl_enable_paren_matching (flag ? 1 : 0);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
370 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
371
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
372 void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
373 gnu_readline::do_set_basic_word_break_characters (const std::string& s)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
374 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
375 ::octave_rl_set_basic_word_break_characters (s.c_str ());
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
376 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
377
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
378 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
379 gnu_readline::do_set_completer_word_break_characters (const std::string& s)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
380 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
381 ::octave_rl_set_completer_word_break_characters (s.c_str ());
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
382 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
383
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
384 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
385 gnu_readline::do_set_basic_quote_characters (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
386 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
387 ::octave_rl_set_basic_quote_characters (s.c_str ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
388 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
389
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
390 void
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
391 gnu_readline::do_set_filename_quote_characters (const std::string& s)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
392 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
393 ::octave_rl_set_filename_quote_characters (s.c_str ());
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
394 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
395
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
396 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
397 gnu_readline::do_set_completer_quote_characters (const std::string& s)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
398 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
399 ::octave_rl_set_completer_quote_characters (s.c_str ());
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
400 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
401
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
402 void
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
403 gnu_readline::do_set_completion_append_character (char c)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
404 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
405 ::octave_rl_set_completion_append_character (c);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
406 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
407
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
408 void
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
409 gnu_readline::do_set_completion_function (completion_fcn f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
410 {
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
411 completion_function = f;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
412
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
413 rl_attempted_completion_fcn_ptr fp
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
414 = f ? gnu_readline::command_completer : 0;
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
415
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
416 ::octave_rl_set_completion_function (fp);
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
417 }
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
418
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
419 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
420 gnu_readline::do_set_quoting_function (quoting_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
421 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
422 quoting_function = f;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
423
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
424 rl_quoting_fcn_ptr fp
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
425 = f ? gnu_readline::command_quoter : 0;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
426
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
427 ::octave_rl_set_quoting_function (fp);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
428 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
429
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
430 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
431 gnu_readline::do_set_dequoting_function (dequoting_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
432 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
433 dequoting_function = f;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
434
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
435 rl_dequoting_fcn_ptr fp
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
436 = f ? gnu_readline::command_dequoter : 0;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
437
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
438 ::octave_rl_set_dequoting_function (fp);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
439 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
440
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
441 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
442 gnu_readline::do_set_char_is_quoted_function (char_is_quoted_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
443 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
444 char_is_quoted_function = f;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
445
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
446 rl_char_is_quoted_fcn_ptr fp
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
447 = f ? gnu_readline::command_char_is_quoted : 0;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
448
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
449 ::octave_rl_set_char_is_quoted_function (fp);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
450 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
451
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
452 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
453 gnu_readline::do_set_user_accept_line_function (user_accept_line_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
454 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
455 user_accept_line_function = f;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
456
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
457 if (f)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
458 octave_rl_add_defun ("accept-line", gnu_readline::command_accept_line,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
459 ::octave_rl_ctrl ('M'));
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
460 else
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
461 octave_rl_add_defun ("accept-line", ::octave_rl_newline,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
462 ::octave_rl_ctrl ('M'));
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
463 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
464
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
465 gnu_readline::completion_fcn
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
466 gnu_readline::do_get_completion_function (void) const
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
467 {
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
468 return completion_function;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
469 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
470
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
471 gnu_readline::quoting_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
472 gnu_readline::do_get_quoting_function (void) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
473 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
474 return quoting_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
475 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
476
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
477 gnu_readline::dequoting_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
478 gnu_readline::do_get_dequoting_function (void) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
479 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
480 return dequoting_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
481 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
482
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
483 gnu_readline::char_is_quoted_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
484 gnu_readline::do_get_char_is_quoted_function (void) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
485 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
486 return char_is_quoted_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
487 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
488
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
489 gnu_readline::user_accept_line_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
490 gnu_readline::do_get_user_accept_line_function (void) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
491 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
492 return user_accept_line_function;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
493 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
494
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
495 string_vector
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
496 gnu_readline::do_generate_filename_completions (const std::string& text)
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
497 {
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
498 string_vector retval;
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
499
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
500 int n = 0;
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
501 int count = 0;
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
502
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
503 char *fn = 0;
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
504
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
505 while (1)
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
506 {
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
507 fn = ::octave_rl_filename_completion_function (text.c_str (), count);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
508
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
509 if (fn)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
510 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
511 if (count == n)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
512 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
513 // Famous last words: Most large directories will not
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
514 // have more than a few hundred files, so we should not
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
515 // resize too many times even if the growth is linear...
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
516
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
517 n += 100;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
518 retval.resize (n);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
519 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
520
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
521 retval[count++] = fn;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
522
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
523 free (fn);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
524 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
525 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
526 break;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
527 }
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
528
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
529 retval.resize (count);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
530
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
531 return retval;
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
532 }
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
533
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
534 std::string
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
535 gnu_readline::do_get_line_buffer (void) const
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
536 {
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
537 return ::octave_rl_line_buffer ();
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
538 }
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
539
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
540 std::string
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
541 gnu_readline::do_get_current_line (void) const
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
542 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
543 std::string retval;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
544 char *buf = ::octave_rl_copy_line ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
545 retval = buf;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
546 free (buf);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
547 return retval;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
548 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
549
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
550 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
551 gnu_readline::do_replace_line (const std::string& text, bool clear_undo)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
552 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
553 ::octave_rl_replace_line (text.c_str (), clear_undo);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
554 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
555
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
556 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
557 gnu_readline::do_insert_text (const std::string& text)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
558 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
559 ::octave_rl_insert_text (text.c_str ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
560 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
561
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
562 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
563 gnu_readline::do_newline (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
564 {
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
565 ::octave_rl_newline (1, '\n');
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
566 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
567
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
568 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
569 gnu_readline::do_accept_line (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
570 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
571 command_accept_line (1, '\n');
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
572 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
573
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
574 bool
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
575 gnu_readline::do_undo (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
576 {
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
577 return ::octave_rl_do_undo ();
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
578 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
579
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
580 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
581 gnu_readline::do_clear_undo_list ()
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
582 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
583 ::octave_rl_clear_undo_list ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
584 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
585
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
586 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
587 gnu_readline::set_startup_hook (startup_hook_fcn f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
588 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
589 previous_startup_hook = ::octave_rl_get_startup_hook ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
590
6917
58b1a9e96037 [project @ 2007-09-19 20:45:13 by jwe]
jwe
parents: 6916
diff changeset
591 if (f != previous_startup_hook)
58b1a9e96037 [project @ 2007-09-19 20:45:13 by jwe]
jwe
parents: 6916
diff changeset
592 ::octave_rl_set_startup_hook (f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
593 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
594
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
595 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
596 gnu_readline::restore_startup_hook (void)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
597 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
598 ::octave_rl_set_startup_hook (previous_startup_hook);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
599 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
600
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
601 void
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
602 gnu_readline::set_pre_input_hook (pre_input_hook_fcn f)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
603 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
604 previous_pre_input_hook = ::octave_rl_get_pre_input_hook ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
605
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
606 if (f != previous_pre_input_hook)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
607 ::octave_rl_set_pre_input_hook (f);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
608 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
609
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
610 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
611 gnu_readline::restore_pre_input_hook (void)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
612 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
613 ::octave_rl_set_pre_input_hook (previous_pre_input_hook);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
614 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
615
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
616 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
617 gnu_readline::set_event_hook (event_hook_fcn f)
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
618 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
619 previous_event_hook = octave_rl_get_event_hook ();
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
620
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
621 ::octave_rl_set_event_hook (f);
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
622 }
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
623
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
624 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
625 gnu_readline::restore_event_hook (void)
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
626 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
627 ::octave_rl_set_event_hook (previous_event_hook);
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
628 }
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
629
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
630 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
631 gnu_readline::do_read_init_file (const std::string& file)
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
632 {
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
633 ::octave_rl_read_init_file (file.c_str ());
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
634 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
635
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
636 void
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
637 gnu_readline::do_re_read_init_file (void)
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
638 {
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
639 ::octave_rl_re_read_init_file ();
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
640 }
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
641
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
642 bool
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
643 gnu_readline::do_filename_completion_desired (bool arg)
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
644 {
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
645 return ::octave_rl_filename_completion_desired (arg);
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
646 }
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
647
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
648 bool
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
649 gnu_readline::do_filename_quoting_desired (bool arg)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
650 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
651 return ::octave_rl_filename_quoting_desired (arg);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
652 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
653
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
654 void
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
655 gnu_readline::do_interrupt (bool arg)
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
656 {
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
657 ::octave_rl_done (arg);
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
658 }
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
659
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
660 int
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
661 gnu_readline::operate_and_get_next (int /* count */, int /* c */)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
662 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
663 // Accept the current line.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
664
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
665 command_editor::accept_line ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
666
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
667 // Find the current line, and find the next line to use.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
668
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
669 int x_where = command_history::where ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
670
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
671 int x_length = command_history::length ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
672
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
673 if ((command_history::is_stifled ()
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
674 && (x_length >= command_history::max_input_history ()))
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
675 || (x_where >= x_length - 1))
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
676 command_history::set_mark (x_where);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
677 else
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
678 command_history::set_mark (x_where + 1);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
679
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
680 command_editor::add_startup_hook (command_history::goto_mark);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
681
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
682 return 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
683 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
684
3951
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
685 int
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
686 gnu_readline::history_search_backward (int count, int c)
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
687 {
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
688 return octave_rl_history_search_backward (count, c);
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
689 }
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
690
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
691 int
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
692 gnu_readline::history_search_forward (int count, int c)
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
693 {
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
694 return octave_rl_history_search_forward (count, c);
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
695 }
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
696
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
697 char *
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
698 gnu_readline::command_generator (const char *text, int state)
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
699 {
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
700 char *retval = 0;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
701
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
702 completion_fcn f = command_editor::get_completion_function ();
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
703
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
704 std::string tmp = f (text, state);
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
705
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
706 size_t len = tmp.length ();
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
707
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
708 if (len > 0)
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
709 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
710 retval = static_cast<char *> (gnulib::malloc (len+1));
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
711
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
712 strcpy (retval, tmp.c_str ());
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
713 }
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
714
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
715 return retval;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
716 }
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
717
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
718 char *
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
719 gnu_readline::command_quoter (char *text, int matches, char *qcp)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
720 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
721 char *retval = 0;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
722
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
723 quoting_fcn f = command_editor::get_quoting_function ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
724
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
725 std::string tmp = f (text, matches, *qcp);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
726
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
727 size_t len = tmp.length ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
728
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
729 if (len > 0)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
730 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
731 retval = static_cast<char *> (gnulib::malloc (len+1));
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
732
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
733 strcpy (retval, tmp.c_str ());
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
734 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
735
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
736 return retval;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
737 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
738
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
739 char *
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
740 gnu_readline::command_dequoter (char *text, int quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
741 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
742 char *retval = 0;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
743
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
744 dequoting_fcn f = command_editor::get_dequoting_function ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
745
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
746 std::string tmp = f (text, quote);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
747
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
748 size_t len = tmp.length ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
749
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
750 if (len > 0)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
751 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
752 retval = static_cast<char *> (gnulib::malloc (len+1));
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
753
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
754 strcpy (retval, tmp.c_str ());
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
755 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
756
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
757 return retval;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
758 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
759
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
760 int
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
761 gnu_readline::command_char_is_quoted (char *text, int quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
762 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
763 char_is_quoted_fcn f = command_editor::get_char_is_quoted_function ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
764
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
765 return f (text, quote);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
766 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
767
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
768 int
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
769 gnu_readline::command_accept_line (int count, int key)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
770 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
771 user_accept_line_fcn f = command_editor::get_user_accept_line_function ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
772
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
773 if (f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
774 f (::octave_rl_line_buffer ());
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
775
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
776 ::octave_rl_redisplay ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
777
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
778 return ::octave_rl_newline (count, key);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
779 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
780
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
781 char **
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
782 gnu_readline::command_completer (const char *text, int, int)
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
783 {
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
784 char **matches = 0;
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
785 matches
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
786 = ::octave_rl_completion_matches (text, gnu_readline::command_generator);
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
787 return matches;
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
788 }
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
789
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
790 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
791
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
792 class
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
793 default_command_editor : public command_editor
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
794 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
795 public:
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
796
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
797 default_command_editor (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
798 : command_editor (), input_stream (stdin), output_stream (stdout) { }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
799
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
800 ~default_command_editor (void) { }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
801
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
802 std::string do_readline (const std::string& prompt, bool& eof);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
803
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
804 void do_set_input_stream (FILE *f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
805
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
806 FILE *do_get_input_stream (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
807
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
808 void do_set_output_stream (FILE *f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
809
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
810 FILE *do_get_output_stream (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
811
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
812 string_vector do_generate_filename_completions (const std::string& text);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
813
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
814 std::string do_get_line_buffer (void) const;
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
815
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
816 std::string do_get_current_line (void) const;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
817
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
818 void do_replace_line (const std::string& text, bool clear_undo);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
819
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
820 void do_insert_text (const std::string& text);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
821
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
822 void do_newline (void);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
823
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
824 void do_accept_line (void);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
825
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
826 private:
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
827
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
828 FILE *input_stream;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
829
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
830 FILE *output_stream;
12153
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
831
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
832 // No copying!
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
833
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
834 default_command_editor (const default_command_editor&);
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
835
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
836 default_command_editor& operator = (const default_command_editor&);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
837 };
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
838
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
839 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
840 default_command_editor::do_readline (const std::string& prompt, bool& eof)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
841 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
842 gnulib::fputs (prompt.c_str (), output_stream);
12912
e116dd862879 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12153
diff changeset
843 gnulib::fflush (output_stream);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
844
4527
c0a23a13eea2 [project @ 2003-10-03 02:52:46 by jwe]
jwe
parents: 4143
diff changeset
845 return octave_fgetl (input_stream, eof);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
846 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
847
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
848 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
849 default_command_editor::do_set_input_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
850 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
851 input_stream = f;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
852 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
853
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
854 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
855 default_command_editor::do_get_input_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
856 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
857 return input_stream;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
858 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
859
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
860 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
861 default_command_editor::do_set_output_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
862 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
863 output_stream = f;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
864 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
865
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
866 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
867 default_command_editor::do_get_output_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
868 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
869 return output_stream;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
870 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
871
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
872 string_vector
4663
bf7272f8ba8c [project @ 2003-11-25 06:05:20 by jwe]
jwe
parents: 4604
diff changeset
873 default_command_editor::do_generate_filename_completions (const std::string&)
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
874 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5452
diff changeset
875 // FIXME
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
876 return string_vector ();
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
877 }
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
878
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
879 std::string
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
880 default_command_editor::do_get_line_buffer (void) const
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
881 {
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
882 return "";
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
883 }
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
884
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
885 std::string
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
886 default_command_editor::do_get_current_line (void) const
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
887 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
888 // FIXME
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
889 return std::string ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
890 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
891
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
892 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
893 default_command_editor::do_replace_line (const std::string&, bool)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
894 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
895 // FIXME
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
896 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
897
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
898 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
899 default_command_editor::do_insert_text (const std::string&)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
900 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5452
diff changeset
901 // FIXME
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
902 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
903
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
904 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
905 default_command_editor::do_newline (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
906 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5452
diff changeset
907 // FIXME
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
908 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
909
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
910 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
911 default_command_editor::do_accept_line (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
912 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
913 // FIXME
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
914 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
915
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
916 bool
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
917 command_editor::instance_ok (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
918 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
919 bool retval = true;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
920
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
921 if (! instance)
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
922 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
923 make_command_editor ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
924
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
925 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
926 singleton_cleanup_list::add (cleanup_instance);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
927 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
928
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
929 if (! instance)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
930 {
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
931 current_liboctave_error_handler
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
932 ("unable to create command history object!");
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
933
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
934 retval = false;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
935 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
936
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
937 return retval;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
938 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
939
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
940 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
941 command_editor::make_command_editor (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
942 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
943 #if defined (USE_READLINE)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
944 instance = new gnu_readline ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
945 #else
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
946 instance = new default_command_editor ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
947 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
948 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
949
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
950 void
9321
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
951 command_editor::force_default_editor (void)
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
952 {
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
953 delete instance;
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
954 instance = new default_command_editor ();
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
955 }
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
956
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
957 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
958 command_editor::set_initial_input (const std::string& text)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
959 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
960 if (instance_ok ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
961 instance->initial_input = text;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
962 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
963
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
964 int
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
965 command_editor::insert_initial_input (void)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
966 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
967 return instance_ok () ? instance->do_insert_initial_input () : 0;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
968 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
969
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
970 int
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
971 command_editor::startup_handler (void)
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
972 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
973 for (startup_hook_set_iterator p = startup_hook_set.begin ();
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
974 p != startup_hook_set.end (); p++)
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
975 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
976 startup_hook_fcn f = *p;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
977
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
978 if (f)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
979 f ();
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
980 }
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
981
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
982 return 0;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
983 }
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
984
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
985 int
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
986 command_editor::pre_input_handler (void)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
987 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
988 for (pre_input_hook_set_iterator p = pre_input_hook_set.begin ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
989 p != pre_input_hook_set.end (); p++)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
990 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
991 pre_input_hook_fcn f = *p;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
992
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
993 if (f)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
994 f ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
995 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
996
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
997 return 0;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
998 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
999
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1000 int
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1001 command_editor::event_handler (void)
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1002 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1003 event_hook_lock.lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1004
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1005 std::set<event_hook_fcn> hook_set (event_hook_set);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1006
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1007 event_hook_lock.unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1008
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1009 for (event_hook_set_iterator p = hook_set.begin ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1010 p != hook_set.end (); p++)
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1011 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1012 event_hook_fcn f = *p;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1013
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1014 if (f)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1015 f ();
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1016 }
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1017
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1018 return 0;
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1019 }
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1020
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1021 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1022 command_editor::set_name (const std::string& n)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1023 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1024 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1025 instance->do_set_name (n);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1026 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1027
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1028 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1029 command_editor::readline (const std::string& prompt)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1030 {
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1031 bool eof;
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1032
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1033 return readline (prompt, eof);
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1034 }
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1035
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1036 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1037 command_editor::readline (const std::string& prompt, bool& eof)
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1038 {
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1039 std::string retval;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1040
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1041 if (instance_ok ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1042 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1043 if (! instance->initial_input.empty ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1044 add_pre_input_hook (command_editor::insert_initial_input);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1045
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1046 retval = instance->do_readline (prompt, eof);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1047 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1048
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1049 return retval;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1050 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1051
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1052 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1053 command_editor::set_input_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1054 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1055 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1056 instance->do_set_input_stream (f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1057 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1058
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1059 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1060 command_editor::get_input_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1061 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1062 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1063 ? instance->do_get_input_stream () : 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1064 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1065
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1066 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1067 command_editor::set_output_stream (FILE *f)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1068 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1069 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1070 instance->do_set_output_stream (f);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1071 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1072
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1073 FILE *
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1074 command_editor::get_output_stream (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1075 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1076 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1077 ? instance->do_get_output_stream () : 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1078 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1079
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1080 void
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1081 command_editor::redisplay (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1082 {
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1083 if (instance_ok ())
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1084 instance->do_redisplay ();
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1085 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1086
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1087 int
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1088 command_editor::terminal_rows (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1089 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1090 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1091 ? instance->do_terminal_rows () : -1;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1092 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1093
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1094 int
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1095 command_editor::terminal_cols (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1096 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1097 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1098 ? instance->do_terminal_cols () : -1;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1099 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1100
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1101 void
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16535
diff changeset
1102 command_editor::clear_screen (bool skip_redisplay)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1103 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1104 if (instance_ok ())
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16535
diff changeset
1105 instance->do_clear_screen (skip_redisplay);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1106 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1107
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1108 void
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1109 command_editor::resize_terminal (void)
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1110 {
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1111 if (instance_ok ())
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1112 instance->do_resize_terminal ();
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1113 }
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1114
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1115 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1116 command_editor::decode_prompt_string (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1117 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1118 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1119 ? instance->do_decode_prompt_string (s) : std::string ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1120 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1121
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1122 int
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1123 command_editor::current_command_number (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1124 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1125 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1126 ? instance->command_number : 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1127 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1128
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1129 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1130 command_editor::reset_current_command_number (int n)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1131 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1132 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1133 instance->command_number = n;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1134 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1135
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1136 void
2967
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1137 command_editor::increment_current_command_number (void)
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1138 {
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1139 if (instance_ok ())
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1140 instance->command_number++;
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1141 }
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1142
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1143 void
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1144 command_editor::restore_terminal_state (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1145 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1146 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1147 instance->do_restore_terminal_state ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1148 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1149
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1150 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1151 command_editor::blink_matching_paren (bool flag)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1152 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1153 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1154 instance->do_blink_matching_paren (flag);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1155 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1156
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1157 void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1158 command_editor::set_basic_word_break_characters (const std::string& s)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1159 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1160 if (instance_ok ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1161 instance->do_set_basic_word_break_characters (s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1162 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1163
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1164 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1165 command_editor::set_completer_word_break_characters (const std::string& s)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1166 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1167 if (instance_ok ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1168 instance->do_set_completer_word_break_characters (s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1169 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1170
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1171 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1172 command_editor::set_basic_quote_characters (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1173 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1174 if (instance_ok ())
3004
9a54159563de [project @ 1997-05-23 05:00:49 by jwe]
jwe
parents: 2967
diff changeset
1175 instance->do_set_basic_quote_characters (s);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1176 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1177
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1178 void
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1179 command_editor::set_filename_quote_characters (const std::string& s)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1180 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1181 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1182 instance->do_set_filename_quote_characters (s);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1183 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1184
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1185 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1186 command_editor::set_completer_quote_characters (const std::string& s)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1187 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1188 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1189 instance->do_set_completer_quote_characters (s);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1190 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1191
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1192 void
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1193 command_editor::set_completion_append_character (char c)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1194 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1195 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1196 instance->do_set_completion_append_character (c);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1197 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1198
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1199 void
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1200 command_editor::set_completion_function (completion_fcn f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1201 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1202 if (instance_ok ())
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1203 instance->do_set_completion_function (f);
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1204 }
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1205
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1206 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1207 command_editor::set_quoting_function (quoting_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1208 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1209 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1210 instance->do_set_quoting_function (f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1211 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1212
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1213 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1214 command_editor::set_dequoting_function (dequoting_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1215 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1216 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1217 instance->do_set_dequoting_function (f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1218 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1219
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1220 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1221 command_editor::set_char_is_quoted_function (char_is_quoted_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1222 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1223 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1224 instance->do_set_char_is_quoted_function (f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1225 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1226
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1227 void
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1228 command_editor::set_user_accept_line_function (user_accept_line_fcn f)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1229 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1230 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1231 instance->do_set_user_accept_line_function (f);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1232 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1233
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1234 command_editor::completion_fcn
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1235 command_editor::get_completion_function (void)
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1236 {
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1237 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1238 ? instance->do_get_completion_function () : 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1239 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1240
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1241 command_editor::quoting_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1242 command_editor::get_quoting_function (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1243 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1244 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1245 ? instance->do_get_quoting_function () : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1246 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1247
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1248 command_editor::dequoting_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1249 command_editor::get_dequoting_function (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1250 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1251 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1252 ? instance->do_get_dequoting_function () : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1253 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1254
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1255 command_editor::char_is_quoted_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1256 command_editor::get_char_is_quoted_function (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1257 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1258 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1259 ? instance->do_get_char_is_quoted_function () : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1260 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1261
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1262 command_editor::user_accept_line_fcn
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1263 command_editor::get_user_accept_line_function (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1264 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1265 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1266 ? instance->do_get_user_accept_line_function () : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1267 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1268
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1269 string_vector
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1270 command_editor::generate_filename_completions (const std::string& text)
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1271 {
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1272 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1273 ? instance->do_generate_filename_completions (text) : string_vector ();
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1274 }
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1275
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1276 std::string
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1277 command_editor::get_line_buffer (void)
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1278 {
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1279 return (instance_ok ()) ? instance->do_get_line_buffer () : "";
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1280 }
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1281
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1282 std::string
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1283 command_editor::get_current_line (void)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1284 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1285 return (instance_ok ()) ? instance->do_get_current_line () : "";
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1286 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1287
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1288 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1289 command_editor::replace_line (const std::string& text, bool clear_undo)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1290 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1291 if (instance_ok ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1292 instance->do_replace_line (text, clear_undo);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1293 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1294
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1295 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1296 command_editor::insert_text (const std::string& text)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1297 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1298 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1299 instance->do_insert_text (text);
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1300 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1301
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1302 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1303 command_editor::newline (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1304 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1305 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1306 instance->do_newline ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1307 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1308
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1309 void
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1310 command_editor::accept_line (void)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1311 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1312 if (instance_ok ())
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1313 instance->do_accept_line ();
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1314 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1315
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1316 bool
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1317 command_editor::undo (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1318 {
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1319 return instance_ok () ? instance->do_undo () : false;
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1320 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1321
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1322 void
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1323 command_editor::clear_undo_list (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1324 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1325 if (instance_ok ())
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1326 instance->do_clear_undo_list ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1327 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1328
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1329 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1330 command_editor::add_startup_hook (startup_hook_fcn f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1331 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1332 if (instance_ok ())
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1333 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1334 startup_hook_set.insert (f);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1335
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1336 instance->set_startup_hook (startup_handler);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1337 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1338 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1339
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1340 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1341 command_editor::remove_startup_hook (startup_hook_fcn f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1342 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1343 if (instance_ok ())
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1344 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1345 startup_hook_set_iterator p = startup_hook_set.find (f);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1346
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1347 if (p != startup_hook_set.end ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1348 startup_hook_set.erase (p);
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1349
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1350 if (startup_hook_set.empty ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1351 instance->restore_startup_hook ();
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1352 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1353 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1354
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1355 void
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1356 command_editor::add_pre_input_hook (pre_input_hook_fcn f)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1357 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1358 if (instance_ok ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1359 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1360 pre_input_hook_set.insert (f);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1361
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1362 instance->set_pre_input_hook (pre_input_handler);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1363 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1364 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1365
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1366 void
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1367 command_editor::remove_pre_input_hook (pre_input_hook_fcn f)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1368 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1369 if (instance_ok ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1370 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1371 pre_input_hook_set_iterator p = pre_input_hook_set.find (f);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1372
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1373 if (p != pre_input_hook_set.end ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1374 pre_input_hook_set.erase (p);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1375
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1376 if (pre_input_hook_set.empty ())
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1377 instance->restore_pre_input_hook ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1378 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1379 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1380
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1381 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1382 command_editor::add_event_hook (event_hook_fcn f)
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1383 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1384 octave_autolock guard (event_hook_lock);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1385
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1386 if (instance_ok ())
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1387 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1388 event_hook_set.insert (f);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1389
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1390 instance->set_event_hook (event_handler);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1391 }
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1392 }
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1393
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1394 void
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1395 command_editor::remove_event_hook (event_hook_fcn f)
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1396 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1397 octave_autolock guard (event_hook_lock);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1398
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1399 if (instance_ok ())
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1400 {
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1401 event_hook_set_iterator p = event_hook_set.find (f);
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1402
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1403 if (p != event_hook_set.end ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1404 event_hook_set.erase (p);
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1405
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1406 if (event_hook_set.empty ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1407 instance->restore_event_hook ();
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1408 }
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1409 }
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1410
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1411 void
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1412 command_editor::run_event_hooks (void)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1413 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1414 event_handler ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1415 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1416
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1417 void
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1418 command_editor::read_init_file (const std::string& file_arg)
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1419 {
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1420 if (instance_ok ())
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1421 {
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1422 std::string file = file_ops::tilde_expand (file_arg);
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1423
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1424 instance->do_read_init_file (file);
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1425 }
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1426 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1427
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1428 void
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1429 command_editor::re_read_init_file (void)
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1430 {
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1431 if (instance_ok ())
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1432 instance->do_re_read_init_file ();
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1433 }
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1434
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1435 bool
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1436 command_editor::filename_completion_desired (bool arg)
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1437 {
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1438 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1439 ? instance->do_filename_completion_desired (arg) : false;
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1440 }
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1441
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1442 bool
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1443 command_editor::filename_quoting_desired (bool arg)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1444 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1445 return (instance_ok ())
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1446 ? instance->do_filename_quoting_desired (arg) : false;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1447 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1448
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1449 bool
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1450 command_editor::interrupt (bool arg)
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1451 {
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1452 bool retval;
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1453
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1454 if (instance_ok ())
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1455 {
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1456 // Return the current interrupt state.
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1457 retval = instance->interrupted;
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1458
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1459 instance->do_interrupt (arg);
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1460
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1461 instance->interrupted = arg;
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1462 }
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1463 else
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1464 retval = false;
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1465
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1466 return retval;
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1467 }
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1468
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1469 // Return a string which will be printed as a prompt. The string may
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1470 // contain special characters which are decoded as follows:
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1471 //
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1472 // \a bell (ascii 07)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1473 // \d the date
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1474 // \e escape (ascii 033)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1475 // \h the hostname up to the first '.'
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1476 // \H the hostname
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1477 // \n CRLF
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1478 // \r CR
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1479 // \s the name of the shell (program)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1480 // \t the time
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1481 // \T the time in 12-hour hh:mm:ss format
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1482 // \@ the time in 12-hour hh:mm am/pm format
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1483 // \A the time in 24-hour hh:mm format
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1484 // \u your username
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1485 // \w the current working directory
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1486 // \W the last element of PWD
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1487 // \! the history number of this command
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1488 // \# the command number of this command
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1489 // \$ a $ or a # if you are root
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1490 // \nnn character code nnn in octal
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1491 // \\ a backslash
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1492 // \[ begin a sequence of non-printing chars
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1493 // \] end a sequence of non-printing chars
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1494
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1495 std::string
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1496 command_editor::do_decode_prompt_string (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1497 {
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1498 std::string result;
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1499 std::string temp;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1500 size_t i = 0;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1501 size_t slen = s.length ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1502 int c;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1503
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1504 while (i < slen)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1505 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1506 c = s[i];
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1507
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1508 i++;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1509
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1510 if (c == '\\')
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1511 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1512 c = s[i];
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1513
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1514 switch (c)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1515 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1516 case '0':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1517 case '1':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1518 case '2':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1519 case '3':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1520 case '4':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1521 case '5':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1522 case '6':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1523 case '7':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1524 // Maybe convert an octal number.
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1525 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1526 int n = read_octal (s.substr (i, 3));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1527
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1528 temp = "\\";
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1529
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1530 if (n != -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1531 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1532 i += 3;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1533 temp[0] = n;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1534 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1535
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1536 c = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1537 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1538 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1539
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1540 case 'a':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1541 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1542 temp = '\a';
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1543
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1544 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1545 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1546
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1547 case 'e':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1548 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1549 temp = '\033';
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1550
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1551 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1552 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1553
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1554 case 'r':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1555 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1556 temp = '\r';
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1557
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1558 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1559 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1560
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1561 case 'd':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1562 case 't':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1563 case 'T':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1564 case '@':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1565 case 'A':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1566 // Make the current time/date into a string.
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1567 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1568 octave_localtime now;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1569
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1570 if (c == 'd')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1571 temp = now.strftime ("%a %b %d");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1572 else if (c == 't')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1573 temp = now.strftime ("%H:%M:%S");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1574 else if (c == 'T')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1575 temp = now.strftime ("%I:%M:%S");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1576 else if (c == '@')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1577 temp = now.strftime ("%I:%M %p");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1578 else if (c == 'A')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1579 temp = now.strftime ("%H:%M");
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1580
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1581 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1582 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1583
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1584 case 'n':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1585 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1586 temp = newline_chars ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1587
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1588 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1589 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1590
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1591 case 's':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1592 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1593 temp = octave_env::get_program_name ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1594 temp = octave_env::base_pathname (temp);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1595
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1596 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1597 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1598
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1599 case 'w':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1600 case 'W':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1601 {
17644
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1602 try
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1603 {
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1604 temp = octave_env::get_current_directory ();
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1605 }
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1606 catch (octave_execution_exception)
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1607 {
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1608 temp = "";
ca9a9c0740c5 Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents: 16570
diff changeset
1609 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1610
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1611 std::string home_dir = octave_env::get_home_directory ();
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1612
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1613 if (c == 'W' && (home_dir.empty () || temp != home_dir))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1614 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1615 if (temp != "/" && temp != "//")
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1616 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1617 size_t pos = temp.rfind ('/');
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1618
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1619 if (pos != std::string::npos && pos != 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1620 temp = temp.substr (pos + 1);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1621 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1622 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1623 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1624 temp = octave_env::polite_directory_format (temp);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1625
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1626 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1627 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1628
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1629 case 'u':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1630 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1631 temp = octave_env::get_user_name ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1632
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1633 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1634 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1635
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1636 case 'H':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1637 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1638 temp = octave_env::get_host_name ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1639
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1640 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1641 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1642
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1643 case 'h':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1644 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1645 temp = octave_env::get_host_name ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1646
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1647 size_t pos = temp.find ('.');
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1648
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1649 if (pos != std::string::npos)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1650 temp.resize (pos);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1651
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1652 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1653 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1654
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1655 case '#':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1656 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1657 char number_buffer[128];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1658 sprintf (number_buffer, "%d", command_number);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1659 temp = number_buffer;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1660
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1661 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1662 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1663
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1664 case '!':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1665 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1666 char number_buffer[128];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1667 int num = command_history::current_number ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1668 if (num > 0)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1669 sprintf (number_buffer, "%d", num);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1670 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1671 strcpy (number_buffer, "!");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1672 temp = number_buffer;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1673
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1674 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1675 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1676
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1677 case '$':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1678 {
4062
86e4baa81410 [project @ 2002-09-23 15:38:05 by jwe]
jwe
parents: 3970
diff changeset
1679 #if defined (HAVE_GETEUID)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1680 temp = (::geteuid () == 0 ? "#" : "$");
4062
86e4baa81410 [project @ 2002-09-23 15:38:05 by jwe]
jwe
parents: 3970
diff changeset
1681 #else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1682 temp = "$";
4062
86e4baa81410 [project @ 2002-09-23 15:38:05 by jwe]
jwe
parents: 3970
diff changeset
1683 #endif
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1684
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1685 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1686 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1687
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1688 #if defined (USE_READLINE)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1689 case '[':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1690 case ']':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1691 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1692 temp.resize (1);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1693
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1694 temp[0] = ((c == '[')
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1695 ? ::octave_rl_prompt_start_ignore ()
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1696 : ::octave_rl_prompt_end_ignore ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1697
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1698 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1699 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1700 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1701
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1702 case '\\':
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1703 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1704 temp = "\\";
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1705
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1706 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1707 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1708
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1709 default:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1710 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1711 temp = "\\ ";
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1712 temp[1] = c;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1713
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1714 goto add_string;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1715 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1716
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1717 add_string:
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1718 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1719 if (c)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1720 i++;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1721
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1722 result.append (temp);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1723
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1724 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1725 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1726 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1727 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1728 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1729 result += c;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1730 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1731
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1732 return result;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1733 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1734
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1735 int
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1736 command_editor::do_insert_initial_input (void)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1737 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1738 std::string input = initial_input;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1739
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1740 initial_input = "";
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1741
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1742 do_insert_text (input);
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1743
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1744 // Is it really right to redisplay here?
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1745 do_redisplay ();
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1746
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1747 return 0;
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1748 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1749
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1750 // Return the octal number parsed from STRING, or -1 to indicate that
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1751 // the string contained a bad number.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1752
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1753 int
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1754 command_editor::read_octal (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1755 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1756 int result = 0;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1757 int digits = 0;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1758
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1759 size_t i = 0;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1760 size_t slen = s.length ();
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1761
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1762 while (i < slen && s[i] >= '0' && s[i] < '8')
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1763 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1764 digits++;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1765 result = (result * 8) + s[i] - '0';
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1766 i++;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1767 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1768
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1769 if (! digits || result > 0777 || i < slen)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1770 result = -1;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1771
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1772 return result;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1773 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1774
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1775 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1776 command_editor::error (int err_num)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1777 {
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
1778 current_liboctave_error_handler ("%s", gnulib::strerror (err_num));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1779 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1780
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1781 void
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3281
diff changeset
1782 command_editor::error (const std::string& s)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1783 {
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1784 current_liboctave_error_handler ("%s", s.c_str ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1785 }