Mercurial > octave
annotate libinterp/corefcn/input.cc @ 27272:9de4741a896e
Do not ignore user preferences for locale encoding on non-Windows platforms.
* gui-preferences.h, resource-manager.cc (do_combo_encoding),
file-editor-tab.cc (file_editor_tab), input.cc (input_system, mfile_encoding):
Remove special case for non-Windows platforms.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 21 Jul 2019 12:43:19 +0200 |
parents | 99aa1bcb8848 |
children | a2b1ba6c92d5 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26358
diff
changeset
|
3 Copyright (C) 1993-2019 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24362
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:
22407
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:
24362
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:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
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:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 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:
24362
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
1 | 20 |
21 */ | |
22 | |
2939 | 23 // Get command input interactively or from files. |
1 | 24 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21547
diff
changeset
|
25 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
26 # include "config.h" |
1 | 27 #endif |
28 | |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
29 #include <cstdio> |
1343 | 30 #include <cstdlib> |
31 #include <cstring> | |
32 #include <cassert> | |
33 | |
3503 | 34 #include <iostream> |
5765 | 35 #include <sstream> |
1728 | 36 #include <string> |
37 | |
2927 | 38 #include "cmd-edit.h" |
3189 | 39 #include "file-ops.h" |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
40 #include "iconv-wrappers.h" |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
41 #include "localcharset-wrapper.h" |
4153 | 42 #include "quit.h" |
1755 | 43 #include "str-vec.h" |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
44 #include "uniconv-wrappers.h" |
1755 | 45 |
23129
35e3d199527c
Replace feval calls with direct call to C++ function (bug #50116).
Rik <rik@octave.org>
parents:
23127
diff
changeset
|
46 #include "builtin-defun-decls.h" |
1352 | 47 #include "defun.h" |
48 #include "dirfns.h" | |
1 | 49 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
50 #include "errwarn.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
51 #include "event-manager.h" |
3016 | 52 #include "help.h" |
16381
f33dcbd6a005
move hook_function classes to separate file
John W. Eaton <jwe@octave.org>
parents:
16378
diff
changeset
|
53 #include "hook-fcn.h" |
1 | 54 #include "input.h" |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
55 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
56 #include "interpreter.h" |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
57 #include "lex.h" |
5832 | 58 #include "load-path.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
59 #include "octave.h" |
1352 | 60 #include "oct-map.h" |
1742 | 61 #include "oct-hist.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
62 #include "interpreter.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
63 #include "event-manager.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
64 #include "ovl.h" |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
65 #include "ov-fcn-handle.h" |
23127
5a91168a30be
avoid including parse tree headers in other header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
66 #include "ov-usr-fcn.h" |
1 | 67 #include "pager.h" |
529 | 68 #include "parse.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
69 #include "pt-eval.h" |
3805 | 70 #include "pt-stmt.h" |
1352 | 71 #include "sighandlers.h" |
1114 | 72 #include "sysdep.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
73 #include "interpreter.h" |
3098 | 74 #include "unwind-prot.h" |
1352 | 75 #include "utils.h" |
76 #include "variables.h" | |
529 | 77 |
3165 | 78 // The time we last printed a prompt. |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 octave::sys::time Vlast_prompt_time = 0.0; |
3165 | 80 |
3804 | 81 // TRUE after a call to completion_matches. |
2299 | 82 bool octave_completion_matches_called = false; |
83 | |
6257 | 84 // TRUE if the plotting system has requested a call to drawnow at |
85 // the next user prompt. | |
7409 | 86 bool Vdrawnow_requested = false; |
6257 | 87 |
22164
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
88 // TRUE if we are recording line numbers in a source file. |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
89 // Always true except when debugging and taking input directly from |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
90 // the terminal. |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
91 bool Vtrack_line_num = true; |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
92 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
93 namespace octave |
6257 | 94 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
95 static std::string |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
96 quoting_filename (const std::string& text, int, char quote) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
97 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
98 if (quote) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
99 return text; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
100 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
101 return ("'" + text); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
102 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
103 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
104 // Try to parse a partial command line in reverse, excluding trailing TEXT. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
105 // If it appears a variable has been indexed by () or {}, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
106 // return that expression, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
107 // to allow autocomplete of field names of arrays of structures. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
108 static std::string |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
109 find_indexed_expression (const std::string& text) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
110 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
111 std::string line = command_editor::get_line_buffer (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
112 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
113 int pos = line.length () - text.length (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
114 int curly_count = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
115 int paren_count = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
116 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
117 int last = --pos; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
118 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
119 while (pos >= 0 && (line[pos] == ')' || line[pos] == '}')) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
120 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
121 if (line[pos] == ')') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
122 paren_count++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
123 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
124 curly_count++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
125 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
126 while (curly_count + paren_count > 0 && --pos >= 0) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
127 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
128 if (line[pos] == ')') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
129 paren_count++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
130 else if (line[pos] == '(') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
131 paren_count--; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
132 else if (line[pos] == '}') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
133 curly_count++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
134 else if (line[pos] == '{') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
135 curly_count--; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
136 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
137 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
138 while (--pos >= 0 && line[pos] == ' ') |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
139 ; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
140 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
141 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
142 while (pos >= 0 && (isalnum (line[pos]) || line[pos] == '_')) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
143 pos--; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
144 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
145 if (++pos >= 0) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
146 return (line.substr (pos, last + 1 - pos)); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
147 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
148 return std::string (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
149 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
150 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
151 static string_vector |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
152 generate_struct_completions (const std::string& text, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
153 std::string& prefix, std::string& hint) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
154 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
155 string_vector names; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
156 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
157 size_t pos = text.rfind ('.'); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
158 bool array = false; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
159 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
160 if (pos != std::string::npos) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
161 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
162 if (pos == text.length ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
163 hint = ""; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
164 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
165 hint = text.substr (pos+1); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
166 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
167 prefix = text.substr (0, pos); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
168 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
169 if (prefix == "") |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
170 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
171 array = true; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
172 prefix = find_indexed_expression (text); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
173 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
174 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
175 std::string base_name = prefix; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
176 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
177 pos = base_name.find_first_of ("{(. "); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
178 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
179 if (pos != std::string::npos) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
180 base_name = base_name.substr (0, pos); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
181 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
182 interpreter& interp |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
183 = __get_interpreter__ ("generate_struct_completions"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
184 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
185 if (interp.is_variable (base_name)) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
186 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
187 int parse_status; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
188 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
189 error_system& es = interp.get_error_system (); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
190 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
191 unwind_protect frame; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
192 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
193 frame.add_method (es, &error_system::set_discard_error_messages, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
194 es.discard_error_messages ()); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
195 frame.add_method (es, &error_system::set_discard_warning_messages, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
196 es.discard_warning_messages ()); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
197 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
198 es.discard_error_messages (true); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
199 es.discard_warning_messages (true); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
200 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
201 try |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
202 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
203 octave_value tmp |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
204 = interp.eval_string (prefix, true, parse_status); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
205 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
206 frame.run (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
207 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
208 if (tmp.is_defined () |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
209 && (tmp.isstruct () || tmp.isjava () || tmp.is_classdef_object ())) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
210 names = tmp.map_keys (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
211 } |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
212 catch (const execution_exception&) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
213 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
214 interpreter::recover_from_exception (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
215 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
216 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
217 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
218 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
219 // Undo look-back that found the array expression, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
220 // but insert an extra "." to distinguish from the non-struct case. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
221 if (array) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
222 prefix = "."; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
223 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
224 return names; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
225 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
226 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
227 // FIXME: this will have to be much smarter to work "correctly". |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
228 static bool |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
229 looks_like_struct (const std::string& text, char prev_char) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
230 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
231 bool retval = (! text.empty () |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
232 && (text != "." || prev_char == ')' || prev_char == '}') |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
233 && text.find_first_of (sys::file_ops::dir_sep_chars ()) == std::string::npos |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
234 && text.find ("..") == std::string::npos |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
235 && text.rfind ('.') != std::string::npos); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
236 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
237 return retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
238 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
239 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
240 // FIXME: make this generate filenames when appropriate. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
241 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
242 static string_vector |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
243 generate_possible_completions (const std::string& text, std::string& prefix, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
244 std::string& hint, bool& deemed_struct) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
245 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
246 string_vector names; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
247 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
248 prefix = ""; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
249 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
250 char prev_char = command_editor::get_prev_char (text.length ()); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
251 deemed_struct = looks_like_struct (text, prev_char); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
252 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
253 if (deemed_struct) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
254 names = generate_struct_completions (text, prefix, hint); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
255 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
256 names = make_name_list (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
257 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
258 // Sort and remove duplicates. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
259 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
260 names.sort (true); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
261 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
262 return names; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
263 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
264 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
265 static bool |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
266 is_completing_dirfns (void) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
267 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
268 static std::string dirfns_commands[] = {"cd", "isfile", "isfolder", "ls"}; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
269 static const size_t dirfns_commands_length = 4; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
270 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
271 bool retval = false; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
272 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
273 std::string line = command_editor::get_line_buffer (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
274 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
275 for (size_t i = 0; i < dirfns_commands_length; i++) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
276 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
277 int index = line.find (dirfns_commands[i] + ' '); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
278 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
279 if (index == 0) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
280 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
281 retval = true; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
282 break; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
283 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
284 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
285 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
286 return retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
287 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
288 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
289 static std::string |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
290 generate_completion (const std::string& text, int state) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
291 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
292 std::string retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
293 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
294 static std::string prefix; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
295 static std::string hint; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
296 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
297 static size_t hint_len = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
298 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
299 static int list_index = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
300 static int name_list_len = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
301 static int name_list_total_len = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
302 static string_vector name_list; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
303 static string_vector file_name_list; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
304 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
305 static int matches = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
306 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
307 if (state == 0) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
308 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
309 list_index = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
310 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
311 prefix = ""; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
312 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
313 hint = text; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
314 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
315 // No reason to display symbols while completing a |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
316 // file/directory operation. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
317 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
318 bool deemed_struct = false; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
319 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
320 if (is_completing_dirfns ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
321 name_list = string_vector (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
322 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
323 name_list = generate_possible_completions (text, prefix, hint, |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
324 deemed_struct); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
325 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
326 name_list_len = name_list.numel (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
327 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
328 // If the line was something like "a{1}." then text = "." but |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
329 // we don't want to expand all the . files. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
330 if (! deemed_struct) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
331 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
332 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
333 file_name_list = command_editor::generate_filename_completions (text); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
334 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
335 name_list.append (file_name_list); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
336 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
337 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
338 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
339 name_list_total_len = name_list.numel (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
340 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
341 hint_len = hint.length (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
342 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
343 matches = 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
344 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
345 for (int i = 0; i < name_list_len; i++) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
346 if (hint == name_list[i].substr (0, hint_len)) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
347 matches++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
348 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
349 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
350 if (name_list_total_len > 0 && matches > 0) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
351 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
352 while (list_index < name_list_total_len) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
353 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
354 std::string name = name_list[list_index]; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
355 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
356 list_index++; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
357 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
358 if (hint == name.substr (0, hint_len)) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
359 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
360 // Special case: array reference forces prefix="." |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
361 // in generate_struct_completions () |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
362 if (list_index <= name_list_len && ! prefix.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
363 retval = (prefix == "." ? "" : prefix) + '.' + name; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
364 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
365 retval = name; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
366 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
367 char prev_char = command_editor::get_prev_char |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
368 (text.length ()); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
369 if (matches == 1 && looks_like_struct (retval, prev_char)) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
370 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
371 // Don't append anything, since we don't know |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
372 // whether it should be '(' or '.'. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
373 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
374 command_editor::set_completion_append_character ('\0'); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
375 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
376 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
377 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
378 input_system& input_sys |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
379 = __get_input_system__ ("generate_completion"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
380 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
381 command_editor::set_completion_append_character |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
382 (input_sys.completion_append_char ()); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
383 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
384 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
385 break; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
386 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
387 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
388 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
389 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
390 return retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
391 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
392 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
393 // Use literal "octave" in default setting for PS1 instead of |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
394 // "\\s" to avoid setting the prompt to "octave.exe" or |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
395 // "octave-gui", etc. |
6257 | 396 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
397 input_system::input_system (interpreter& interp) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
398 : m_interpreter (interp), m_PS1 (R"(octave:\#> )"), m_PS2 ("> "), |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
399 m_completion_append_char (' '), m_gud_mode (false), |
27272
9de4741a896e
Do not ignore user preferences for locale encoding on non-Windows platforms.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
400 m_mfile_encoding ("system"), m_last_debugging_command ("\n"), |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
401 m_input_event_hook_functions () |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
402 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
403 } |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
404 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
405 void input_system::initialize (bool line_editing) |
6257 | 406 { |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
407 // Force default line editor if we don't want readline editing. |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
408 if (! line_editing) |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
409 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
410 command_editor::force_default_editor (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
411 return; |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
412 } |
6257 | 413 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
414 // If we are using readline, this allows conditional parsing of the |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
415 // .inputrc file. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
416 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
417 command_editor::set_name ("Octave"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
418 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
419 // FIXME: this needs to include a comma too, but that |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
420 // causes trouble for the new struct element completion code. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
421 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
422 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
423 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
424 command_editor::set_basic_word_break_characters (s); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
425 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
426 command_editor::set_completer_word_break_characters (s); |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
427 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
428 command_editor::set_basic_quote_characters (R"(")"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
429 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
430 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
431 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
432 command_editor::set_completer_quote_characters (R"('")"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
433 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
434 command_editor::set_completion_function (generate_completion); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
435 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
436 command_editor::set_quoting_function (quoting_filename); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
437 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
438 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
439 octave_value |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
440 input_system::PS1 (const octave_value_list& args, int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
441 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
442 return set_internal_variable (m_PS1, args, nargout, "PS1"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
443 } |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
444 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
445 octave_value |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
446 input_system::PS2 (const octave_value_list& args, int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
447 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
448 return set_internal_variable (m_PS2, args, nargout, "PS2"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
449 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
450 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
451 octave_value |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
452 input_system::completion_append_char (const octave_value_list& args, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
453 int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
454 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
455 return set_internal_variable (m_completion_append_char, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
456 "completion_append_char"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
457 } |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
458 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
459 octave_value |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
460 input_system::gud_mode (const octave_value_list& args, int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
461 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
462 return set_internal_variable (m_gud_mode, args, nargout, "__gud_mode__"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
463 } |
269 | 464 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
465 octave_value |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
466 input_system::mfile_encoding (const octave_value_list& args, int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
467 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
468 // Save current value in case there is an error in the additional |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
469 // validation below. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
470 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
471 std::string saved_encoding = m_mfile_encoding; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
472 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
473 // We must pass the actual variable to change here for temporary |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
474 // "local" settings to work properly. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
475 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
476 octave_value retval |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
477 = set_internal_variable (m_mfile_encoding, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
478 "__mfile_encoding__"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
479 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
480 // Additional validation if the encoding has changed. |
1358 | 481 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
482 if (m_mfile_encoding != saved_encoding) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
483 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
484 if (m_mfile_encoding.empty ()) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
485 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
486 m_mfile_encoding = "system"; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
487 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
488 else |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
489 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
490 std::transform (m_mfile_encoding.begin (), |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
491 m_mfile_encoding.end (), |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
492 m_mfile_encoding.begin (), ::tolower); |
3933 | 493 |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
494 std::string encoding = (m_mfile_encoding.compare ("system") == 0) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
495 ? octave_locale_charset_wrapper () : m_mfile_encoding; |
3933 | 496 |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
497 // Check for valid encoding name. |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
498 void *codec |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
499 = octave_iconv_open_wrapper (encoding.c_str (), "utf-8"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
500 |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
501 if (codec == reinterpret_cast<void *> (-1)) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
502 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
503 m_mfile_encoding = saved_encoding; |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
504 if (errno == EINVAL) |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
505 error ("__mfile_encoding__: conversion from encoding '%s' " |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
506 "not supported", encoding.c_str ()); |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
507 else |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
508 error ("__mfile_encoding__: error %d opening encoding '%s'.", |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
509 errno, encoding.c_str ()); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
510 } |
26880
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
511 else |
6c25c714bec4
Improve error checking for iconv_open.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
512 octave_iconv_close_wrapper (codec); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
513 } |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25659
diff
changeset
|
514 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
515 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
516 |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25659
diff
changeset
|
517 // Synchronize the related gui preference for editor encoding |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
518 feval ("__event_manager_gui_preference__", |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
519 ovl ("editor/default_encoding", m_mfile_encoding)); |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25659
diff
changeset
|
520 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
521 return retval; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
522 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
523 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
524 bool input_system::yes_or_no (const std::string& prompt) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
525 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
526 std::string prompt_string = prompt + "(yes or no) "; |
6367 | 527 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
528 while (1) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
529 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
530 bool eof = false; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
531 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
532 std::string input_buf = interactive_input (prompt_string, eof); |
6979 | 533 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
534 if (input_buf == "yes") |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
535 return true; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
536 else if (input_buf == "no") |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
537 return false; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
538 else |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
539 message (nullptr, "Please answer yes or no."); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
540 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
541 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
542 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
543 std::string input_system::interactive_input (const std::string& s, bool& eof) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
544 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
545 Vlast_prompt_time.stamp (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
546 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
547 if (Vdrawnow_requested && application::interactive ()) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
548 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
549 bool eval_error = false; |
6979 | 550 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
551 try |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
552 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
553 Fdrawnow (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
554 } |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
555 catch (const execution_exception& e) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
556 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
557 eval_error = true; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
558 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
559 std::string stack_trace = e.info (); |
269 | 560 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
561 if (! stack_trace.empty ()) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
562 std::cerr << stack_trace; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
563 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
564 if (application::interactive ()) |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
565 interpreter::recover_from_exception (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
566 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
567 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
568 flush_stdout (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
569 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
570 // We set Vdrawnow_requested to false even if there is an error in |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
571 // drawnow so that the error doesn't reappear at every prompt. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
572 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
573 Vdrawnow_requested = false; |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
574 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
575 if (eval_error) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
576 return "\n"; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
577 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
578 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
579 return gnu_readline (s, eof); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
580 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
581 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
582 // If the user simply hits return, this will produce an empty matrix. |
6305 | 583 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
584 octave_value_list |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
585 input_system::get_user_input (const octave_value_list& args, int nargout) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
586 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
587 octave_value_list retval; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
588 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
589 int read_as_string = 0; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
590 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
591 if (args.length () == 2) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
592 read_as_string++; |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
593 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
594 std::string prompt = args(0).xstring_value ("input: unrecognized argument"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
595 |
25435
a52e6fb674b1
eliminate some singletons and static & global variables
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
596 output_system& output_sys = __get_output_system__ ("do_sync"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
597 |
25435
a52e6fb674b1
eliminate some singletons and static & global variables
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
598 output_sys.reset (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
599 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
600 octave_diary << prompt; |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25392
diff
changeset
|
601 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
602 bool eof = false; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
603 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
604 std::string input_buf = interactive_input (prompt.c_str (), eof); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19379
diff
changeset
|
605 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
606 if (input_buf.empty ()) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
607 error ("input: reading user-input failed!"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
608 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
609 size_t len = input_buf.length (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
610 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
611 octave_diary << input_buf; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
612 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
613 if (input_buf[len - 1] != '\n') |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
614 octave_diary << "\n"; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
615 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
616 if (read_as_string) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
617 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
618 // FIXME: fix gnu_readline and octave_gets instead! |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
619 if (input_buf.length () == 1 && input_buf[0] == '\n') |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
620 retval(0) = ""; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
621 else |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
622 retval(0) = input_buf; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
623 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
624 else |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
625 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
626 int parse_status = 0; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
627 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26062
diff
changeset
|
628 retval |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26062
diff
changeset
|
629 = m_interpreter.eval_string (input_buf, true, parse_status, nargout); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
630 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
631 tree_evaluator& tw = m_interpreter.get_evaluator (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
632 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
633 if (! tw.in_debug_repl () && retval.empty ()) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
634 retval(0) = Matrix (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
635 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
636 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
637 return retval; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
638 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
639 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
640 bool input_system::have_input_event_hooks (void) const |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
641 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
642 return ! m_input_event_hook_functions.empty (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
643 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
644 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
645 void input_system::add_input_event_hook (const hook_function& hook_fcn) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
646 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
647 m_input_event_hook_functions.insert (hook_fcn.id (), hook_fcn); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
648 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
649 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
650 bool input_system::remove_input_event_hook (const std::string& hook_fcn_id) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
651 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
652 hook_function_list::iterator p |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
653 = m_input_event_hook_functions.find (hook_fcn_id); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
654 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
655 if (p == m_input_event_hook_functions.end ()) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
656 return false; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
657 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
658 m_input_event_hook_functions.erase (p); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
659 return true; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
660 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
661 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
662 void input_system::clear_input_event_hooks (void) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
663 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
664 m_input_event_hook_functions.clear (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
665 } |
269 | 666 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
667 void input_system::run_input_event_hooks (void) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
668 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
669 m_input_event_hook_functions.run (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
670 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
671 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
672 std::string |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
673 input_system::gnu_readline (const std::string& s, bool& eof) const |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
674 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
675 octave_quit (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
676 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
677 eof = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
678 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
679 std::string retval = command_editor::readline (s, eof); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
680 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
681 if (! eof && retval.empty ()) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
682 retval = "\n"; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
683 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
684 return retval; |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
685 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
686 |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
687 std::string base_reader::octave_gets (bool& eof) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
688 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
689 octave_quit (); |
5142 | 690 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
691 eof = false; |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
692 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
693 std::string retval; |
1 | 694 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
695 // Process pre input event hook function prior to flushing output and |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
696 // printing the prompt. |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
697 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
698 interpreter& interp = __get_interpreter__ ("base_reader::octave_gets"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
699 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
700 tree_evaluator& tw = interp.get_evaluator (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
701 |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
702 event_manager& evmgr = interp.get_event_manager (); |
27261
dccdc3b001a2
eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents:
27200
diff
changeset
|
703 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
704 if (application::interactive ()) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
705 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
706 if (! tw.in_debug_repl ()) |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
707 evmgr.exit_debugger_event (); |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
708 |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
709 evmgr.pre_input_event (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
710 |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
711 evmgr.set_workspace (); |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
712 } |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
713 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
714 bool history_skip_auto_repeated_debugging_command = false; |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
715 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
716 input_system& input_sys = interp.get_input_system (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
717 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
718 std::string ps = (m_pflag > 0) ? input_sys.PS1 () : input_sys.PS2 (); |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
719 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
720 std::string prompt = command_editor::decode_prompt_string (ps); |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
721 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
722 pipe_handler_error_count = 0; |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
723 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
724 output_system& output_sys = interp.get_output_system (); |
1755 | 725 |
25435
a52e6fb674b1
eliminate some singletons and static & global variables
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
726 output_sys.reset (); |
2618 | 727 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
728 octave_diary << prompt; |
1 | 729 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
730 retval = input_sys.interactive_input (prompt, eof); |
581 | 731 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
732 // There is no need to update the load_path cache if there is no |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
733 // user input. |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
734 if (retval != "\n" |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
735 && retval.find_first_not_of (" \t\n\r") != std::string::npos) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
736 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
737 load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
738 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
739 lp.update (); |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
740 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
741 if (tw.in_debug_repl ()) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
742 input_sys.last_debugging_command (retval); |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
743 else |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
744 input_sys.last_debugging_command ("\n"); |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
745 } |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
746 else if (tw.in_debug_repl ()) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
747 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
748 retval = input_sys.last_debugging_command (); |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
749 history_skip_auto_repeated_debugging_command = true; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
750 } |
1 | 751 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
752 if (retval != "\n") |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
753 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
754 if (! history_skip_auto_repeated_debugging_command) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
755 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
756 if (command_history::add (retval)) |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
757 evmgr.append_history (retval); |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
758 } |
1 | 759 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
760 octave_diary << retval; |
3176 | 761 |
26061
cb3ead3cf859
avoid assertion failure with -D_GLIBCXX_ASSERTIONS
Orion Poplawski <orion@cora.nwra.com>
parents:
25054
diff
changeset
|
762 if (! retval.empty () && retval.back () != '\n') |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
763 octave_diary << "\n"; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
764 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
765 else |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
766 octave_diary << "\n"; |
581 | 767 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
768 // Process post input event hook function after the internal history |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
769 // list has been updated. |
9476 | 770 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
771 if (application::interactive ()) |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
772 evmgr.post_input_event (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
773 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
774 return retval; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
775 } |
1 | 776 |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
777 bool base_reader::reading_fcn_file (void) const |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
778 { |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
779 return m_lexer.m_reading_fcn_file; |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
780 } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
781 |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
782 bool base_reader::reading_classdef_file (void) const |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
783 { |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
784 return m_lexer.m_reading_classdef_file; |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
785 } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
786 |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
787 bool base_reader::reading_script_file (void) const |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
788 { |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
789 return m_lexer.m_reading_script_file; |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
790 } |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
791 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
792 class |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
793 terminal_reader : public base_reader |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
794 { |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
795 public: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
796 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
797 terminal_reader (base_lexer& lxr) |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
798 : base_reader (lxr) |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
799 { } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
800 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
801 std::string get_input (bool& eof); |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
802 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
803 std::string input_source (void) const { return s_in_src; } |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
804 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
805 bool input_from_terminal (void) const { return true; } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
806 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
807 private: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
808 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
809 static const std::string s_in_src; |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
810 }; |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
811 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
812 class |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
813 file_reader : public base_reader |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
814 { |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
815 public: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
816 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
817 file_reader (FILE *f_arg, base_lexer& lxr) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
818 : base_reader (lxr), m_file (f_arg) { } |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
819 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
820 std::string get_input (bool& eof); |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
821 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
822 std::string input_source (void) const { return s_in_src; } |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
823 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
824 bool input_from_file (void) const { return true; } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
825 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
826 private: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
827 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
828 FILE *m_file; |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
829 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
830 static const std::string s_in_src; |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
831 }; |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
832 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
833 class |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
834 eval_string_reader : public base_reader |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
835 { |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
836 public: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
837 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
838 eval_string_reader (const std::string& str, base_lexer& lxr) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
839 : base_reader (lxr), m_eval_string (str) |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
840 { } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
841 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
842 std::string get_input (bool& eof); |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
843 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
844 std::string input_source (void) const { return s_in_src; } |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
845 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
846 bool input_from_eval_string (void) const { return true; } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
847 |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
848 private: |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
849 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
850 std::string m_eval_string; |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
851 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
852 static const std::string s_in_src; |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
853 }; |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
854 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
855 input_reader::input_reader (base_lexer& lxr) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
856 : m_rep (new terminal_reader (lxr)) |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
857 { } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
858 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
859 input_reader::input_reader (FILE *file, base_lexer& lxr) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
860 : m_rep (new file_reader (file, lxr)) |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
861 { } |
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
862 |
27162
eab1c573c4fc
store reference to lexer in reader instead of pointer
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
863 input_reader::input_reader (const std::string& str, base_lexer& lxr) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
864 : m_rep (new eval_string_reader (str, lxr)) |
24732
f079a0856321
move internal input reader classes out of header file
John W. Eaton <jwe@octave.org>
parents:
24597
diff
changeset
|
865 { } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
866 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
867 const std::string base_reader::s_in_src ("invalid"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
868 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
869 const std::string terminal_reader::s_in_src ("terminal"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
870 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
871 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
872 terminal_reader::get_input (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
873 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
874 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
875 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
876 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
877 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
878 return octave_gets (eof); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
879 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
880 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
881 const std::string file_reader::s_in_src ("file"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
882 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
883 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
884 file_reader::get_input (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
885 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
886 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
887 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
888 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
889 |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
890 std::string src_str = octave_fgets (m_file, eof); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
891 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
892 input_system& input_sys |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
893 = __get_input_system__ ("get_input"); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
894 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
895 std::string mfile_encoding = input_sys.mfile_encoding (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
896 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
897 std::string encoding |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
898 = (mfile_encoding.compare ("system") == 0 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
899 ? octave_locale_charset_wrapper () : mfile_encoding); |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
900 |
25620
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
901 if (encoding.compare ("utf-8") == 0) |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
902 { |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
903 // Check for BOM and strip it |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
904 if (src_str.compare (0, 3, "\xef\xbb\xbf") == 0) |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
905 src_str.erase (0, 3); |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
906 } |
467729037209
Strip BOM from UTF-8 encoded .m files (bug #52574).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25441
diff
changeset
|
907 else |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
908 { |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
909 // convert encoding to UTF-8 before returning string |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
910 const char *src = src_str.c_str (); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
911 size_t srclen = src_str.length (); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
912 |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
913 size_t length; |
26358
d527c6111425
input.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26193
diff
changeset
|
914 uint8_t *utf8_str; |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
915 |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
916 utf8_str = octave_u8_conv_from_encoding (encoding.c_str (), src, srclen, |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
917 &length); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
918 |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
919 if (! utf8_str) |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
920 error ("file_reader::get_input: converting from codepage '%s' to UTF-8: %s", |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
921 encoding.c_str (), std::strerror (errno)); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
922 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
923 unwind_protect frame; |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
924 frame.add_fcn (::free, static_cast<void *> (utf8_str)); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
925 |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
926 src_str = std::string (reinterpret_cast<char *> (utf8_str), length); |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
927 } |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
928 |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
929 return src_str; |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
930 } |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
931 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
932 const std::string eval_string_reader::s_in_src ("eval_string"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
933 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
934 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
935 eval_string_reader::get_input (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
936 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
937 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
938 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
939 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
940 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
941 std::string retval; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
942 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
943 retval = m_eval_string; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
944 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
945 // Clear the eval string so that the next call will return |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
946 // an empty character string with EOF = true. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24732
diff
changeset
|
947 m_eval_string = ""; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
948 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
949 if (retval.empty ()) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
950 eof = true; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
951 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
952 return retval; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
953 } |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
954 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
955 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
956 DEFMETHOD (input, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
957 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
958 @deftypefn {} {@var{ans} =} input (@var{prompt}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
959 @deftypefnx {} {@var{ans} =} input (@var{prompt}, "s") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
960 Print @var{prompt} and wait for user input. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
961 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
962 For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
963 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
964 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
965 input ("Pick a number, any number! ") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
966 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
967 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
968 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
969 prints the prompt |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
970 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
971 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
972 Pick a number, any number! |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
973 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
974 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
975 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
976 and waits for the user to enter a value. The string entered by the user |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
977 is evaluated as an expression, so it may be a literal constant, a variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
978 name, or any other valid Octave code. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
979 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
980 The number of return arguments, their size, and their class depend on the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
981 expression entered. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
982 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
983 If you are only interested in getting a literal string value, you can call |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
984 @code{input} with the character string @qcode{"s"} as the second argument. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
985 This tells Octave to return the string entered by the user directly, without |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
986 evaluating it first. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
987 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
988 Because there may be output waiting to be displayed by the pager, it is a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
989 good idea to always call @code{fflush (stdout)} before calling @code{input}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
990 This will ensure that all pending output is written to the screen before |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
991 your prompt. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
992 @seealso{yes_or_no, kbhit, pause, menu, listdlg} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
993 @end deftypefn */) |
529 | 994 { |
995 int nargin = args.length (); | |
996 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
997 if (nargin < 1 || nargin > 2) |
5823 | 998 print_usage (); |
529 | 999 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1000 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1001 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1002 return input_sys.get_user_input (args, std::max (nargout, 1)); |
529 | 1003 } |
1004 | |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1005 DEFMETHOD (yes_or_no, interp, args, , |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1006 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1007 @deftypefn {} {@var{ans} =} yes_or_no ("@var{prompt}") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1008 Ask the user a yes-or-no question. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1009 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1010 Return logical true if the answer is yes or false if the answer is no. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1011 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1012 Takes one argument, @var{prompt}, which is the string to display when asking |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1013 the question. @var{prompt} should end in a space; @code{yes-or-no} adds the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1014 string @samp{(yes or no) } to it. The user must confirm the answer with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1015 @key{RET} and can edit it until it has been confirmed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1016 @seealso{input} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1017 @end deftypefn */) |
5640 | 1018 { |
1019 int nargin = args.length (); | |
1020 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1021 if (nargin > 1) |
5823 | 1022 print_usage (); |
5640 | 1023 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1024 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1025 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1026 std::string prompt; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1027 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1028 if (nargin == 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1029 prompt = args(0).xstring_value ("yes_or_no: PROMPT must be a string"); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1030 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1031 return ovl (input_sys.yes_or_no (prompt)); |
23728
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1032 } |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1033 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
1034 DEFMETHOD (keyboard, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
1035 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1036 @deftypefn {} {} keyboard () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1037 @deftypefnx {} {} keyboard ("@var{prompt}") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1038 Stop m-file execution and enter debug mode. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1039 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1040 When the @code{keyboard} function is executed, Octave prints a prompt and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1041 waits for user input. The input strings are then evaluated and the results |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1042 are printed. This makes it possible to examine the values of variables |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1043 within a function, and to assign new values if necessary. To leave the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1044 prompt and return to normal execution type @samp{return} or @samp{dbcont}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1045 The @code{keyboard} function does not return an exit status. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1046 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1047 If @code{keyboard} is invoked without arguments, a default prompt of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1048 @samp{debug> } is used. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1049 @seealso{dbstop, dbcont, dbquit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1050 @end deftypefn */) |
529 | 1051 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1052 int nargin = args.length (); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
1053 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1054 if (nargin > 1) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1055 print_usage (); |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1056 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25392
diff
changeset
|
1057 octave::tree_evaluator& tw = interp.get_evaluator (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1058 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1059 if (nargin == 1) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1060 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1061 std::string prompt |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1062 = args(0).xstring_value ("keyboard: PROMPT must be a string"); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1063 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1064 tw.keyboard (prompt); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1065 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1066 else |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26884
diff
changeset
|
1067 tw.keyboard (); |
529 | 1068 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1069 return ovl (); |
529 | 1070 } |
1071 | |
2234 | 1072 DEFUN (completion_matches, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1073 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1074 @deftypefn {} {} completion_matches (@var{hint}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1075 Generate possible completions given @var{hint}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1076 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1077 This function is provided for the benefit of programs like Emacs which |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1078 might be controlling Octave and handling user input. The current |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1079 command number is not incremented when this function is called. This is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1080 a feature, not a bug. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1081 @end deftypefn */) |
2234 | 1082 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
1083 if (args.length () != 1) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1084 print_usage (); |
2234 | 1085 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1086 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1087 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1088 std::string hint = args(0).string_value (); |
2234 | 1089 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1090 int n = 32; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1091 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1092 string_vector list (n); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1093 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1094 int k = 0; |
2234 | 1095 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1096 for (;;) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1097 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1098 std::string cmd = octave::generate_completion (hint, k); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1099 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1100 if (! cmd.empty ()) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1101 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1102 if (k == n) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1103 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1104 n *= 2; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1105 list.resize (n); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1106 } |
2234 | 1107 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1108 list[k++] = cmd; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1109 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1110 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1111 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1112 list.resize (k); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1113 break; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1114 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1115 } |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1116 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1117 if (nargout > 0) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1118 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1119 if (! list.empty ()) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1120 retval = list; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1121 else |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1122 retval = ""; |
2234 | 1123 } |
1124 else | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1125 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1126 // We don't use string_vector::list_in_columns here |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1127 // because it will be easier for Emacs if the names |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1128 // appear in a single column. |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1129 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1130 int len = list.numel (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1131 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1132 for (int i = 0; i < len; i++) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1133 octave_stdout << list[i] << "\n"; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1134 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1135 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1136 octave_completion_matches_called = true; |
2234 | 1137 |
1138 return retval; | |
1139 } | |
1140 | |
20239
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1141 /* |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1142 %!assert (ischar (completion_matches (""))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1143 %!assert (ischar (completion_matches ("a"))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1144 %!assert (ischar (completion_matches (" "))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1145 %!assert (isempty (completion_matches (" "))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1146 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("")))))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1147 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("a")))))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1148 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("ab")))))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1149 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("abs")))))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1150 %!assert (! any (strcmp ("abs", deblank (cellstr (completion_matches ("absa")))))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1151 |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1152 %!error completion_matches () |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1153 %!error completion_matches (1, 2) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1154 */ |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1155 |
16879
cc3743a91652
Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1156 DEFUN (readline_read_init_file, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1157 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1158 @deftypefn {} {} readline_read_init_file (@var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1159 Read the readline library initialization file @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1160 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1161 If @var{file} is omitted, read the default initialization file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1162 (normally @file{~/.inputrc}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1163 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1164 @xref{Readline Init File, , , readline, GNU Readline Library}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1165 for details. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1166 @seealso{readline_re_read_init_file} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1167 @end deftypefn */) |
3189 | 1168 { |
1169 int nargin = args.length (); | |
1170 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1171 if (nargin > 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1172 print_usage (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1173 |
3189 | 1174 if (nargin == 0) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1175 octave::command_editor::read_init_file (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1176 else |
3189 | 1177 { |
5872 | 1178 std::string file = args(0).string_value (); |
3189 | 1179 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1180 octave::command_editor::read_init_file (file); |
3189 | 1181 } |
1182 | |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1183 return ovl (); |
3189 | 1184 } |
1185 | |
16880
1aebb613a5ac
Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents:
16879
diff
changeset
|
1186 DEFUN (readline_re_read_init_file, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1187 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1188 @deftypefn {} {} readline_re_read_init_file () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1189 Re-read the last readline library initialization file that was read. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1190 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1191 @xref{Readline Init File, , , readline, GNU Readline Library}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1192 for details. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1193 @seealso{readline_read_init_file} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1194 @end deftypefn */) |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1195 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1196 if (args.length () != 0) |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1197 print_usage (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1198 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1199 octave::command_editor::re_read_init_file (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1200 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1201 return ovl (); |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1202 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1203 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1204 namespace octave |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1205 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1206 static int internal_input_event_hook_fcn (void) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1207 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1208 input_system& input_sys |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1209 = __get_input_system__ ("internal_input_event_hook_fcn"); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1210 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1211 input_sys.run_input_event_hooks (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1212 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1213 if (! input_sys.have_input_event_hooks ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1214 command_editor::remove_event_hook (internal_input_event_hook_fcn); |
16152
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1215 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1216 return 0; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1217 } |
3498 | 1218 } |
1219 | |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1220 DEFMETHOD (add_input_event_hook, interp, args, , |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1221 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1222 @deftypefn {} {@var{id} =} add_input_event_hook (@var{fcn}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1223 @deftypefnx {} {@var{id} =} add_input_event_hook (@var{fcn}, @var{data}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1224 Add the named function or function handle @var{fcn} to the list of functions |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1225 to call periodically when Octave is waiting for input. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1226 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1227 The function should have the form |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1228 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1229 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1230 @var{fcn} (@var{data}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1231 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1232 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1233 If @var{data} is omitted, Octave calls the function without any arguments. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1234 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1235 The returned identifier may be used to remove the function handle from the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1236 list of input hook functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1237 @seealso{remove_input_event_hook} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1238 @end deftypefn */) |
3498 | 1239 { |
1240 int nargin = args.length (); | |
1241 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1242 if (nargin < 1 || nargin > 2) |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1243 print_usage (); |
3498 | 1244 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1245 octave_value user_data; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1246 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1247 if (nargin == 2) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1248 user_data = args(1); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1249 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1250 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1251 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1252 hook_function hook_fcn (args(0), user_data); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1253 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1254 if (! input_sys.have_input_event_hooks ()) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1255 octave::command_editor::add_event_hook (octave::internal_input_event_hook_fcn); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1256 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1257 input_sys.add_input_event_hook (hook_fcn); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1258 |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1259 return ovl (hook_fcn.id ()); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1260 } |
3498 | 1261 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1262 DEFMETHOD (remove_input_event_hook, interp, args, , |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1263 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1264 @deftypefn {} {} remove_input_event_hook (@var{name}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1265 @deftypefnx {} {} remove_input_event_hook (@var{fcn_id}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1266 Remove the named function or function handle with the given identifier |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1267 from the list of functions to call periodically when Octave is waiting |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1268 for input. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1269 @seealso{add_input_event_hook} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1270 @end deftypefn */) |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1271 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1272 int nargin = args.length (); |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1273 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1274 if (nargin < 1 || nargin > 2) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1275 print_usage (); |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1276 |
26358
d527c6111425
input.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26193
diff
changeset
|
1277 std::string hook_fcn_id = args(0).xstring_value ("remove_input_event_hook: argument not valid as a hook function name or id"); |
3498 | 1278 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1279 bool warn = (nargin < 2); |
3498 | 1280 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1281 octave::input_system& input_sys = interp.get_input_system (); |
3498 | 1282 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1283 if (! input_sys.remove_input_event_hook (hook_fcn_id) && warn) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1284 warning ("remove_input_event_hook: %s not found in list", |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1285 hook_fcn_id.c_str ()); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1286 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1287 if (! input_sys.have_input_event_hooks ()) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1288 octave::command_editor::remove_event_hook (octave::internal_input_event_hook_fcn); |
3498 | 1289 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1290 return ovl (); |
3498 | 1291 } |
1292 | |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1293 DEFMETHOD (PS1, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1294 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1295 @deftypefn {} {@var{val} =} PS1 () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1296 @deftypefnx {} {@var{old_val} =} PS1 (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1297 @deftypefnx {} {} PS1 (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1298 Query or set the primary prompt string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1299 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1300 When executing interactively, Octave displays the primary prompt when it is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1301 ready to read a command. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1302 |
24595
5ed2e9248ee9
doc: Tweaks to use single quotes instead of double quotes (bug #52870).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
1303 The default value of the primary prompt string is @qcode{'octave:\#> '}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1304 To change it, use a command like |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1305 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1306 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1307 PS1 ("\\u@@\\H> ") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1308 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1309 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1310 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1311 which will result in the prompt @samp{boris@@kremvax> } for the user |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1312 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1313 backslashes are required to enter a backslash into a double-quoted |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1314 character string. @xref{Strings}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1315 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1316 You can also use ANSI escape sequences if your terminal supports them. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1317 This can be useful for coloring the prompt. For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1318 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1319 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1320 PS1 ('\[\033[01;31m\]\s:\#> \[\033[0m\]') |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1321 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1322 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1323 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1324 will give the default Octave prompt a red coloring. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1325 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1326 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1327 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1328 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1329 @seealso{PS2, PS4} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1330 @end deftypefn */) |
5794 | 1331 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1332 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1333 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1334 return input_sys.PS1 (args, nargout); |
5794 | 1335 } |
2181 | 1336 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1337 DEFMETHOD (PS2, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1338 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1339 @deftypefn {} {@var{val} =} PS2 () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1340 @deftypefnx {} {@var{old_val} =} PS2 (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1341 @deftypefnx {} {} PS2 (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1342 Query or set the secondary prompt string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1343 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1344 The secondary prompt is printed when Octave is expecting additional input to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1345 complete a command. For example, if you are typing a @code{for} loop that |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1346 spans several lines, Octave will print the secondary prompt at the beginning |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1347 of each line after the first. The default value of the secondary prompt |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1348 string is @qcode{"> "}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1349 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1350 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1351 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1352 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1353 @seealso{PS1, PS4} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1354 @end deftypefn */) |
5794 | 1355 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1356 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1357 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1358 return input_sys.PS2 (args, nargout); |
5794 | 1359 } |
2181 | 1360 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1361 DEFMETHOD (completion_append_char, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1362 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1363 @deftypefn {} {@var{val} =} completion_append_char () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1364 @deftypefnx {} {@var{old_val} =} completion_append_char (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1365 @deftypefnx {} {} completion_append_char (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1366 Query or set the internal character variable that is appended to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1367 successful command-line completion attempts. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1368 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1369 The default value is @qcode{" "} (a single space). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1370 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1371 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1372 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1373 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1374 @end deftypefn */) |
5794 | 1375 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1376 octave::input_system& input_sys = interp.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1377 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1378 return input_sys.completion_append_char (args, nargout); |
5794 | 1379 } |
3019 | 1380 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1381 DEFMETHOD (__request_drawnow__, , args, , |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1382 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1383 @deftypefn {} {} __request_drawnow__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1384 @deftypefnx {} {} __request_drawnow__ (@var{flag}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1385 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1386 @end deftypefn */) |
6257 | 1387 { |
1388 int nargin = args.length (); | |
1389 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1390 if (nargin > 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1391 print_usage (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1392 |
6257 | 1393 if (nargin == 0) |
1394 Vdrawnow_requested = true; | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1395 else |
6257 | 1396 Vdrawnow_requested = args(0).bool_value (); |
1397 | |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1398 return ovl (); |
6257 | 1399 } |
1400 | |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1401 DEFMETHOD (__gud_mode__, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1402 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1403 @deftypefn {} {} __gud_mode__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1404 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1405 @end deftypefn */) |
7294 | 1406 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1407 octave::input_system& input_sys = interp.get_input_system (); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1408 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1409 return input_sys.gud_mode (args, nargout); |
7294 | 1410 } |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1411 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1412 DEFMETHOD (__mfile_encoding__, interp, args, nargout, |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1413 doc: /* -*- texinfo -*- |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1414 @deftypefn {} {@var{current_encoding} =} __mfile_encoding__ (@var{new_encoding}) |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1415 Set and query the codepage that is used for reading .m files. |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1416 @end deftypefn */) |
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1417 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1418 octave::input_system& input_sys = interp.get_input_system (); |
7294 | 1419 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1420 return input_sys.mfile_encoding (args, nargout); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1421 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1422 |
25659
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1423 // Always define these functions. The macro is intended to allow the |
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1424 // declarations to be hidden, not so that Octave will not provide the |
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1425 // functions if they are requested. |
25361
82445187633e
Add support for arbitrary character encodings in m-files (bug #53842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1426 |
25659
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1427 // #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1428 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1429 bool |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1430 octave_yes_or_no (const std::string& prompt) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1431 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1432 octave::input_system& input_sys |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1433 = octave::__get_input_system__ ("set_default_prompts"); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1434 |
25659
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1435 return input_sys.yes_or_no (prompt); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1436 } |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1437 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1438 void |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1439 remove_input_event_hook_functions (void) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1440 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1441 octave::input_system& input_sys |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1442 = octave::__get_input_system__ ("remove_input_event_hook_functions"); |
7294 | 1443 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1444 input_sys.clear_input_event_hooks (); |
7294 | 1445 } |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1446 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1447 // Fix things up so that input can come from the standard input. This |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1448 // may need to become much more complicated, which is why it's in a |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1449 // separate function. |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1450 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1451 FILE * |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1452 get_input_from_stdin (void) |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1453 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1454 octave::command_editor::set_input_stream (stdin); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1455 return octave::command_editor::get_input_stream (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1456 } |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1457 |
25659
e6d3f4f9473c
always provide definitions for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
25620
diff
changeset
|
1458 // #endif |