annotate liboctave/util/cmd-edit.cc @ 22868:87e3163f6c87

use c++11 "= default" syntax for declaration of trivial destructors * make_int.cc, Canvas.h, GenericEventNotify.h, TextEdit.h, gl-select.h, QTerminal.h, files-dock-widget.h, history-dock-widget.h, octave-cmd.h, octave-dock-widget.h, octave-interpreter.h, thread-manager.h, welcome-wizard.h, workspace-model.h, workspace-view.h, base-text-renderer.h, comment-list.h, debug.h, dynamic-ld.cc, dynamic-ld.h, ft-text-renderer.cc, gl-render.h, gl2ps-print.cc, graphics.in.h, hook-fcn.h, input.h, load-path.h, mxarray.in.h, oct-errno.h, oct-fstrm.h, oct-handle.h, oct-iostrm.h, oct-lvalue.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, pr-output.cc, procstream.h, sighandlers.cc, symtab.h, text-renderer.h, txt-eng.h, variables.cc, workspace-element.h, __init_fltk__.cc, __init_gnuplot__.cc, ov-base-diag.h, ov-base-int.h, ov-base-scalar.h, ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h, ov-intx.h, ov-lazy-idx.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h, ov-typeinfo.h, ov-usr-fcn.h, ovl.h, octave.h, lex.h, parse.h, pt-binop.h, pt-bp.h, pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-const.h, pt-decl.h, pt-eval.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-jump.h, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-unop.h, pt-walk.h, pt.h, DiagArray2.h, MArray.h, MDiagArray2.h, MSparse.h, idx-vector.h, quit.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.h, DASRT.h, DASSL.h, EIG.h, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, aepbalance.h, base-dae.h, base-de.h, base-min.h, fEIG.h, gepbalance.h, gsvd.h, hess.h, lu.h, oct-rand.h, oct-spparms.h, qr.h, qrp.h, schur.h, sparse-lu.h, svd.h, child-list.h, file-stat.h, oct-passwd.h, oct-time.h, oct-uname.h, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, glob-match.h, lo-array-errwarn.h, lo-regexp.h, oct-mutex.h, pathsearch.h, str-vec.h, url-transfer.h:
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2016 10:59:29 -0500
parents 89756f2f085b
children f75d289645ec
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
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22171
diff changeset
3 Copyright (C) 1996-2016 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
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
2926
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
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
2926
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 "cmd-edit.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
33 #include "cmd-hist.h"
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
34 #include "file-ops.h"
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
35 #include "file-stat.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
36 #include "lo-error.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
37 #include "lo-utils.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
38 #include "oct-env.h"
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
39 #include "oct-mutex.h"
3260
cd454a6fa1a4 [project @ 1999-08-02 21:55:15 by jwe]
jwe
parents: 3225
diff changeset
40 #include "oct-time.h"
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21876
diff changeset
41 #include "quit.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
42 #include "singleton-cleanup.h"
21944
4b2eab5d2a6a provide wrapper for strdup
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
43 #include "strdup-wrapper.h"
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21876
diff changeset
44 #include "unistd-wrappers.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
45
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
46 #if defined (USE_READLINE)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
47 #include <cstdio>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
48
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
49 #include "oct-rl-edit.h"
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
50 #endif
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
51
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
52 namespace octave
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
53 {
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
54 char *do_completer_word_break_hook ();
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
55
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
56 command_editor *command_editor::instance = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
57
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
58 std::set<command_editor::startup_hook_fcn> command_editor::startup_hook_set;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
59
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
60 std::set<command_editor::pre_input_hook_fcn> command_editor::pre_input_hook_set;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
61
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
62 std::set<command_editor::event_hook_fcn> command_editor::event_hook_set;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
63
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
64 static octave_mutex event_hook_lock;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
65
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
66 #if defined (USE_READLINE)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
67
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
68 class
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
69 gnu_readline : public command_editor
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
70 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
71 public:
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
72
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
73 typedef command_editor::startup_hook_fcn startup_hook_fcn;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
74
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
75 typedef command_editor::pre_input_hook_fcn pre_input_hook_fcn;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
76
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
77 typedef command_editor::event_hook_fcn event_hook_fcn;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
78
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
79 typedef command_editor::completion_fcn completion_fcn;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
80
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
81 gnu_readline (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
82
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
83 ~gnu_readline (void) = default;
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
84
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
85 void do_set_name (const std::string& n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
86
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
87 std::string do_readline (const std::string& prompt, bool& eof);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
88
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
89 void do_set_input_stream (FILE *f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
90
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
91 FILE *do_get_input_stream (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
92
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
93 void do_set_output_stream (FILE *f);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
94
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
95 FILE *do_get_output_stream (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
96
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
97 void do_redisplay (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
98
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
99 int do_terminal_rows (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
100
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
101 int do_terminal_cols (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
102
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
103 void do_clear_screen (bool skip_redisplay);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
104
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
105 void do_resize_terminal (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
106
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
107 void do_set_screen_size (int ht, int wd);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
108
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
109 std::string newline_chars (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
110
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
111 void do_restore_terminal_state (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
112
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
113 void do_blink_matching_paren (bool flag);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
114
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
115 bool do_erase_empty_line (bool flag);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
116
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
117 void do_set_basic_word_break_characters (const std::string& s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
118
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
119 void do_set_completer_word_break_characters (const std::string& s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
120
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
121 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
122
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
123 void do_set_filename_quote_characters (const std::string& s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
124
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
125 void do_set_completer_quote_characters (const std::string& s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
126
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
127 void do_set_completion_append_character (char c);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
128
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
129 void do_set_completion_function (completion_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
130
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
131 void do_set_quoting_function (quoting_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
132
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
133 void do_set_dequoting_function (dequoting_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
134
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
135 void do_set_char_is_quoted_function (char_is_quoted_fcn f);
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
136
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
137 void do_set_user_accept_line_function (user_accept_line_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
138
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
139 completion_fcn do_get_completion_function (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
140
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
141 quoting_fcn do_get_quoting_function (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
142
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
143 dequoting_fcn do_get_dequoting_function (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
144
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
145 char_is_quoted_fcn do_get_char_is_quoted_function (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
146
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
147 user_accept_line_fcn do_get_user_accept_line_function (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
148
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
149 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
150 do_generate_filename_completions (const std::string& text);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
151
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
152 std::string do_get_line_buffer (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
153
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
154 std::string do_get_current_line (void) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
155
22171
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
156 char do_get_prev_char (int) const;
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
157
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
158 void do_replace_line (const std::string& text, bool clear_undo);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
159
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
160 void do_kill_full_line (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
161
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
162 void do_insert_text (const std::string& text);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
163
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
164 void do_newline (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
165
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
166 void do_accept_line (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
167
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
168 bool do_undo (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
169
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
170 void do_clear_undo_list (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
171
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
172 void set_startup_hook (startup_hook_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
173
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
174 void restore_startup_hook (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
175
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
176 void set_pre_input_hook (pre_input_hook_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
177
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
178 void restore_pre_input_hook (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
179
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
180 void set_event_hook (event_hook_fcn f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
181
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
182 void restore_event_hook (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
183
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
184 void do_restore_event_hook (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
185
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
186 void do_read_init_file (const std::string& file);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
187
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
188 void do_re_read_init_file (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
189
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
190 bool do_filename_completion_desired (bool);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
191
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
192 bool do_filename_quoting_desired (bool);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
193
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
194 bool do_prefer_env_winsize (bool);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
195
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
196 void do_interrupt (bool);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
197
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
198 static int operate_and_get_next (int, int);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
199
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
200 static int history_search_backward (int, int);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
201
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
202 static int history_search_forward (int, int);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
203
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
204 private:
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
205
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
206 startup_hook_fcn previous_startup_hook;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
207
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
208 pre_input_hook_fcn previous_pre_input_hook;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
209
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
210 event_hook_fcn previous_event_hook;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
211
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
212 completion_fcn completion_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
213
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
214 quoting_fcn quoting_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
215
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
216 dequoting_fcn dequoting_function;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
217
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
218 char_is_quoted_fcn char_is_quoted_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
219
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
220 user_accept_line_fcn user_accept_line_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
221
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
222 static std::string completer_quote_characters;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
223
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
224 static char *command_generator (const char *text, int state);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
225
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
226 static char *command_quoter (char *text, int match_type, char *quote_pointer);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
227 static char *command_dequoter (char *text, int match_type);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
228
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
229 static int command_char_is_quoted (char *text, int index);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
230
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
231 static int command_accept_line (int count, int key);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
232
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
233 static char **command_completer (const char *text, int start, int end);
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
234
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
235 static char *do_completer_word_break_hook ();
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
236 };
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
237
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
238 std::string gnu_readline::completer_quote_characters = "";
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
239
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
240 gnu_readline::gnu_readline ()
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
241 : command_editor (), previous_startup_hook (0),
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
242 previous_pre_input_hook (0),
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
243 previous_event_hook (0), completion_function (0),
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
244 quoting_function (0), dequoting_function (0),
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
245 char_is_quoted_function (0), user_accept_line_function (0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
246 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
247 // FIXME: need interface to rl_add_defun, rl_initialize, and
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
248 // a function to set rl_terminal_name
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
249
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
250 std::string term = octave::sys::env::getenv ("TERM");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
251
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
252 octave_rl_set_terminal_name (term.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
253
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
254 octave_rl_initialize ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
255
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
256 do_blink_matching_paren (true);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
257
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
258 // Bind operate-and-get-next.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
259
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
260 octave_rl_add_defun ("operate-and-get-next",
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
261 gnu_readline::operate_and_get_next,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
262 octave_rl_ctrl ('O'));
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
263
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
264 // And the history search functions.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
265
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
266 octave_rl_add_defun ("history-search-backward",
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
267 gnu_readline::history_search_backward,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
268 octave_rl_meta ('P'));
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
269
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
270 octave_rl_add_defun ("history-search-forward",
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
271 gnu_readline::history_search_forward,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
272 octave_rl_meta ('N'));
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
273 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
274
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
275 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
276 gnu_readline::do_set_name (const std::string& nm)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
277 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
278 ::octave_rl_set_name (nm.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
279 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
280
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
281 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
282 gnu_readline::do_readline (const std::string& prompt, bool& eof)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
283 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
284 std::string retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
285
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
286 eof = false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
287
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
288 const char *p = prompt.c_str ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
289
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
290 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
291
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
292 char *line = ::octave_rl_readline (p);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
293
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
294 if (line)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
295 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
296 retval = line;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
297
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
298 free (line);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
299 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
300 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
301 eof = true;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
302
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
303 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
19309
735bc47d18af command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents: 19304
diff changeset
304
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
305 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
306 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
307
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
308 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
309 gnu_readline::do_set_input_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
310 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
311 ::octave_rl_set_input_stream (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
312 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
313
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
314 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
315 gnu_readline::do_get_input_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
316 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
317 return ::octave_rl_get_input_stream ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
318 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
319
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
320 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
321 gnu_readline::do_set_output_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
322 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
323 ::octave_rl_set_output_stream (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
324 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
325
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
326 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
327 gnu_readline::do_get_output_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
328 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
329 return ::octave_rl_get_output_stream ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
330 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
331
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
332 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
333 gnu_readline::do_redisplay (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
334 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
335 ::octave_rl_redisplay ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
336 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
337
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
338 // GNU readline handles SIGWINCH, so these values have a good chance
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
339 // of being correct even if the window changes size (they may be
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
340 // wrong if, for example, the luser changes the window size while the
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
341 // pager is running, and the signal is handled by the pager instead of
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
342 // us.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
343
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
344 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
345 gnu_readline::do_terminal_rows (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
346 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
347 int sh = ::octave_rl_screen_height ();
19378
f7ccd02bc060 provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents: 19309
diff changeset
348
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
349 return sh > 0 ? sh : 24;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
350 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
351
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
352 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
353 gnu_readline::do_terminal_cols (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
354 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
355 int sw = ::octave_rl_screen_width ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
356
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
357 return sw > 0 ? sw : 80;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
358 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
359
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
360 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
361 gnu_readline::do_clear_screen (bool skip_redisplay)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
362 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
363 ::octave_rl_clear_screen (skip_redisplay);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
364 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
365
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
366 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
367 gnu_readline::do_resize_terminal (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
368 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
369 ::octave_rl_resize_terminal ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
370 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
371
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
372 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
373 gnu_readline::do_set_screen_size (int ht, int wd)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
374 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
375 ::octave_rl_set_screen_size (ht, wd);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
376 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
377
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
378 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
379 gnu_readline::newline_chars (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
380 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
381 return "\r\n";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
382 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
383
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
384 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
385 gnu_readline::do_restore_terminal_state (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
386 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
387 ::octave_rl_restore_terminal_state ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
388 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
389
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
390 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
391 gnu_readline::do_blink_matching_paren (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
392 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
393 ::octave_rl_enable_paren_matching (flag ? 1 : 0);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
394 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
395
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
396 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
397 gnu_readline::do_erase_empty_line (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
398 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
399 return ::octave_rl_erase_empty_line (flag ? 1 : 0);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
400 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
401
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
402 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
403 gnu_readline::do_set_basic_word_break_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
404 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
405 ::octave_rl_set_basic_word_break_characters (s.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
406 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
407
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
408 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
409 gnu_readline::do_set_completer_word_break_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
410 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
411 ::octave_rl_set_completer_word_break_characters (s.c_str ());
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
412
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
413 ::octave_rl_set_completion_word_break_hook
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
414 (gnu_readline::do_completer_word_break_hook);
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
415
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
416 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
417
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
418 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
419 gnu_readline::do_set_basic_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
420 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
421 ::octave_rl_set_basic_quote_characters (s.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
422 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
423
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
424 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
425 gnu_readline::do_set_filename_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
426 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
427 ::octave_rl_set_filename_quote_characters (s.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
428 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
429
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
430 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
431 gnu_readline::do_set_completer_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
432 {
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
433 completer_quote_characters = s;
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
434 }
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
435
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
436 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
437 gnu_readline::do_set_completion_append_character (char c)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
438 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
439 ::octave_rl_set_completion_append_character (c);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
440 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
441
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
442 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
443 gnu_readline::do_set_completion_function (completion_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
444 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
445 completion_function = f;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
446
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
447 rl_attempted_completion_fcn_ptr fp
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
448 = f ? gnu_readline::command_completer : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
449
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
450 ::octave_rl_set_completion_function (fp);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
451 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
452
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
453 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
454 gnu_readline::do_set_quoting_function (quoting_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
455 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
456 quoting_function = f;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
457
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
458 rl_quoting_fcn_ptr fp
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
459 = f ? gnu_readline::command_quoter : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
460
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
461 ::octave_rl_set_quoting_function (fp);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
462 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
463
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
464 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
465 gnu_readline::do_set_dequoting_function (dequoting_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
466 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
467 dequoting_function = f;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
468
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
469 rl_dequoting_fcn_ptr fp
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
470 = f ? gnu_readline::command_dequoter : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
471
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
472 ::octave_rl_set_dequoting_function (fp);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
473 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
474
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
475 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
476 gnu_readline::do_set_char_is_quoted_function (char_is_quoted_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
477 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
478 char_is_quoted_function = f;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
479
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
480 rl_char_is_quoted_fcn_ptr fp
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
481 = f ? gnu_readline::command_char_is_quoted : 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
482
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
483 ::octave_rl_set_char_is_quoted_function (fp);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
484 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
485
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
486 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
487 gnu_readline::do_set_user_accept_line_function (user_accept_line_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
488 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
489 user_accept_line_function = f;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
490
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
491 if (f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
492 octave_rl_add_defun ("accept-line", gnu_readline::command_accept_line,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
493 ::octave_rl_ctrl ('M'));
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
494 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
495 octave_rl_add_defun ("accept-line", ::octave_rl_newline,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
496 ::octave_rl_ctrl ('M'));
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
497 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
498
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
499 gnu_readline::completion_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
500 gnu_readline::do_get_completion_function (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
501 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
502 return completion_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
503 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
504
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
505 gnu_readline::quoting_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
506 gnu_readline::do_get_quoting_function (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
507 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
508 return quoting_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
509 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
510
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
511 gnu_readline::dequoting_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
512 gnu_readline::do_get_dequoting_function (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
513 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
514 return dequoting_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
515 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
516
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
517 gnu_readline::char_is_quoted_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
518 gnu_readline::do_get_char_is_quoted_function (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
519 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
520 return char_is_quoted_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
521 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
522
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
523 gnu_readline::user_accept_line_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
524 gnu_readline::do_get_user_accept_line_function (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
525 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
526 return user_accept_line_function;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
527 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
528
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
529 // True if the last "word" of the string line (delimited by delim) is
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
530 // an existing directory. Used by do_completer_word_break_hook.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
531
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
532 static bool
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
533 looks_like_filename (const char *line, char delim)
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
534 {
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
535 bool retval = false;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
536
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
537 const char *s = strrchr (line, delim);
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
538
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
539 if (s)
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
540 {
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
541 // Remove incomplete component.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
542 const char *f = strrchr (line, octave::sys::file_ops::dir_sep_char ());
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
543
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
544 if (s[1] == '~' || (f && f != s))
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
545 {
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
546 // For something like "A /b", f==s; don't assume a file.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
547
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
548 std::string candidate_filename = s+1;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
549
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
550 candidate_filename = candidate_filename.substr (0, f - s);
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
551
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
552 // Handles any complete ~<username>, but doesn't expand usernames.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
553
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
554 if (candidate_filename[0] == '~')
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
555 candidate_filename
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
556 = octave::sys::file_ops::tilde_expand (candidate_filename);
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
557
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
558 octave::sys::file_stat fs (candidate_filename);
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
559
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
560 retval = fs.is_dir ();
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
561 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
562 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
563
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
564 return retval;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
565 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
566
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
567 // Decide whether to interpret partial commands like "abc/def" as a
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
568 // filename or division. Return the set of delimiters appropriate for
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
569 // the decision.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
570
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
571 char *
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
572 gnu_readline::do_completer_word_break_hook ()
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
573 {
21944
4b2eab5d2a6a provide wrapper for strdup
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
574 static char *dir_sep = octave_strdup_wrapper (" '\"");
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
575
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
576 std::string word;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
577 std::string line = get_line_buffer ();
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
578
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
579 // For now, assume space or quote delimiter for file names.
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
580 const char *l = line.c_str ();
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
581
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
582 if (looks_like_filename (l, ' ') || looks_like_filename (l, '\'')
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
583 || looks_like_filename (l, '"'))
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
584 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
585 ::octave_rl_set_completer_quote_characters (
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
586 completer_quote_characters.c_str ());
21798
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
587
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
588 return dir_sep;
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
589 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
590 else
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
591 {
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
592 ::octave_rl_set_completer_quote_characters ("");
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
593
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
594 return octave_rl_get_completer_word_break_characters ();
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
595 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
596 }
12e7456f7619 Tab completion of multiple directory levels. (bug #44095)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21748
diff changeset
597
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
598 string_vector
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
599 gnu_readline::do_generate_filename_completions (const std::string& text)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
600 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
601 string_vector retval;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
602
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
603 int n = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
604 int count = 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
605
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
606 char *fn = 0;
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
607
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
608 while (1)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
609 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
610 fn = ::octave_rl_filename_completion_function (text.c_str (), count);
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
611
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
612 if (fn)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
613 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
614 if (count == n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
615 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
616 // Famous last words: Most large directories will not
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
617 // have more than a few hundred files, so we should not
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
618 // resize too many times even if the growth is linear...
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
619
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
620 n += 100;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
621 retval.resize (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
622 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
623
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
624 retval[count++] = fn;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
625
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
626 free (fn);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
627 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
628 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
629 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
630 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
631
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
632 retval.resize (count);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
633
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
634 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
635 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
636
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
637 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
638 gnu_readline::do_get_line_buffer (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
639 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
640 return ::octave_rl_line_buffer ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
641 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
642
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
643 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
644 gnu_readline::do_get_current_line (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
645 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
646 std::string retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
647 char *buf = ::octave_rl_copy_line ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
648 retval = buf;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
649 free (buf);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
650 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
651 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
652
22171
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
653 // Return the character (offset+1) to the left of the cursor,
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
654 // or '\0' if the cursor is at the start of the line.
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
655 char
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
656 gnu_readline::do_get_prev_char (int offset) const
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
657 {
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
658 const char *buf = ::octave_rl_line_buffer ();
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
659 int p = ::octave_rl_point ();
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
660
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
661 return p > offset ? buf[p - offset - 1] : '\0';
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
662 }
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
663
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
664 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
665 gnu_readline::do_replace_line (const std::string& text, bool clear_undo)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
666 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
667 ::octave_rl_replace_line (text.c_str (), clear_undo);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
668 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
669
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
670 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
671 gnu_readline::do_kill_full_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
672 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
673 ::octave_rl_kill_full_line ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
674 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
675
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
676 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
677 gnu_readline::do_insert_text (const std::string& text)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
678 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
679 ::octave_rl_insert_text (text.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
680 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
681
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
682 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
683 gnu_readline::do_newline (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
684 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
685 ::octave_rl_newline (1, '\n');
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
686 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
687
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
688 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
689 gnu_readline::do_accept_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
690 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
691 command_accept_line (1, '\n');
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
692 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
693
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
694 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
695 gnu_readline::do_undo (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
696 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
697 return ::octave_rl_do_undo ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
698 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
699
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
700 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
701 gnu_readline::do_clear_undo_list ()
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
702 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
703 ::octave_rl_clear_undo_list ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
704 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
705
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
706 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
707 gnu_readline::set_startup_hook (startup_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
708 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
709 previous_startup_hook = ::octave_rl_get_startup_hook ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
710
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
711 if (f != previous_startup_hook)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
712 ::octave_rl_set_startup_hook (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
713 }
19378
f7ccd02bc060 provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents: 19309
diff changeset
714
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
715 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
716 gnu_readline::restore_startup_hook (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
717 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
718 ::octave_rl_set_startup_hook (previous_startup_hook);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
719 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
720
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
721 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
722 gnu_readline::set_pre_input_hook (pre_input_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
723 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
724 previous_pre_input_hook = ::octave_rl_get_pre_input_hook ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
725
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
726 if (f != previous_pre_input_hook)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
727 ::octave_rl_set_pre_input_hook (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
728 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
729
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
730 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
731 gnu_readline::restore_pre_input_hook (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
732 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
733 ::octave_rl_set_pre_input_hook (previous_pre_input_hook);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
734 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
735
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
736 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
737 gnu_readline::set_event_hook (event_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
738 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
739 previous_event_hook = octave_rl_get_event_hook ();
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
740
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
741 ::octave_rl_set_event_hook (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
742 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
743
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
744 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
745 gnu_readline::restore_event_hook (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
746 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
747 ::octave_rl_set_event_hook (previous_event_hook);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
748 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
749
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
750 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
751 gnu_readline::do_read_init_file (const std::string& file)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
752 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
753 ::octave_rl_read_init_file (file.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
754 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
755
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
756 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
757 gnu_readline::do_re_read_init_file (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
758 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
759 ::octave_rl_re_read_init_file ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
760 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
761
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
762 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
763 gnu_readline::do_filename_completion_desired (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
764 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
765 return ::octave_rl_filename_completion_desired (arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
766 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
767
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
768 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
769 gnu_readline::do_filename_quoting_desired (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
770 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
771 return ::octave_rl_filename_quoting_desired (arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
772 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
773
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
774 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
775 gnu_readline::do_prefer_env_winsize (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
776 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
777 return ::octave_rl_prefer_env_winsize (arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
778 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
779
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
780 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
781 gnu_readline::do_interrupt (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
782 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
783 ::octave_rl_done (arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
784 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
785
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
786 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
787 gnu_readline::operate_and_get_next (int /* count */, int /* c */)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
788 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
789 // Accept the current line.
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
790
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
791 command_editor::accept_line ();
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
792
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
793 // Find the current line, and find the next line to use.
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
794
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
795 int x_where = command_history::where ();
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
796
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
797 int x_length = command_history::length ();
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
798
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
799 if ((command_history::is_stifled ()
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
800 && (x_length >= command_history::max_input_history ()))
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
801 || (x_where >= x_length - 1))
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
802 command_history::set_mark (x_where);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
803 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
804 command_history::set_mark (x_where + 1);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
805
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
806 command_editor::add_startup_hook (command_history::goto_mark);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
807
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
808 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
809 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
810
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
811 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
812 gnu_readline::history_search_backward (int count, int c)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
813 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
814 return octave_rl_history_search_backward (count, c);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
815 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
816
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
817 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
818 gnu_readline::history_search_forward (int count, int c)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
819 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
820 return octave_rl_history_search_forward (count, c);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
821 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
822
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
823 char *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
824 gnu_readline::command_generator (const char *text, int state)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
825 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
826 char *retval = 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
827
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
828 completion_fcn f = command_editor::get_completion_function ();
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
829
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
830 std::string tmp = f (text, state);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
831
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
832 size_t len = tmp.length ();
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
833
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
834 if (len > 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
835 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
836 retval = static_cast<char *> (std::malloc (len+1));
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
837
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
838 strcpy (retval, tmp.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
839 }
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
840
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
841 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
842 }
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
843
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
844 char *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
845 gnu_readline::command_quoter (char *text, int matches, char *qcp)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
846 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
847 char *retval = 0;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
848
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
849 quoting_fcn f = command_editor::get_quoting_function ();
19304
ad93e9be78ee command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
850
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
851 std::string tmp = f (text, matches, *qcp);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
852
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
853 size_t len = tmp.length ();
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
854
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
855 if (len > 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
856 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
857 retval = static_cast<char *> (std::malloc (len+1));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
858
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
859 strcpy (retval, tmp.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
860 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
861
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
862 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
863 }
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
864
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
865 char *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
866 gnu_readline::command_dequoter (char *text, int quote)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
867 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
868 char *retval = 0;
3951
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
869
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
870 dequoting_fcn f = command_editor::get_dequoting_function ();
3951
e6f67a1ed814 [project @ 2002-05-23 03:41:25 by jwe]
jwe
parents: 3933
diff changeset
871
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
872 std::string tmp = f (text, quote);
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
873
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
874 size_t len = tmp.length ();
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
875
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
876 if (len > 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
877 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
878 retval = static_cast<char *> (std::malloc (len+1));
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
879
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
880 strcpy (retval, tmp.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
881 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
882
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
883 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
884 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
885
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
886 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
887 gnu_readline::command_char_is_quoted (char *text, int quote)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
888 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
889 char_is_quoted_fcn f = command_editor::get_char_is_quoted_function ();
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
890
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
891 return f (text, quote);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
892 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
893
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
894 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
895 gnu_readline::command_accept_line (int count, int key)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
896 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
897 user_accept_line_fcn f = command_editor::get_user_accept_line_function ();
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
898
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
899 if (f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
900 f (::octave_rl_line_buffer ());
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
901
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
902 ::octave_rl_redisplay ();
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
903
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
904 return ::octave_rl_newline (count, key);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
905 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
906
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
907 char **
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
908 gnu_readline::command_completer (const char *text, int, int)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
909 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
910 char **matches = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
911 matches
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
912 = ::octave_rl_completion_matches (text, gnu_readline::command_generator);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
913 return matches;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
914 }
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
915
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
916 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
917
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
918 class
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
919 default_command_editor : public command_editor
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
920 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
921 public:
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
922
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
923 default_command_editor (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
924 : command_editor (), input_stream (stdin), output_stream (stdout) { }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
925
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
926 ~default_command_editor (void) = default;
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
927
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
928 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
929
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
930 void do_set_input_stream (FILE *f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
931
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
932 FILE *do_get_input_stream (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
933
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
934 void do_set_output_stream (FILE *f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
935
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
936 FILE *do_get_output_stream (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
937
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
938 string_vector do_generate_filename_completions (const std::string& text);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
939
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
940 std::string do_get_line_buffer (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
941
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
942 std::string do_get_current_line (void) const;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
943
22171
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
944 char do_get_prev_char (int) const;
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
945
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
946 void do_replace_line (const std::string& text, bool clear_undo);
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
947
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
948 void do_kill_full_line (void);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
949
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
950 void do_insert_text (const std::string& text);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
951
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
952 void do_newline (void);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
953
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
954 void do_accept_line (void);
19702
c048358da712 also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
955
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
956 private:
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
957
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
958 FILE *input_stream;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
959
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
960 FILE *output_stream;
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
961
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
962 // No copying!
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
963
22865
89756f2f085b use c++11 style for deleting default copy constructor and assignment operator
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
964 default_command_editor (const default_command_editor&) = delete;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
965
22865
89756f2f085b use c++11 style for deleting default copy constructor and assignment operator
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
966 default_command_editor& operator = (const default_command_editor&) = delete;
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
967 };
12153
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
968
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
969 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
970 default_command_editor::do_readline (const std::string& prompt, bool& eof)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
971 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
972 std::fputs (prompt.c_str (), output_stream);
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
973 std::fflush (output_stream);
12153
e0e50f48df37 Explicitly disallow copying in some classes
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
974
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
975 return octave_fgetl (input_stream, eof);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
976 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
977
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
978 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
979 default_command_editor::do_set_input_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
980 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
981 input_stream = f;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
982 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
983
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
984 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
985 default_command_editor::do_get_input_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
986 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
987 return input_stream;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
988 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
989
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
990 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
991 default_command_editor::do_set_output_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
992 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
993 output_stream = f;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
994 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
995
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
996 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
997 default_command_editor::do_get_output_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
998 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
999 return output_stream;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1000 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1001
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1002 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1003 default_command_editor::do_generate_filename_completions (const std::string&)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1004 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1005 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1006 return string_vector ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1007 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1008
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1009 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1010 default_command_editor::do_get_line_buffer (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1011 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1012 return "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1013 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1014
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1015 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1016 default_command_editor::do_get_current_line (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1017 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1018 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1019 return "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1020 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1021
22171
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1022 char
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1023 default_command_editor::do_get_prev_char (int) const
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1024 {
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1025 return '\0';
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1026 }
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1027
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1028 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1029 default_command_editor::do_replace_line (const std::string&, bool)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1030 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1031 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1032 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1033
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1034 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1035 default_command_editor::do_kill_full_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1036 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1037 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1038 }
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1039
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1040 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1041 default_command_editor::do_insert_text (const std::string&)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1042 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1043 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1044 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1045
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1046 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1047 default_command_editor::do_newline (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1048 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1049 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1050 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1051
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1052 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1053 default_command_editor::do_accept_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1054 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1055 // FIXME
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1056 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1057
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1058 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1059 command_editor::instance_ok (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1060 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1061 bool retval = true;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1062
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1063 if (! instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1064 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1065 make_command_editor ();
19702
c048358da712 also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
1066
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1067 if (instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1068 singleton_cleanup_list::add (cleanup_instance);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1069 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1070
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1071 if (! instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1072 (*current_liboctave_error_handler)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1073 ("unable to create command history object!");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1074
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1075 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1076 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1077
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1078 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1079 command_editor::make_command_editor (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1080 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1081 #if defined (USE_READLINE)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1082 instance = new gnu_readline ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1083 #else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1084 instance = new default_command_editor ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1085 #endif
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1086 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1087
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1088 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1089 command_editor::force_default_editor (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1090 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1091 delete instance;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1092 instance = new default_command_editor ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1093 }
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13924
diff changeset
1094
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1095 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1096 command_editor::set_initial_input (const std::string& text)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1097 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1098 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1099 instance->initial_input = text;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1100 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1101
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1102 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1103 command_editor::insert_initial_input (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1104 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1105 return instance_ok () ? instance->do_insert_initial_input () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1106 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1107
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1108 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1109 command_editor::startup_handler (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1110 {
21876
ef25c202bacc maint: Clean up for-range usage in liboctave in cset 5c67b16acc4a.
Rik <rik@octave.org>
parents: 21862
diff changeset
1111 for (auto& fcnptr : startup_hook_set)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1112 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1113 startup_hook_fcn f = *fcnptr;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1114
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1115 if (f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1116 f ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1117 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1118
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1119 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1120 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1121
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1122 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1123 command_editor::pre_input_handler (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1124 {
21876
ef25c202bacc maint: Clean up for-range usage in liboctave in cset 5c67b16acc4a.
Rik <rik@octave.org>
parents: 21862
diff changeset
1125 for (auto& fcnptr : pre_input_hook_set)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1126 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1127 pre_input_hook_fcn f = *fcnptr;
9321
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
1128
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1129 if (f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1130 f ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1131 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1132
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1133 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1134 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1135
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1136 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1137 command_editor::event_handler (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1138 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1139 event_hook_lock.lock ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1140
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1141 std::set<event_hook_fcn> hook_set (event_hook_set);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1142
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1143 event_hook_lock.unlock ();
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1144
21876
ef25c202bacc maint: Clean up for-range usage in liboctave in cset 5c67b16acc4a.
Rik <rik@octave.org>
parents: 21862
diff changeset
1145 for (auto& fcnptr : hook_set)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1146 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1147 event_hook_fcn f = *fcnptr;
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1148
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1149 if (f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1150 f ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1151 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1152
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1153 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1154 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1155
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1156 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1157 command_editor::set_name (const std::string& n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1158 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1159 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1160 instance->do_set_name (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1161 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1162
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1163 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1164 command_editor::readline (const std::string& prompt)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1165 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1166 bool eof;
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1167
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1168 return readline (prompt, eof);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1169 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1170
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1171 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1172 command_editor::readline (const std::string& prompt, bool& eof)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1173 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1174 std::string retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1175
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1176 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1177 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1178 if (! instance->initial_input.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1179 add_pre_input_hook (command_editor::insert_initial_input);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1180
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1181 retval = instance->do_readline (prompt, eof);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1182 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1183
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1184 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1185 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1186
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1187 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1188 command_editor::set_input_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1189 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1190 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1191 instance->do_set_input_stream (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1192 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1193
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1194 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1195 command_editor::get_input_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1196 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1197 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1198 ? instance->do_get_input_stream () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1199 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1200
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1201 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1202 command_editor::set_output_stream (FILE *f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1203 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1204 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1205 instance->do_set_output_stream (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1206 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1207
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1208 FILE *
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1209 command_editor::get_output_stream (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1210 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1211 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1212 ? instance->do_get_output_stream () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1213 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1214
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1215 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1216 command_editor::redisplay (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1217 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1218 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1219 instance->do_redisplay ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1220 }
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1221
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1222 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1223 command_editor::terminal_rows (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1224 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1225 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1226 ? instance->do_terminal_rows () : -1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1227 }
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
1228
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1229 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1230 command_editor::terminal_cols (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1231 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1232 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1233 ? instance->do_terminal_cols () : -1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1234 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1235
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1236 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1237 command_editor::clear_screen (bool skip_redisplay)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1238 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1239 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1240 instance->do_clear_screen (skip_redisplay);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1241 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1242
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1243 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1244 command_editor::resize_terminal (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1245 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1246 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1247 instance->do_resize_terminal ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1248 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1249
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1250 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1251 command_editor::set_screen_size (int ht, int wd)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1252 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1253 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1254 instance->do_set_screen_size (ht, wd);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1255 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1256
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1257 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1258 command_editor::decode_prompt_string (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1259 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1260 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1261 ? instance->do_decode_prompt_string (s) : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1262 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1263
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1264 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1265 command_editor::current_command_number (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1266 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1267 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1268 ? instance->command_number : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1269 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1270
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1271 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1272 command_editor::reset_current_command_number (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1273 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1274 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1275 instance->command_number = n;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1276 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1277
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1278 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1279 command_editor::increment_current_command_number (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1280 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1281 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1282 instance->command_number++;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1283 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1284
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1285 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1286 command_editor::restore_terminal_state (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1287 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1288 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1289 instance->do_restore_terminal_state ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1290 }
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1291
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1292 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1293 command_editor::blink_matching_paren (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1294 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1295 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1296 instance->do_blink_matching_paren (flag);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1297 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1298
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1299 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1300 command_editor::erase_empty_line (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1301 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1302 return instance_ok () ? instance->do_erase_empty_line (flag) : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1303 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1304
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1305 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1306 command_editor::set_basic_word_break_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1307 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1308 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1309 instance->do_set_basic_word_break_characters (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1310 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1311
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1312 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1313 command_editor::set_completer_word_break_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1314 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1315 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1316 instance->do_set_completer_word_break_characters (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1317 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1318
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1319 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1320 command_editor::set_basic_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1321 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1322 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1323 instance->do_set_basic_quote_characters (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1324 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1325
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1326 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1327 command_editor::set_filename_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1328 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1329 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1330 instance->do_set_filename_quote_characters (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1331 }
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3260
diff changeset
1332
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1333 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1334 command_editor::set_completer_quote_characters (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1335 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1336 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1337 instance->do_set_completer_quote_characters (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1338 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1339
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1340 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1341 command_editor::set_completion_append_character (char c)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1342 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1343 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1344 instance->do_set_completion_append_character (c);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1345 }
19309
735bc47d18af command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents: 19304
diff changeset
1346
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1347 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1348 command_editor::set_completion_function (completion_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1349 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1350 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1351 instance->do_set_completion_function (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1352 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1353
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1354 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1355 command_editor::set_quoting_function (quoting_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1356 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1357 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1358 instance->do_set_quoting_function (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1359 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1360
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1361 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1362 command_editor::set_dequoting_function (dequoting_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1363 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1364 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1365 instance->do_set_dequoting_function (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1366 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1367
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1368 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1369 command_editor::set_char_is_quoted_function (char_is_quoted_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1370 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1371 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1372 instance->do_set_char_is_quoted_function (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1373 }
2967
467aae13b70a [project @ 1997-05-15 16:47:12 by jwe]
jwe
parents: 2941
diff changeset
1374
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1375 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1376 command_editor::set_user_accept_line_function (user_accept_line_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1377 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1378 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1379 instance->do_set_user_accept_line_function (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1380 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1381
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1382 command_editor::completion_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1383 command_editor::get_completion_function (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1384 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1385 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1386 ? instance->do_get_completion_function () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1387 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1388
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1389 command_editor::quoting_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1390 command_editor::get_quoting_function (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1391 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1392 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1393 ? instance->do_get_quoting_function () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1394 }
19378
f7ccd02bc060 provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents: 19309
diff changeset
1395
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1396 command_editor::dequoting_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1397 command_editor::get_dequoting_function (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1398 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1399 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1400 ? instance->do_get_dequoting_function () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1401 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1402
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1403 command_editor::char_is_quoted_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1404 command_editor::get_char_is_quoted_function (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1405 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1406 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1407 ? instance->do_get_char_is_quoted_function () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1408 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3779
diff changeset
1409
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1410 command_editor::user_accept_line_fcn
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1411 command_editor::get_user_accept_line_function (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1412 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1413 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1414 ? instance->do_get_user_accept_line_function () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1415 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1416
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1417 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1418 command_editor::generate_filename_completions (const std::string& text)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1419 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1420 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1421 ? instance->do_generate_filename_completions (text) : string_vector ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1422 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1423
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1424 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1425 command_editor::get_line_buffer (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1426 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1427 return (instance_ok ()) ? instance->do_get_line_buffer () : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1428 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1429
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1430 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1431 command_editor::get_current_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1432 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1433 return (instance_ok ()) ? instance->do_get_current_line () : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1434 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1435
22171
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1436 // Return the character (offset+1) to the left of the cursor,
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1437 // or '\0' if the cursor is at the start of the line.
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1438 char
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1439 command_editor::get_prev_char (int offset)
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1440 {
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1441 return (instance_ok ()) ? instance->do_get_prev_char (offset) : '\0';
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1442 }
0a4c5a90f286 Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22022
diff changeset
1443
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1444 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1445 command_editor::replace_line (const std::string& text, bool clear_undo)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1446 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1447 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1448 instance->do_replace_line (text, clear_undo);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1449 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1450
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1451 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1452 command_editor::kill_full_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1453 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1454 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1455 instance->do_kill_full_line ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1456 }
2941
b779a5b8aed4 [project @ 1997-05-08 02:14:34 by jwe]
jwe
parents: 2926
diff changeset
1457
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1458 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1459 command_editor::insert_text (const std::string& text)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1460 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1461 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1462 instance->do_insert_text (text);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1463 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1464
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1465 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1466 command_editor::newline (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1467 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1468 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1469 instance->do_newline ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1470 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1471
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1472 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1473 command_editor::accept_line (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1474 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1475 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1476 instance->do_accept_line ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1477 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1478
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1479 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1480 command_editor::undo (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1481 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1482 return instance_ok () ? instance->do_undo () : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1483 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1484
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1485 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1486 command_editor::clear_undo_list (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1487 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1488 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1489 instance->do_clear_undo_list ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1490 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1491
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1492 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1493 command_editor::add_startup_hook (startup_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1494 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1495 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1496 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1497 startup_hook_set.insert (f);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1498
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1499 instance->set_startup_hook (startup_handler);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1500 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1501 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1502
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1503 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1504 command_editor::remove_startup_hook (startup_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1505 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1506 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1507 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1508 auto p = startup_hook_set.find (f);
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1509
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1510 if (p != startup_hook_set.end ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1511 startup_hook_set.erase (p);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1512
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1513 if (startup_hook_set.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1514 instance->restore_startup_hook ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1515 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1516 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1517
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1518 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1519 command_editor::add_pre_input_hook (pre_input_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1520 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1521 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1522 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1523 pre_input_hook_set.insert (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1524
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1525 instance->set_pre_input_hook (pre_input_handler);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1526 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1527 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1528
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1529 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1530 command_editor::remove_pre_input_hook (pre_input_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1531 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1532 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1533 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1534 auto p = pre_input_hook_set.find (f);
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1535
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1536 if (p != pre_input_hook_set.end ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1537 pre_input_hook_set.erase (p);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1538
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1539 if (pre_input_hook_set.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1540 instance->restore_pre_input_hook ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1541 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1542 }
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4527
diff changeset
1543
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1544 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1545 command_editor::add_event_hook (event_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1546 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1547 octave_autolock guard (event_hook_lock);
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
1548
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1549 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1550 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1551 event_hook_set.insert (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1552
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1553 instance->set_event_hook (event_handler);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1554 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1555 }
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1556
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1557 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1558 command_editor::remove_event_hook (event_hook_fcn f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1559 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1560 octave_autolock guard (event_hook_lock);
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1561
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1562 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1563 {
21862
5c67b16acc4a maint: Use C++ 'auto' keyword in some instances in liboctave.
Rik <rik@octave.org>
parents: 21798
diff changeset
1564 auto p = event_hook_set.find (f);
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1565
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1566 if (p != event_hook_set.end ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1567 event_hook_set.erase (p);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1568
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1569 if (event_hook_set.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1570 instance->restore_event_hook ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1571 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1572 }
19702
c048358da712 also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
1573
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1574 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1575 command_editor::run_event_hooks (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1576 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1577 event_handler ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1578 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1579
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1580 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1581 command_editor::read_init_file (const std::string& file_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1582 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1583 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1584 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1585 std::string file = octave::sys::file_ops::tilde_expand (file_arg);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1586
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1587 instance->do_read_init_file (file);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1588 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1589 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1590
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1591 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1592 command_editor::re_read_init_file (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1593 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1594 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1595 instance->do_re_read_init_file ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1596 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1597
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1598 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1599 command_editor::filename_completion_desired (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1600 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1601 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1602 ? instance->do_filename_completion_desired (arg) : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1603 }
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1604
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1605 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1606 command_editor::filename_quoting_desired (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1607 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1608 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1609 ? instance->do_filename_quoting_desired (arg) : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1610 }
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
1611
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1612 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1613 command_editor::prefer_env_winsize (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1614 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1615 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1616 ? instance->do_prefer_env_winsize (arg) : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1617 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1618
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1619 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1620 command_editor::interrupt (bool arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1621 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1622 bool retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1623
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1624 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1625 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1626 // Return the current interrupt state.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1627 retval = instance->interrupted;
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1628
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1629 instance->do_interrupt (arg);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1630
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1631 instance->interrupted = arg;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1632 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1633 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1634 retval = false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1635
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1636 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1637 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1638
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1639 // Return a string which will be printed as a prompt. The string may
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1640 // contain special characters which are decoded as follows:
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1641 //
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1642 // \a bell (ascii 07)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1643 // \d the date
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1644 // \e escape (ascii 033)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1645 // \h the hostname up to the first '.'
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1646 // \H the hostname
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1647 // \n CRLF
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1648 // \r CR
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1649 // \s the name of the shell (program)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1650 // \t the time
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1651 // \T the time in 12-hour hh:mm:ss format
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1652 // \@ the time in 12-hour hh:mm am/pm format
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1653 // \A the time in 24-hour hh:mm format
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1654 // \u your username
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1655 // \w the current working directory
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1656 // \W the last element of PWD
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1657 // \! the history number of this command
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1658 // \# the command number of this command
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1659 // \$ a $ or a # if you are root
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1660 // \nnn character code nnn in octal
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1661 // \\ a backslash
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1662 // \[ begin a sequence of non-printing chars
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1663 // \] end a sequence of non-printing chars
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1664
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1665 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1666 command_editor::do_decode_prompt_string (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1667 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1668 std::string retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1669 std::string tmpstr;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1670 size_t i = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1671 size_t slen = s.length ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1672 int c;
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1673
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1674 while (i < slen)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1675 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1676 c = s[i];
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1677
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1678 i++;
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1679
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1680 if (c == '\\')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1681 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1682 c = s[i];
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
1683
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1684 switch (c)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1685 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1686 case '0':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1687 case '1':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1688 case '2':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1689 case '3':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1690 case '4':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1691 case '5':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1692 case '6':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1693 case '7':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1694 // Maybe convert an octal number.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1695 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1696 int n = read_octal (s.substr (i, 3));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1697
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1698 tmpstr = "\\";
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 3189
diff changeset
1699
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1700 if (n != -1)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1701 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1702 tmpstr[0] = n;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1703 i += 2; // i++ makes this += 3 later
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1704 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7758
diff changeset
1705
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1706 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1707 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1708
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1709 case 'a':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1710 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1711 tmpstr = '\a';
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1712
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1713 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1714 }
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 5872
diff changeset
1715
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1716 case 'd':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1717 case 't':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1718 case 'T':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1719 case '@':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1720 case 'A':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1721 // Make the current time/date into a string.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1722 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1723 octave::sys::localtime now;
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12912
diff changeset
1724
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1725 if (c == 'd')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1726 tmpstr = now.strftime ("%a %b %d");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1727 else if (c == 't')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1728 tmpstr = now.strftime ("%H:%M:%S");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1729 else if (c == 'T')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1730 tmpstr = now.strftime ("%I:%M:%S");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1731 else if (c == '@')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1732 tmpstr = now.strftime ("%I:%M %p");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1733 else if (c == 'A')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1734 tmpstr = now.strftime ("%H:%M");
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
1735
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1736 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1737 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1738
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1739 case 'e':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1740 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1741 tmpstr = '\033';
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3145
diff changeset
1742
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1743 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1744 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1745
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1746 case 'h':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1747 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1748 tmpstr = octave::sys::env::get_host_name ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1749
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1750 size_t pos = tmpstr.find ('.');
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
1751
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1752 if (pos != std::string::npos)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1753 tmpstr.resize (pos);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1754
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1755 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1756 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1757
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1758 case 'H':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1759 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1760 tmpstr = octave::sys::env::get_host_name ();
4143
62afb31c1f85 [project @ 2002-11-01 17:27:38 by jwe]
jwe
parents: 4062
diff changeset
1761
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1762 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1763 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1764
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1765 case 'n':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1766 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1767 tmpstr = newline_chars ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1768
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1769 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1770 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1771
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1772 case 'r':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1773 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1774 tmpstr = '\r';
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6940
diff changeset
1775
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1776 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1777 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1778
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1779 case 's':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1780 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1781 tmpstr = octave::sys::env::get_program_name ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1782 tmpstr = octave::sys::env::base_pathname (tmpstr);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1783
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1784 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1785 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1786
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1787 case 'u':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1788 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1789 tmpstr = octave::sys::env::get_user_name ();
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
1790
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1791 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1792 }
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1793
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1794 case 'w':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1795 case 'W':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1796 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1797 try
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1798 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1799 tmpstr = octave::sys::env::get_current_directory ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1800 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1801 catch (const octave::execution_exception&)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1802 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1803 tmpstr = "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1804 }
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1805
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1806 std::string home_dir = octave::sys::env::get_home_directory ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1807
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1808 if (c == 'W' && (home_dir.empty () || tmpstr != home_dir))
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1809 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1810 if (tmpstr != "/" && tmpstr != "//")
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1811 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1812 size_t pos = tmpstr.rfind ('/');
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1813
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1814 if (pos != std::string::npos && pos != 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1815 tmpstr = tmpstr.substr (pos + 1);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1816 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1817 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1818 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1819 tmpstr = octave::sys::env::polite_directory_format (tmpstr);
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1820
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1821 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1822 }
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1823
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1824 case '!':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1825 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1826 char number_buffer[32];
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1827 int num = command_history::current_number ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1828 if (num > 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1829 sprintf (number_buffer, "%d", num);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1830 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1831 strcpy (number_buffer, "!");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1832 tmpstr = number_buffer;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1833
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1834 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1835 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1836
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1837 case '#':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1838 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1839 char number_buffer[32];
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1840 sprintf (number_buffer, "%d", command_number);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1841 tmpstr = number_buffer;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1842
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1843 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1844 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1845
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1846 case '$':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1847 {
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21876
diff changeset
1848 tmpstr = (octave_geteuid_wrapper () == 0 ? '#' : '$');
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1849 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1850 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1851
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1852 #if defined (USE_READLINE)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1853 case '[':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1854 case ']':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1855 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1856 tmpstr.resize (1);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1857
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1858 tmpstr[0] = ((c == '[')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1859 ? ::octave_rl_prompt_start_ignore ()
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1860 : ::octave_rl_prompt_end_ignore ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1861
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1862 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1863 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1864 #endif
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1865
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1866 case '\\':
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1867 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1868 tmpstr = "\\";
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1869
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1870 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1871 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1872
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1873 default:
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1874 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1875 tmpstr = "\\ ";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1876 tmpstr[1] = c;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1877
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1878 break;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1879 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1880 }
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1881
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1882 retval.append (tmpstr);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1883 i++; // Move past processed escape character
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1884 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1885 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1886 retval += c;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1887 }
21168
26f85aa072de maint: Replace instances of goto in liboctave where convenient.
Rik <rik@octave.org>
parents: 21136
diff changeset
1888
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1889 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1890 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1891
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1892 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1893 command_editor::do_insert_initial_input (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1894 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1895 std::string input = initial_input;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1896
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1897 initial_input = "";
21168
26f85aa072de maint: Replace instances of goto in liboctave where convenient.
Rik <rik@octave.org>
parents: 21136
diff changeset
1898
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1899 do_insert_text (input);
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1900
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1901 // Is it really right to redisplay here?
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1902 do_redisplay ();
5442
636886245488 [project @ 2005-09-07 21:42:26 by jwe]
jwe
parents: 5336
diff changeset
1903
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1904 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1905 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1906
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1907 // Return the octal number parsed from STRING, or -1 to indicate that
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1908 // the string contained a bad number.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1909
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1910 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1911 command_editor::read_octal (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1912 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1913 int result = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1914 int digits = 0;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1915
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1916 size_t i = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1917 size_t slen = s.length ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1918
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1919 while (i < slen && s[i] >= '0' && s[i] < '8')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1920 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1921 digits++;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1922 result = (result * 8) + s[i] - '0';
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1923 i++;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1924 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1925
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1926 if (! digits || result > 0777 || i < slen)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1927 result = -1;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1928
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1929 return result;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1930 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1931
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1932 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1933 command_editor::error (int err_num)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1934 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
1935 (*current_liboctave_error_handler) ("%s", std::strerror (err_num));
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1936 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1937
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1938 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1939 command_editor::error (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1940 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1941 (*current_liboctave_error_handler) ("%s", s.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1942 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1943 }
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
1944