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