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