Mercurial > hg > octave-max
annotate liboctave/cmd-edit.cc @ 11188:4cb1522e4d0f
Use function handle as input to cellfun,
rather than quoted function name or anonymous function wrapper.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 03 Nov 2010 17:20:56 -0700 |
parents | bbe99b2a5ba7 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
2926 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, |
8920 | 4 2006, 2007, 2008, 2009 John W. Eaton |
2926 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2926 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2926 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
28 #include <cstdlib> |
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
29 #include <cstring> |
2926 | 30 |
31 #include <string> | |
32 | |
33 #include <sys/types.h> | |
34 #include <unistd.h> | |
35 | |
5247 | 36 #include "quit.h" |
37 | |
2926 | 38 #include "cmd-edit.h" |
39 #include "cmd-hist.h" | |
5872 | 40 #include "file-ops.h" |
2926 | 41 #include "lo-error.h" |
42 #include "lo-utils.h" | |
43 #include "oct-env.h" | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
44 #include "oct-mutex.h" |
3260 | 45 #include "oct-time.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 | |
51 std::set<command_editor::event_hook_fcn> command_editor::event_hook_set; | |
52 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
53 static octave_mutex event_hook_lock; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7758
diff
changeset
|
54 |
2926 | 55 #if defined (USE_READLINE) |
56 | |
57 #include <cstdio> | |
58 #include <cstdlib> | |
59 | |
3519 | 60 #include "oct-rl-edit.h" |
2926 | 61 |
62 class | |
63 gnu_readline : public command_editor | |
64 { | |
65 public: | |
66 | |
3519 | 67 typedef command_editor::startup_hook_fcn startup_hook_fcn; |
68 | |
6913 | 69 typedef command_editor::event_hook_fcn event_hook_fcn; |
2926 | 70 |
2941 | 71 typedef command_editor::completion_fcn completion_fcn; |
72 | |
2926 | 73 gnu_readline (void); |
74 | |
75 ~gnu_readline (void) { } | |
76 | |
3504 | 77 void do_set_name (const std::string& n); |
2926 | 78 |
3504 | 79 std::string do_readline (const std::string& prompt, bool& eof); |
2926 | 80 |
81 void do_set_input_stream (FILE *f); | |
82 | |
83 FILE *do_get_input_stream (void); | |
84 | |
85 void do_set_output_stream (FILE *f); | |
86 | |
87 FILE *do_get_output_stream (void); | |
88 | |
89 int do_terminal_rows (void); | |
90 | |
91 int do_terminal_cols (void); | |
92 | |
93 void do_clear_screen (void); | |
94 | |
3281 | 95 void do_resize_terminal (void); |
96 | |
3504 | 97 std::string newline_chars (void); |
2926 | 98 |
99 void do_restore_terminal_state (void); | |
100 | |
101 void do_blink_matching_paren (bool flag); | |
102 | |
3933 | 103 void do_set_basic_word_break_characters (const std::string& s); |
104 | |
105 void do_set_completer_word_break_characters (const std::string& s); | |
106 | |
3504 | 107 void do_set_basic_quote_characters (const std::string& s); |
2926 | 108 |
6979 | 109 void do_set_filename_quote_characters (const std::string& s); |
110 | |
111 void do_set_completer_quote_characters (const std::string& s); | |
112 | |
2926 | 113 void do_set_completion_append_character (char c); |
114 | |
2941 | 115 void do_set_completion_function (completion_fcn f); |
116 | |
6979 | 117 void do_set_quoting_function (quoting_fcn f); |
118 | |
119 void do_set_dequoting_function (dequoting_fcn f); | |
120 | |
121 void do_set_char_is_quoted_function (char_is_quoted_fcn f); | |
122 | |
123 void do_set_user_accept_line_function (user_accept_line_fcn f); | |
124 | |
2941 | 125 completion_fcn do_get_completion_function (void) const; |
2926 | 126 |
6979 | 127 quoting_fcn do_get_quoting_function (void) const; |
128 | |
129 dequoting_fcn do_get_dequoting_function (void) const; | |
130 | |
131 char_is_quoted_fcn do_get_char_is_quoted_function (void) const; | |
132 | |
133 user_accept_line_fcn do_get_user_accept_line_function (void) const; | |
134 | |
4604 | 135 string_vector |
136 do_generate_filename_completions (const std::string& text); | |
137 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
138 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
|
139 |
3504 | 140 void do_insert_text (const std::string& text); |
2926 | 141 |
142 void do_newline (void); | |
143 | |
6979 | 144 void do_accept_line (void); |
145 | |
2926 | 146 void do_clear_undo_list (void); |
147 | |
6913 | 148 void set_startup_hook (startup_hook_fcn f); |
149 | |
150 void restore_startup_hook (void); | |
2926 | 151 |
6913 | 152 void set_event_hook (event_hook_fcn f); |
2926 | 153 |
6913 | 154 void restore_event_hook (void); |
3215 | 155 |
156 void do_restore_event_hook (void); | |
157 | |
3504 | 158 void do_read_init_file (const std::string& file); |
3189 | 159 |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
160 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
|
161 |
4143 | 162 bool do_filename_completion_desired (bool); |
163 | |
6979 | 164 bool do_filename_quoting_desired (bool); |
165 | |
3519 | 166 static int operate_and_get_next (int, int); |
2926 | 167 |
3951 | 168 static int history_search_backward (int, int); |
169 | |
170 static int history_search_forward (int, int); | |
171 | |
2926 | 172 private: |
173 | |
3519 | 174 startup_hook_fcn previous_startup_hook; |
2926 | 175 |
3519 | 176 event_hook_fcn previous_event_hook; |
3215 | 177 |
2941 | 178 completion_fcn completion_function; |
179 | |
6979 | 180 quoting_fcn quoting_function; |
181 | |
182 dequoting_fcn dequoting_function; | |
183 | |
184 char_is_quoted_fcn char_is_quoted_function; | |
185 | |
186 user_accept_line_fcn user_accept_line_function; | |
187 | |
2941 | 188 static char *command_generator (const char *text, int state); |
189 | |
6979 | 190 static char *command_quoter (char *text, int match_type, char *quote_pointer); |
191 static char *command_dequoter (char *text, int match_type); | |
192 | |
193 static int command_char_is_quoted (char *text, int index); | |
194 | |
195 static int command_accept_line (int count, int key); | |
196 | |
3519 | 197 static char **command_completer (const char *text, int start, int end); |
2926 | 198 }; |
199 | |
200 gnu_readline::gnu_readline () | |
3215 | 201 : command_editor (), previous_startup_hook (0), |
6979 | 202 previous_event_hook (0), completion_function (0), |
203 quoting_function (0), dequoting_function (0), | |
204 char_is_quoted_function (0), user_accept_line_function (0) | |
2926 | 205 { |
5775 | 206 // FIXME -- need interface to rl_add_defun, rl_initialize, and |
3519 | 207 // a function to set rl_terminal_name |
3225 | 208 |
3520 | 209 std::string term = octave_env::getenv ("TERM"); |
3519 | 210 |
211 octave_rl_set_terminal_name (term.c_str ()); | |
212 | |
213 octave_rl_initialize (); | |
2926 | 214 |
215 do_blink_matching_paren (true); | |
216 | |
5452 | 217 // Bind operate-and-get-next. |
2926 | 218 |
3519 | 219 octave_rl_add_defun ("operate-and-get-next", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
220 gnu_readline::operate_and_get_next, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
221 octave_rl_ctrl ('O')); |
2926 | 222 |
5452 | 223 // And the history search functions. |
2926 | 224 |
3519 | 225 octave_rl_add_defun ("history-search-backward", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
226 gnu_readline::history_search_backward, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
227 octave_rl_meta ('P')); |
2926 | 228 |
3519 | 229 octave_rl_add_defun ("history-search-forward", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
230 gnu_readline::history_search_forward, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
231 octave_rl_meta ('N')); |
2926 | 232 } |
233 | |
234 void | |
3519 | 235 gnu_readline::do_set_name (const std::string& nm) |
2926 | 236 { |
3519 | 237 ::octave_rl_set_name (nm.c_str ()); |
2926 | 238 } |
239 | |
3504 | 240 std::string |
241 gnu_readline::do_readline (const std::string& prompt, bool& eof) | |
2926 | 242 { |
3504 | 243 std::string retval; |
2926 | 244 |
3219 | 245 eof = false; |
246 | |
5247 | 247 char *line = 0; |
248 | |
5336 | 249 const char *p = prompt.c_str (); |
250 | |
5452 | 251 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
5247 | 252 |
5336 | 253 line = ::octave_rl_readline (p); |
5247 | 254 |
5452 | 255 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
2926 | 256 |
257 if (line) | |
258 { | |
259 retval = line; | |
260 | |
261 free (line); | |
262 } | |
3219 | 263 else |
264 eof = true; | |
2926 | 265 |
266 return retval; | |
267 } | |
268 | |
269 void | |
270 gnu_readline::do_set_input_stream (FILE *f) | |
271 { | |
3519 | 272 ::octave_rl_set_input_stream (f); |
2926 | 273 } |
274 | |
275 FILE * | |
276 gnu_readline::do_get_input_stream (void) | |
277 { | |
3519 | 278 return ::octave_rl_get_input_stream (); |
2926 | 279 } |
280 | |
281 void | |
282 gnu_readline::do_set_output_stream (FILE *f) | |
283 { | |
3519 | 284 ::octave_rl_set_output_stream (f); |
2926 | 285 } |
286 | |
287 FILE * | |
288 gnu_readline::do_get_output_stream (void) | |
289 { | |
3519 | 290 return ::octave_rl_get_output_stream (); |
2926 | 291 } |
292 | |
293 // GNU readline handles SIGWINCH, so these values have a good chance | |
294 // of being correct even if the window changes size (they may be | |
295 // wrong if, for example, the luser changes the window size while the | |
296 // pager is running, and the signal is handled by the pager instead of | |
297 // us. | |
298 | |
299 int | |
300 gnu_readline::do_terminal_rows (void) | |
301 { | |
3519 | 302 int sh = ::octave_rl_screen_height (); |
303 | |
304 return sh > 0 ? sh : 24; | |
2926 | 305 } |
306 | |
307 int | |
308 gnu_readline::do_terminal_cols (void) | |
309 { | |
3519 | 310 int sw = ::octave_rl_screen_width (); |
311 | |
312 return sw > 0 ? sw : 80; | |
2926 | 313 } |
314 | |
315 void | |
316 gnu_readline::do_clear_screen (void) | |
317 { | |
3519 | 318 ::octave_rl_clear_screen (); |
2926 | 319 } |
320 | |
3281 | 321 void |
322 gnu_readline::do_resize_terminal (void) | |
323 { | |
3519 | 324 ::octave_rl_resize_terminal (); |
3281 | 325 } |
326 | |
3504 | 327 std::string |
2926 | 328 gnu_readline::newline_chars (void) |
329 { | |
330 return "\r\n"; | |
331 } | |
332 | |
333 void | |
334 gnu_readline::do_restore_terminal_state (void) | |
335 { | |
3519 | 336 ::octave_rl_restore_terminal_state (); |
2926 | 337 } |
338 | |
339 void | |
340 gnu_readline::do_blink_matching_paren (bool flag) | |
341 { | |
3779 | 342 ::octave_rl_enable_paren_matching (flag ? 1 : 0); |
2926 | 343 } |
344 | |
345 void | |
3933 | 346 gnu_readline::do_set_basic_word_break_characters (const std::string& s) |
347 { | |
348 ::octave_rl_set_basic_word_break_characters (s.c_str ()); | |
349 } | |
350 | |
351 void | |
352 gnu_readline::do_set_completer_word_break_characters (const std::string& s) | |
353 { | |
354 ::octave_rl_set_completer_word_break_characters (s.c_str ()); | |
355 } | |
356 | |
357 void | |
3504 | 358 gnu_readline::do_set_basic_quote_characters (const std::string& s) |
2926 | 359 { |
3519 | 360 ::octave_rl_set_basic_quote_characters (s.c_str ()); |
2926 | 361 } |
362 | |
363 void | |
6979 | 364 gnu_readline::do_set_filename_quote_characters (const std::string& s) |
365 { | |
366 ::octave_rl_set_filename_quote_characters (s.c_str ()); | |
367 } | |
368 | |
369 void | |
370 gnu_readline::do_set_completer_quote_characters (const std::string& s) | |
371 { | |
372 ::octave_rl_set_completer_quote_characters (s.c_str ()); | |
373 } | |
374 | |
375 void | |
2926 | 376 gnu_readline::do_set_completion_append_character (char c) |
377 { | |
3519 | 378 ::octave_rl_set_completion_append_character (c); |
2926 | 379 } |
380 | |
381 void | |
2941 | 382 gnu_readline::do_set_completion_function (completion_fcn f) |
2926 | 383 { |
2941 | 384 completion_function = f; |
385 | |
3519 | 386 rl_attempted_completion_fcn_ptr fp |
387 = f ? gnu_readline::command_completer : 0; | |
2941 | 388 |
3519 | 389 ::octave_rl_set_completion_function (fp); |
2941 | 390 } |
391 | |
6979 | 392 void |
393 gnu_readline::do_set_quoting_function (quoting_fcn f) | |
394 { | |
395 quoting_function = f; | |
396 | |
397 rl_quoting_fcn_ptr fp | |
398 = f ? gnu_readline::command_quoter : 0; | |
399 | |
400 ::octave_rl_set_quoting_function (fp); | |
401 } | |
402 | |
403 void | |
404 gnu_readline::do_set_dequoting_function (dequoting_fcn f) | |
405 { | |
406 dequoting_function = f; | |
407 | |
408 rl_dequoting_fcn_ptr fp | |
409 = f ? gnu_readline::command_dequoter : 0; | |
410 | |
411 ::octave_rl_set_dequoting_function (fp); | |
412 } | |
413 | |
414 void | |
415 gnu_readline::do_set_char_is_quoted_function (char_is_quoted_fcn f) | |
416 { | |
417 char_is_quoted_function = f; | |
418 | |
419 rl_char_is_quoted_fcn_ptr fp | |
420 = f ? gnu_readline::command_char_is_quoted : 0; | |
421 | |
422 ::octave_rl_set_char_is_quoted_function (fp); | |
423 } | |
424 | |
425 void | |
426 gnu_readline::do_set_user_accept_line_function (user_accept_line_fcn f) | |
427 { | |
428 user_accept_line_function = f; | |
429 | |
430 if (f) | |
431 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
|
432 ::octave_rl_ctrl ('M')); |
6979 | 433 else |
434 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
|
435 ::octave_rl_ctrl ('M')); |
6979 | 436 } |
437 | |
2941 | 438 gnu_readline::completion_fcn |
439 gnu_readline::do_get_completion_function (void) const | |
440 { | |
441 return completion_function; | |
2926 | 442 } |
443 | |
6979 | 444 gnu_readline::quoting_fcn |
445 gnu_readline::do_get_quoting_function (void) const | |
446 { | |
447 return quoting_function; | |
448 } | |
449 | |
450 gnu_readline::dequoting_fcn | |
451 gnu_readline::do_get_dequoting_function (void) const | |
452 { | |
453 return dequoting_function; | |
454 } | |
455 | |
456 gnu_readline::char_is_quoted_fcn | |
457 gnu_readline::do_get_char_is_quoted_function (void) const | |
458 { | |
459 return char_is_quoted_function; | |
460 } | |
461 | |
462 gnu_readline::user_accept_line_fcn | |
463 gnu_readline::do_get_user_accept_line_function (void) const | |
464 { | |
465 return user_accept_line_function; | |
466 } | |
467 | |
4604 | 468 string_vector |
469 gnu_readline::do_generate_filename_completions (const std::string& text) | |
470 { | |
471 string_vector retval; | |
472 | |
473 int n = 0; | |
474 int count = 0; | |
475 | |
476 char *fn = 0; | |
477 | |
478 while (1) | |
479 { | |
480 fn = ::octave_rl_filename_completion_function (text.c_str (), count); | |
481 | |
482 if (fn) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
483 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
484 if (count == n) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
485 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
486 // Famous last words: Most large directories will not |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
487 // 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
|
488 // resize too many times even if the growth is linear... |
4604 | 489 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
490 n += 100; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
491 retval.resize (n); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
492 } |
4604 | 493 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
494 retval[count++] = fn; |
4604 | 495 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
496 free (fn); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
497 } |
4604 | 498 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
499 break; |
4604 | 500 } |
501 | |
502 retval.resize (count); | |
503 | |
504 return retval; | |
505 } | |
506 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
507 std::string |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
508 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
|
509 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
510 return ::octave_rl_line_buffer (); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
511 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
512 |
2926 | 513 void |
3504 | 514 gnu_readline::do_insert_text (const std::string& text) |
2926 | 515 { |
3519 | 516 ::octave_rl_insert_text (text.c_str ()); |
2926 | 517 } |
518 | |
519 void | |
520 gnu_readline::do_newline (void) | |
521 { | |
6979 | 522 ::octave_rl_newline (1, '\n'); |
523 } | |
524 | |
525 void | |
526 gnu_readline::do_accept_line (void) | |
527 { | |
528 command_accept_line (1, '\n'); | |
2926 | 529 } |
530 | |
531 void | |
532 gnu_readline::do_clear_undo_list () | |
533 { | |
3519 | 534 ::octave_rl_clear_undo_list (); |
2926 | 535 } |
536 | |
537 void | |
6913 | 538 gnu_readline::set_startup_hook (startup_hook_fcn f) |
2926 | 539 { |
3519 | 540 previous_startup_hook = ::octave_rl_get_startup_hook (); |
2926 | 541 |
6917 | 542 if (f != previous_startup_hook) |
543 ::octave_rl_set_startup_hook (f); | |
2926 | 544 } |
545 | |
546 void | |
6913 | 547 gnu_readline::restore_startup_hook (void) |
2926 | 548 { |
3519 | 549 ::octave_rl_set_startup_hook (previous_startup_hook); |
2926 | 550 } |
551 | |
552 void | |
6913 | 553 gnu_readline::set_event_hook (event_hook_fcn f) |
3215 | 554 { |
3519 | 555 previous_event_hook = octave_rl_get_event_hook (); |
3215 | 556 |
3519 | 557 ::octave_rl_set_event_hook (f); |
3215 | 558 } |
559 | |
560 void | |
6913 | 561 gnu_readline::restore_event_hook (void) |
3215 | 562 { |
3519 | 563 ::octave_rl_set_event_hook (previous_event_hook); |
3215 | 564 } |
565 | |
566 void | |
3504 | 567 gnu_readline::do_read_init_file (const std::string& file) |
3189 | 568 { |
3519 | 569 ::octave_rl_read_init_file (file.c_str ()); |
3189 | 570 } |
571 | |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
572 void |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
573 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
|
574 { |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
575 ::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
|
576 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
577 |
4143 | 578 bool |
579 gnu_readline::do_filename_completion_desired (bool arg) | |
580 { | |
581 return ::octave_rl_filename_completion_desired (arg); | |
582 } | |
583 | |
6979 | 584 bool |
585 gnu_readline::do_filename_quoting_desired (bool arg) | |
586 { | |
587 return ::octave_rl_filename_quoting_desired (arg); | |
588 } | |
589 | |
3519 | 590 int |
2926 | 591 gnu_readline::operate_and_get_next (int /* count */, int /* c */) |
592 { | |
593 // Accept the current line. | |
594 | |
6979 | 595 command_editor::accept_line (); |
2926 | 596 |
597 // Find the current line, and find the next line to use. | |
598 | |
599 int x_where = command_history::where (); | |
600 | |
601 int x_length = command_history::length (); | |
602 | |
603 if ((command_history::is_stifled () | |
604 && (x_length >= command_history::max_input_history ())) | |
605 || (x_where >= x_length - 1)) | |
606 command_history::set_mark (x_where); | |
607 else | |
608 command_history::set_mark (x_where + 1); | |
609 | |
6913 | 610 command_editor::add_startup_hook (command_history::goto_mark); |
3519 | 611 |
612 return 0; | |
2926 | 613 } |
614 | |
3951 | 615 int |
616 gnu_readline::history_search_backward (int count, int c) | |
617 { | |
618 return octave_rl_history_search_backward (count, c); | |
619 } | |
620 | |
621 int | |
622 gnu_readline::history_search_forward (int count, int c) | |
623 { | |
624 return octave_rl_history_search_forward (count, c); | |
625 } | |