Mercurial > octave-nkf
annotate liboctave/util/cmd-edit.cc @ 20651:e54ecb33727e
lo-array-gripes.cc: Remove FIXME's related to buffer size.
* lo-array-gripes.cc: Remove FIXME's related to buffer size. Shorten sprintf
buffers from 100 to 64 characters (still well more than 19 required).
Use 'const' decorator on constant value for clarity. Remove extra space
between variable and array bracket.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 12 Oct 2015 21:13:47 -0700 |
parents | b70cc4bd8109 |
children |
rev | line source |
---|---|
2926 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19414
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 | |
24 #include <config.h> | |
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 | |
19343
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
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:
19338
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 | |
19412
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
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:
19343
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 |
19736
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
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 | |
19338
ad93e9be78ee
command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents:
19336
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:
19336
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 |
19820
d6652461dfbc
avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents:
19736
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 |
19820
d6652461dfbc
avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents:
19736
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:
19736
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 | |
19343
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
360 void |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
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:
19338
diff
changeset
|
362 { |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
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:
19338
diff
changeset
|
364 } |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
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 | |
19412
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
diff
changeset
|
384 bool |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
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:
19343
diff
changeset
|
386 { |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
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:
19343
diff
changeset
|
388 } |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
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 |
19736
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
diff
changeset
|
576 { |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
diff
changeset
|
578 } |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
579 |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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 | |
19338
ad93e9be78ee
command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents:
19336
diff
changeset
|
678 bool |
ad93e9be78ee
command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents:
19336
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:
19336
diff
changeset
|
680 { |
ad93e9be78ee
command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents:
19336
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:
19336
diff
changeset
|
682 } |
ad93e9be78ee
command_editor: provide access to rl_prefer_env_winsize
John W. Eaton <jwe@octave.org>
parents:
19336
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 |
19736
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
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 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
921 return std::string (); |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
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 |
19736
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
diff
changeset
|
932 { |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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:
19731
diff
changeset
|
934 } |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
935 |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
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) | |
968 { | |
2941 | 969 current_liboctave_error_handler |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
970 ("unable to create command history object!"); |
2926 | 971 |
972 retval = false; | |
973 } | |
974 | |
975 return retval; | |
976 } | |
977 | |
978 void | |
979 command_editor::make_command_editor (void) | |
980 { | |
981 #if defined (USE_READLINE) | |
982 instance = new gnu_readline (); | |
983 #else | |
984 instance = new default_command_editor (); | |
985 #endif | |
986 } | |
987 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
988 void |
9321
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
989 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
|
990 { |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
991 delete instance; |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
992 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
|
993 } |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
994 |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
995 void |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
996 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
|
997 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
998 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
|
999 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
|
1000 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1001 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1002 int |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1003 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
|
1004 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1005 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
|
1006 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1007 |
6913 | 1008 int |
1009 command_editor::startup_handler (void) | |
1010 { | |
1011 for (startup_hook_set_iterator p = startup_hook_set.begin (); | |
1012 p != startup_hook_set.end (); p++) | |
1013 { | |
1014 startup_hook_fcn f = *p; | |
1015 | |
1016 if (f) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1017 f (); |
6913 | 1018 } |
1019 | |
1020 return 0; | |
1021 } | |
1022 | |
1023 int | |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1024 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
|
1025 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1026 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
|
1027 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
|
1028 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1029 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
|
1030 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1031 if (f) |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1032 f (); |
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 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1035 return 0; |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1036 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1037 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1038 int |
6913 | 1039 command_editor::event_handler (void) |
1040 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1041 event_hook_lock.lock (); |
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 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
|
1044 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1045 event_hook_lock.unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1046 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1047 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
|
1048 p != hook_set.end (); p++) |
6913 | 1049 { |
1050 event_hook_fcn f = *p; | |
1051 | |
1052 if (f) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1053 f (); |
6913 | 1054 } |
1055 | |
1056 return 0; | |
1057 } | |
1058 | |
2926 | 1059 void |
3504 | 1060 command_editor::set_name (const std::string& n) |
2926 | 1061 { |
1062 if (instance_ok ()) | |
1063 instance->do_set_name (n); | |
1064 } | |
1065 | |
3504 | 1066 std::string |
1067 command_editor::readline (const std::string& prompt) | |
2926 | 1068 { |
3219 | 1069 bool eof; |
1070 | |
1071 return readline (prompt, eof); | |
1072 } | |
1073 | |
3504 | 1074 std::string |
1075 command_editor::readline (const std::string& prompt, bool& eof) | |
3219 | 1076 { |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1077 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
|
1078 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1079 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
|
1080 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1081 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
|
1082 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
|
1083 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1084 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
|
1085 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1086 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1087 return retval; |
2926 | 1088 } |
1089 | |
1090 void | |
1091 command_editor::set_input_stream (FILE *f) | |
1092 { | |
1093 if (instance_ok ()) | |
1094 instance->do_set_input_stream (f); | |
1095 } | |
1096 | |
1097 FILE * | |
1098 command_editor::get_input_stream (void) | |
1099 { | |
1100 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1101 ? instance->do_get_input_stream () : 0; |
2926 | 1102 } |
1103 | |
1104 void | |
1105 command_editor::set_output_stream (FILE *f) | |
1106 { | |
1107 if (instance_ok ()) | |
1108 instance->do_set_output_stream (f); | |
1109 } | |
1110 | |
1111 FILE * | |
1112 command_editor::get_output_stream (void) | |
1113 { | |
1114 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1115 ? instance->do_get_output_stream () : 0; |
2926 | 1116 } |
1117 | |
16539
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1118 void |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1119 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
|
1120 { |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1121 if (instance_ok ()) |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1122 instance->do_redisplay (); |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1123 } |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1124 |
2926 | 1125 int |
1126 command_editor::terminal_rows (void) | |
1127 { | |
1128 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1129 ? instance->do_terminal_rows () : -1; |
2926 | 1130 } |
1131 | |
1132 int | |
1133 command_editor::terminal_cols (void) | |
1134 { | |
1135 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1136 ? instance->do_terminal_cols () : -1; |
2926 | 1137 } |
1138 | |
1139 void | |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16535
diff
changeset
|
1140 command_editor::clear_screen (bool skip_redisplay) |
2926 | 1141 { |
1142 if (instance_ok ()) | |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16535
diff
changeset
|
1143 instance->do_clear_screen (skip_redisplay); |
2926 | 1144 } |
1145 | |
3281 | 1146 void |
1147 command_editor::resize_terminal (void) | |
1148 { | |
1149 if (instance_ok ()) | |
1150 instance->do_resize_terminal (); | |
1151 } | |
1152 | |
19343
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1153 void |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1154 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:
19338
diff
changeset
|
1155 { |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1156 if (instance_ok ()) |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1157 instance->do_set_screen_size (ht, wd); |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1158 } |
735bc47d18af
command_editor: provide access to rl_set_screen_size
John W. Eaton <jwe@octave.org>
parents:
19338
diff
changeset
|
1159 |
3504 | 1160 std::string |
1161 command_editor::decode_prompt_string (const std::string& s) | |
2926 | 1162 { |
1163 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1164 ? instance->do_decode_prompt_string (s) : std::string (); |
2926 | 1165 } |
1166 | |
1167 int | |
1168 command_editor::current_command_number (void) | |
1169 { | |
1170 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1171 ? instance->command_number : 0; |
2926 | 1172 } |
1173 | |
1174 void | |
1175 command_editor::reset_current_command_number (int n) | |
1176 { | |
1177 if (instance_ok ()) | |
1178 instance->command_number = n; | |
1179 } | |
1180 | |
1181 void | |
2967 | 1182 command_editor::increment_current_command_number (void) |
1183 { | |
1184 if (instance_ok ()) | |
1185 instance->command_number++; | |
1186 } | |
1187 | |
1188 void | |
2926 | 1189 command_editor::restore_terminal_state (void) |
1190 { | |
1191 if (instance_ok ()) | |
1192 instance->do_restore_terminal_state (); | |
1193 } | |
1194 | |
1195 void | |
1196 command_editor::blink_matching_paren (bool flag) | |
1197 { | |
1198 if (instance_ok ()) | |
1199 instance->do_blink_matching_paren (flag); | |
1200 } | |
1201 | |
19412
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
diff
changeset
|
1202 bool |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
diff
changeset
|
1203 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:
19343
diff
changeset
|
1204 { |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
diff
changeset
|
1205 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:
19343
diff
changeset
|
1206 } |
f7ccd02bc060
provide access to the readline variable rl_erase_empty_line
John W. Eaton <jwe@octave.org>
parents:
19343
diff
changeset
|
1207 |
2926 | 1208 void |
3933 | 1209 command_editor::set_basic_word_break_characters (const std::string& s) |
1210 { | |
1211 if (instance_ok ()) | |
1212 instance->do_set_basic_word_break_characters (s); | |
1213 } | |
1214 | |
1215 void | |
1216 command_editor::set_completer_word_break_characters (const std::string& s) | |
1217 { | |
1218 if (instance_ok ()) | |
1219 instance->do_set_completer_word_break_characters (s); | |
1220 } | |
1221 | |
1222 void | |
3504 | 1223 command_editor::set_basic_quote_characters (const std::string& s) |
2926 | 1224 { |
1225 if (instance_ok ()) | |
3004 | 1226 instance->do_set_basic_quote_characters (s); |
2926 | 1227 } |
1228 | |
1229 void | |
6979 | 1230 command_editor::set_filename_quote_characters (const std::string& s) |
1231 { | |
1232 if (instance_ok ()) | |
1233 instance->do_set_filename_quote_characters (s); | |
1234 } | |
1235 | |
1236 void | |
1237 command_editor::set_completer_quote_characters (const std::string& s) | |
1238 { | |
1239 if (instance_ok ()) | |
1240 instance->do_set_completer_quote_characters (s); | |
1241 } | |
1242 | |
1243 void | |
2926 | 1244 command_editor::set_completion_append_character (char c) |
1245 { | |
1246 if (instance_ok ()) | |
1247 instance->do_set_completion_append_character (c); | |
1248 } | |
1249 | |
1250 void | |
2941 | 1251 command_editor::set_completion_function (completion_fcn f) |
2926 | 1252 { |
1253 if (instance_ok ()) | |
2941 | 1254 instance->do_set_completion_function (f); |
1255 } | |
1256 | |
6979 | 1257 void |
1258 command_editor::set_quoting_function (quoting_fcn f) | |
1259 { | |
1260 if (instance_ok ()) | |
1261 instance->do_set_quoting_function (f); | |
1262 } | |
1263 | |
1264 void | |
1265 command_editor::set_dequoting_function (dequoting_fcn f) | |
1266 { | |
1267 if (instance_ok ()) | |
1268 instance->do_set_dequoting_function (f); | |
1269 } | |
1270 | |
1271 void | |
1272 command_editor::set_char_is_quoted_function (char_is_quoted_fcn f) | |
1273 { | |
1274 if (instance_ok ()) | |
1275 instance->do_set_char_is_quoted_function (f); | |
1276 } | |
1277 | |
1278 void | |
1279 command_editor::set_user_accept_line_function (user_accept_line_fcn f) | |
1280 { | |
1281 if (instance_ok ()) | |
1282 instance->do_set_user_accept_line_function (f); | |
1283 } | |
1284 | |
2941 | 1285 command_editor::completion_fcn |
1286 command_editor::get_completion_function (void) | |
1287 { | |
1288 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1289 ? instance->do_get_completion_function () : 0; |
2926 | 1290 } |
1291 | |
6979 | 1292 command_editor::quoting_fcn |
1293 command_editor::get_quoting_function (void) | |
1294 { | |
1295 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1296 ? instance->do_get_quoting_function () : 0; |
6979 | 1297 } |
1298 | |
1299 command_editor::dequoting_fcn | |
1300 command_editor::get_dequoting_function (void) | |
1301 { | |
1302 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1303 ? instance->do_get_dequoting_function () : 0; |
6979 | 1304 } |
1305 | |
1306 command_editor::char_is_quoted_fcn | |
1307 command_editor::get_char_is_quoted_function (void) | |
1308 { | |
1309 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1310 ? instance->do_get_char_is_quoted_function () : 0; |
6979 | 1311 } |
1312 | |
1313 command_editor::user_accept_line_fcn | |
1314 command_editor::get_user_accept_line_function (void) | |
1315 { | |
1316 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1317 ? instance->do_get_user_accept_line_function () : 0; |
6979 | 1318 } |
1319 | |
4604 | 1320 string_vector |
1321 command_editor::generate_filename_completions (const std::string& text) | |
1322 { | |
1323 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1324 ? instance->do_generate_filename_completions (text) : string_vector (); |
4604 | 1325 } |
1326 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
1327 std::string |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
1328 command_editor::get_line_buffer (void) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
1329 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
1330 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
|
1331 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
1332 |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1333 std::string |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1334 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
|
1335 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1336 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
|
1337 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1338 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1339 void |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1340 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
|
1341 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1342 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
|
1343 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
|
1344 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1345 |
2926 | 1346 void |
19736
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
1347 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:
19731
diff
changeset
|
1348 { |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
1349 if (instance_ok ()) |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
1350 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:
19731
diff
changeset
|
1351 } |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
1352 |
c048358da712
also kill pending input line when gui command window is cleared (bug #44015)
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
1353 void |
3504 | 1354 command_editor::insert_text (const std::string& text) |
2926 | 1355 { |
1356 if (instance_ok ()) | |
1357 instance->do_insert_text (text); | |
1358 } | |
1359 | |
1360 void | |
1361 command_editor::newline (void) | |
1362 { | |
1363 if (instance_ok ()) | |
1364 instance->do_newline (); | |
1365 } | |
1366 | |
1367 void | |
6979 | 1368 command_editor::accept_line (void) |
1369 { | |
1370 if (instance_ok ()) | |
1371 instance->do_accept_line (); | |
1372 } | |
1373 | |
16539
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1374 bool |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1375 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
|
1376 { |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1377 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
|
1378 } |
8ea8df0747e9
make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
1379 |
6979 | 1380 void |
2926 | 1381 command_editor::clear_undo_list (void) |
1382 { | |
1383 if (instance_ok ()) | |
1384 instance->do_clear_undo_list (); | |
1385 } | |
1386 | |
1387 void | |
6913 | 1388 command_editor::add_startup_hook (startup_hook_fcn f) |
2926 | 1389 { |
1390 if (instance_ok ()) | |
6913 | 1391 { |
1392 startup_hook_set.insert (f); | |
1393 | |
1394 instance->set_startup_hook (startup_handler); | |
1395 } | |
2926 | 1396 } |
1397 | |
1398 void | |
6913 | 1399 command_editor::remove_startup_hook (startup_hook_fcn f) |
2926 | 1400 { |
1401 if (instance_ok ()) | |
6913 | 1402 { |
1403 startup_hook_set_iterator p = startup_hook_set.find (f); | |
1404 | |
1405 if (p != startup_hook_set.end ()) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1406 startup_hook_set.erase (p); |
6913 | 1407 |
1408 if (startup_hook_set.empty ()) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1409 instance->restore_startup_hook (); |
6913 | 1410 } |
2926 | 1411 } |
1412 | |
3189 | 1413 void |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1414 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
|
1415 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1416 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
|
1417 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1418 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
|
1419 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1420 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
|
1421 } |
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 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1424 void |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1425 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
|
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 (instance_ok ()) |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1428 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1429 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
|
1430 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1431 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
|
1432 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
|
1433 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1434 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
|
1435 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
|
1436 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1437 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1438 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1439 void |
6913 | 1440 command_editor::add_event_hook (event_hook_fcn f) |
3215 | 1441 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1442 octave_autolock guard (event_hook_lock); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1443 |
3215 | 1444 if (instance_ok ()) |
6913 | 1445 { |
1446 event_hook_set.insert (f); | |
1447 | |
1448 instance->set_event_hook (event_handler); | |
1449 } | |
3215 | 1450 } |
1451 | |
1452 void | |
6913 | 1453 command_editor::remove_event_hook (event_hook_fcn f) |
3215 | 1454 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1455 octave_autolock guard (event_hook_lock); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
1456 |
3215 | 1457 if (instance_ok ()) |
6913 | 1458 { |
1459 event_hook_set_iterator p = event_hook_set.find (f); | |
1460 | |
1461 if (p != event_hook_set.end ()) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1462 event_hook_set.erase (p); |
6913 | 1463 |
1464 if (event_hook_set.empty ()) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1465 instance->restore_event_hook (); |
6913 | 1466 } |
3215 | 1467 } |
1468 | |
1469 void | |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1470 command_editor::run_event_hooks (void) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1471 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1472 event_handler (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1473 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1474 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12912
diff
changeset
|
1475 void |
5872 | 1476 command_editor::read_init_file (const std::string& file_arg) |
3189 | 1477 { |
1478 if (instance_ok ()) | |
5872 | 1479 { |
1480 std::string file = file_ops::tilde_expand (file_arg); | |
1481 | |
1482 instance->do_read_init_file (file); | |
1483 } | |
3189 | 1484 } |
1485 | |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
1486 void |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
1487 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
|
1488 { |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
1489 if (instance_ok ()) |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
1490 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
|
1491 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
1492 |
4143 | 1493 bool |
1494 command_editor::filename_completion_desired (bool arg) | |
1495 { | |
1496 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1497 ? instance->do_filename_completion_desired (arg) : false; |
4143 | 1498 } |
1499 | |
6979 | 1500 bool |
1501 command_editor::filename_quoting_desired (bool arg) | |
1502 { | |
1503 return (instance_ok ()) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1504 ? instance->do_filename_quoting_desired (arg) : false; |
6979 | 1505 } |
1506 | |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1507 bool |
19336
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
1508 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
|
1509 { |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
1510 return (instance_ok ()) |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
1511 ? 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
|
1512 } |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
1513 |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
1514 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
|
1515 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
|
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 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
|
1518 |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1519 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
|
1520 { |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1521 // 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
|
1522 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
|
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 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
|
1525 |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1526 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
|
1527 } |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1528 else |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1529 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
|
1530 |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1531 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
|
1532 } |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
1533 |
2926 | 1534 // 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
|
1535 // 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
|
1536 // |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1537 // \a bell (ascii 07) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1538 // \d the date |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1539 // \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
|
1540 // \h the hostname up to the first '.' |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1541 // \H the hostname |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1542 // \n CRLF |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1543 // \r CR |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1544 // \s the name of the shell (program) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1545 // \t the time |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1546 // \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
|
1547 // \@ 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
|
1548 // \A the time in 24-hour hh:mm format |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1549 // \u your username |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1550 // \w the current working directory |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1551 // \W the last element of PWD |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1552 // \! the history number of this command |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1553 // \# the command number of this command |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1554 // \$ a $ or a # if you are root |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1555 // \nnn character code nnn in octal |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1556 // \\ a backslash |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1557 // \[ begin a sequence of non-printing chars |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1558 // \] end a sequence of non-printing chars |
2926 | 1559 |
3504 | 1560 std::string |
1561 command_editor::do_decode_prompt_string (const std::string& s) | |
2926 | 1562 { |
3504 | 1563 std::string result; |
1564 std::string temp; | |
2926 | 1565 size_t i = 0; |
1566 size_t slen = s.length (); | |
1567 int c; | |
1568 | |
1569 while (i < slen) | |
1570 { | |
1571 c = s[i]; | |
1572 | |
1573 i++; | |
1574 | |
1575 if (c == '\\') | |
10314
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 c = s[i]; |
2926 | 1578 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1579 switch (c) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1580 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1581 case '0': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1582 case '1': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1583 case '2': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1584 case '3': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1585 case '4': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1586 case '5': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1587 case '6': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1588 case '7': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1589 // Maybe convert an octal number. |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1590 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1591 int n = read_octal (s.substr (i, 3)); |
2926 | 1592 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1593 temp = "\\"; |
2926 | 1594 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1595 if (n != -1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1596 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1597 i += 3; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1598 temp[0] = n; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1599 } |
2926 | 1600 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1601 c = 0; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1602 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1603 } |
5442 | 1604 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1605 case 'a': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1606 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1607 temp = '\a'; |
5442 | 1608 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1609 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1610 } |
5442 | 1611 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1612 case 'e': |
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 temp = '\033'; |
5442 | 1615 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1616 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1617 } |
5442 | 1618 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1619 case 'r': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1620 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1621 temp = '\r'; |
5442 | 1622 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1623 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1624 } |
5442 | 1625 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1626 case 'd': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1627 case 't': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1628 case 'T': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1629 case '@': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1630 case 'A': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1631 // Make the current time/date into a string. |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1632 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1633 octave_localtime now; |
2926 | 1634 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1635 if (c == 'd') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1636 temp = now.strftime ("%a %b %d"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1637 else if (c == 't') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1638 temp = now.strftime ("%H:%M:%S"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1639 else if (c == 'T') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1640 temp = now.strftime ("%I:%M:%S"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1641 else if (c == '@') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1642 temp = now.strftime ("%I:%M %p"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1643 else if (c == 'A') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1644 temp = now.strftime ("%H:%M"); |
2926 | 1645 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1646 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1647 } |
2926 | 1648 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1649 case 'n': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1650 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1651 temp = newline_chars (); |
2926 | 1652 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1653 goto add_string; |
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 's': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1657 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1658 temp = octave_env::get_program_name (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1659 temp = octave_env::base_pathname (temp); |
2926 | 1660 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1661 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1662 } |
5442 | 1663 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1664 case 'w': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1665 case 'W': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1666 { |
17644
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1667 try |
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1668 { |
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1669 temp = octave_env::get_current_directory (); |
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1670 } |
20569
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
19820
diff
changeset
|
1671 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
|
1672 { |
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1673 temp = ""; |
ca9a9c0740c5
Fix infinite loop when PS1 needs deleted directory (bug #32176)
Mike Miller <mtmiller@ieee.org>
parents:
16570
diff
changeset
|
1674 } |
2926 | 1675 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1676 std::string home_dir = octave_env::get_home_directory (); |
5442 | 1677 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1678 if (c == 'W' && (home_dir.empty () || temp != home_dir)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1679 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1680 if (temp != "/" && temp != "//") |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1681 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1682 size_t pos = temp.rfind ('/'); |
2926 | 1683 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1684 if (pos != std::string::npos && pos != 0) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1685 temp = temp.substr (pos + 1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1686 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1687 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1688 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1689 temp = octave_env::polite_directory_format (temp); |
2926 | 1690 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1691 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1692 } |
5442 | 1693 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1694 case 'u': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1695 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1696 temp = octave_env::get_user_name (); |
2926 | 1697 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1698 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1699 } |
2926 | 1700 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1701 case 'H': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1702 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1703 temp = octave_env::get_host_name (); |
2926 | 1704 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1705 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1706 } |
2926 | 1707 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1708 case 'h': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1709 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1710 temp = octave_env::get_host_name (); |
2926 | 1711 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1712 size_t pos = temp.find ('.'); |
2926 | 1713 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1714 if (pos != std::string::npos) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1715 temp.resize (pos); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1716 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1717 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1718 } |
2926 | 1719 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1720 case '#': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1721 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1722 char number_buffer[128]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1723 sprintf (number_buffer, "%d", command_number); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1724 temp = number_buffer; |
2926 | 1725 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1726 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1727 } |
2926 | 1728 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1729 case '!': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1730 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1731 char number_buffer[128]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1732 int num = command_history::current_number (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1733 if (num > 0) |
2926 | 1734 sprintf (number_buffer, "%d", num); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1735 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1736 strcpy (number_buffer, "!"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1737 temp = number_buffer; |
2926 | 1738 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1739 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1740 } |
2926 | 1741 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1742 case '$': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1743 { |
4062 | 1744 #if defined (HAVE_GETEUID) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1745 temp = (::geteuid () == 0 ? "#" : "$"); |
4062 | 1746 #else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1747 temp = "$"; |
4062 | 1748 #endif |
2926 | 1749 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1750 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1751 } |
2926 | 1752 |
1753 #if defined (USE_READLINE) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1754 case '[': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1755 case ']': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1756 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1757 temp.resize (1); |
2926 | 1758 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1759 temp[0] = ((c == '[') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1760 ? ::octave_rl_prompt_start_ignore () |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1761 : ::octave_rl_prompt_end_ignore ()); |
2926 | 1762 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1763 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1764 } |
2926 | 1765 #endif |
1766 | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1767 case '\\': |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1768 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1769 temp = "\\"; |
2926 | 1770 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1771 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1772 } |
2926 | 1773 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1774 default: |
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 temp = "\\ "; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1777 temp[1] = c; |
2926 | 1778 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1779 goto add_string; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1780 } |
2926 | 1781 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1782 add_string: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1783 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1784 if (c) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1785 i++; |
2926 | 1786 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1787 result.append (temp); |
2926 | 1788 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1789 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1790 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1791 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1792 } |
2926 | 1793 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1794 result += c; |
2926 | 1795 } |
1796 | |
1797 return result; | |
1798 } | |
1799 | |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1800 int |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1801 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
|
1802 { |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1803 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
|
1804 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1805 initial_input = ""; |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1806 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1807 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
|
1808 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1809 // 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
|
1810 do_redisplay (); |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1811 |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1812 return 0; |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1813 } |
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16539
diff
changeset
|
1814 |
2926 | 1815 // Return the octal number parsed from STRING, or -1 to indicate that |
1816 // the string contained a bad number. | |
1817 | |
1818 int | |
3504 | 1819 command_editor::read_octal (const std::string& s) |
2926 | 1820 { |
1821 int result = 0; | |
1822 int digits = 0; | |
1823 | |
1824 size_t i = 0; | |
1825 size_t slen = s.length (); | |
1826 | |
1827 while (i < slen && s[i] >= '0' && s[i] < '8') | |
1828 { | |
1829 digits++; | |
1830 result = (result * 8) + s[i] - '0'; | |
1831 i++; | |
1832 } | |
1833 | |
1834 if (! digits || result > 0777 || i < slen) | |
1835 result = -1; | |
1836 | |
1837 return result; | |
1838 } | |
1839 | |
1840 void | |
1841 command_editor::error (int err_num) | |
1842 { | |
10411 | 1843 current_liboctave_error_handler ("%s", gnulib::strerror (err_num)); |
2926 | 1844 } |
1845 | |
1846 void | |
3504 | 1847 command_editor::error (const std::string& s) |
2926 | 1848 { |
2941 | 1849 current_liboctave_error_handler ("%s", s.c_str ()); |
2926 | 1850 } |