Mercurial > octave
annotate libinterp/corefcn/input.cc @ 23061:aedc662896a3
move input reader classes into octave namespace
* input.h, input.cc (base_reader, file_reader, terminal_reader,
eval_string_reader, input_reader): Move classes inside octave
namespace and rename without octave_ prefix. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Jan 2017 14:40:40 -0500 |
parents | baf03cdb28b5 |
children | 4e3d47dc7e25 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22196
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
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 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
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 |
19 <http://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" |
4153 | 40 #include "quit.h" |
1755 | 41 #include "str-vec.h" |
42 | |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
43 #include "call-stack.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
44 #include "debug.h" |
1352 | 45 #include "defun.h" |
46 #include "dirfns.h" | |
1 | 47 #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
|
48 #include "errwarn.h" |
3016 | 49 #include "help.h" |
16381
f33dcbd6a005
move hook_function classes to separate file
John W. Eaton <jwe@octave.org>
parents:
16378
diff
changeset
|
50 #include "hook-fcn.h" |
1 | 51 #include "input.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
52 #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
|
53 #include "lex.h" |
5832 | 54 #include "load-path.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
55 #include "octave.h" |
16416
169f71c9d9c8
use octave_link instead of hook functions in input.cc
John W. Eaton <jwe@octave.org>
parents:
16395
diff
changeset
|
56 #include "octave-link.h" |
1352 | 57 #include "oct-map.h" |
1742 | 58 #include "oct-hist.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
59 #include "interpreter.h" |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
60 #include "octave-link.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
61 #include "ovl.h" |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
62 #include "ov-fcn-handle.h" |
1 | 63 #include "pager.h" |
529 | 64 #include "parse.h" |
3772 | 65 #include "pt.h" |
1755 | 66 #include "pt-const.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
67 #include "pt-eval.h" |
3805 | 68 #include "pt-stmt.h" |
1352 | 69 #include "sighandlers.h" |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
70 #include "symtab.h" |
1114 | 71 #include "sysdep.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
72 #include "interpreter.h" |
3098 | 73 #include "unwind-prot.h" |
1352 | 74 #include "utils.h" |
75 #include "variables.h" | |
529 | 76 |
2181 | 77 // Primary prompt string. |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
78 static std::string VPS1; |
2181 | 79 |
80 // Secondary prompt string. | |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
81 static std::string VPS2; |
2181 | 82 |
83 // String printed before echoed input (enabled by --echo-input). | |
5794 | 84 std::string VPS4 = "+ "; |
2181 | 85 |
3019 | 86 // Echo commands as they are executed? |
87 // | |
88 // 1 ==> echo commands read from script files | |
89 // 2 ==> echo commands from functions | |
90 // 4 ==> echo commands read from command line | |
91 // | |
92 // more than one state can be active at once. | |
5794 | 93 int Vecho_executing_commands = ECHO_OFF; |
3019 | 94 |
3165 | 95 // 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
|
96 octave::sys::time Vlast_prompt_time = 0.0; |
3165 | 97 |
2181 | 98 // Character to append after successful command-line completion attempts. |
5794 | 99 static char Vcompletion_append_char = ' '; |
2181 | 100 |
3804 | 101 // TRUE after a call to completion_matches. |
2299 | 102 bool octave_completion_matches_called = false; |
103 | |
6257 | 104 // TRUE if the plotting system has requested a call to drawnow at |
105 // the next user prompt. | |
7409 | 106 bool Vdrawnow_requested = false; |
6257 | 107 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
108 // TRUE if we are in debugging mode. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
109 bool Vdebugging = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
110 |
22164
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
111 // 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
|
112 // 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
|
113 // the terminal. |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
114 bool Vtrack_line_num = true; |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
115 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
116 // If we are in debugging mode, this is the last command entered, so |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
117 // that we can repeat the previous command if the user just types RET. |
16336
0ce49f9fb171
"\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents:
16288
diff
changeset
|
118 static std::string last_debugging_command = "\n"; |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
119 |
7294 | 120 // TRUE if we are running in the Emacs GUD mode. |
121 static bool Vgud_mode = false; | |
122 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
123 // The filemarker used to separate filenames from subfunction names |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
124 char Vfilemarker = '>'; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
125 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
126 static hook_function_list input_event_hook_functions; |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
127 |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
128 // For octave_quit. |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
129 void |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
130 remove_input_event_hook_functions (void) |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
131 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
132 input_event_hook_functions.clear (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
133 } |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
134 |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
135 void |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
136 set_default_prompts (void) |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
137 { |
18037
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
138 // Use literal "octave" instead of "\\s" to avoid setting the prompt |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
139 // to "octave.exe" or "octave-gui", etc. |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
140 |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
141 VPS1 = "octave:\\#> "; |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
142 VPS2 = "> "; |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
143 VPS4 = "+ "; |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
144 |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
145 octave_link::set_default_prompts (VPS1, VPS2, VPS4); |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
146 } |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
147 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
148 namespace octave |
1044 | 149 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
150 void |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
151 base_reader::do_input_echo (const std::string& input_string) const |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
152 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
153 bool forced_interactive = octave::application::forced_interactive (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
154 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
155 int do_echo = reading_script_file () |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
156 ? (Vecho_executing_commands & ECHO_SCRIPTS) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
157 : ((Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive); |
1588 | 158 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
159 if (do_echo) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
160 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
161 if (forced_interactive) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
162 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
163 if (pflag > 0) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
164 octave_stdout << octave::command_editor::decode_prompt_string (VPS1); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
165 else |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
166 octave_stdout << octave::command_editor::decode_prompt_string (VPS2); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
167 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
168 else |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
169 octave_stdout << octave::command_editor::decode_prompt_string (VPS4); |
1044 | 170 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
171 if (! input_string.empty ()) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
172 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
173 octave_stdout << input_string; |
1755 | 174 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
175 if (input_string[input_string.length () - 1] != '\n') |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
176 octave_stdout << "\n"; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
177 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
178 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
179 } |
1044 | 180 } |
181 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
182 static std::string |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
183 gnu_readline (const std::string& s, bool& eof) |
1822 | 184 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
185 octave_quit (); |
5142 | 186 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
187 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
188 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
189 std::string retval = octave::command_editor::readline (s, eof); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19379
diff
changeset
|
190 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
191 if (! eof && retval.empty ()) |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
192 retval = "\n"; |
1822 | 193 |
194 return retval; | |
195 } | |
581 | 196 |
6257 | 197 static inline std::string |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
198 interactive_input (const std::string& s, bool& eof) |
6257 | 199 { |
200 Vlast_prompt_time.stamp (); | |
201 | |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
202 if (Vdrawnow_requested && octave::application::interactive ()) |
6257 | 203 { |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
204 bool eval_error = false; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
205 |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
206 try |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
207 { |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
208 feval ("drawnow"); |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
209 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
210 catch (const octave::execution_exception& e) |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
211 { |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
212 eval_error = true; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
213 |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
214 std::string stack_trace = e.info (); |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
215 |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
216 if (! stack_trace.empty ()) |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
217 std::cerr << stack_trace; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
218 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
219 if (octave::application::interactive ()) |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
220 recover_from_exception (); |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
221 } |
6257 | 222 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
223 octave::flush_stdout (); |
6367 | 224 |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
225 // We set Vdrawnow_requested to false even if there is an error in |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
226 // drawnow so that the error doesn't reappear at every prompt. |
6305 | 227 |
6257 | 228 Vdrawnow_requested = false; |
6305 | 229 |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
230 if (eval_error) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
231 return "\n"; |
6257 | 232 } |
233 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
234 return gnu_readline (s, eof); |
6257 | 235 } |
236 | |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
237 namespace octave |
1 | 238 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
239 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
240 base_reader::octave_gets (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
241 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
242 octave_quit (); |
5142 | 243 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
244 eof = false; |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
245 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
246 std::string retval; |
1 | 247 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
248 // 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
|
249 // printing the prompt. |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
250 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
251 if (octave::application::interactive ()) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
252 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
253 if (! Vdebugging) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
254 octave_link::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
|
255 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
256 octave_link::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
|
257 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
258 octave_link::set_workspace (); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
259 } |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
260 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
261 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
|
262 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
263 std::string ps = (pflag > 0) ? VPS1 : VPS2; |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
264 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
265 std::string prompt = octave::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
|
266 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
267 octave::pipe_handler_error_count = 0; |
1755 | 268 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
269 octave::flush_stdout (); |
2618 | 270 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
271 octave::pager_stream::reset (); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
272 octave::diary_stream::reset (); |
1 | 273 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
274 octave_diary << prompt; |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
275 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
276 retval = interactive_input (prompt, eof); |
581 | 277 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
278 // 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
|
279 // user input. |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
280 if (retval != "\n" |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
281 && 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
|
282 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
283 load_path::update (); |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
284 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
285 if (Vdebugging) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
286 last_debugging_command = retval; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
287 else |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
288 last_debugging_command = "\n"; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
289 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
290 else if (Vdebugging) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
291 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
292 retval = last_debugging_command; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
293 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
|
294 } |
1 | 295 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
296 if (retval != "\n") |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
297 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
298 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
|
299 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
300 if (octave::command_history::add (retval)) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
301 octave_link::append_history (retval); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
302 } |
1 | 303 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
304 octave_diary << retval; |
3176 | 305 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
306 if (retval[retval.length () - 1] != '\n') |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
307 octave_diary << "\n"; |
581 | 308 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
309 do_input_echo (retval); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
310 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
311 else |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
312 octave_diary << "\n"; |
9476 | 313 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
314 // 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
|
315 // list has been updated. |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
316 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
317 if (octave::application::interactive ()) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
318 octave_link::post_input_event (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
319 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
320 return retval; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
321 } |
1 | 322 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
323 bool |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
324 base_reader::reading_fcn_file (void) const |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
325 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
326 return lexer ? lexer->reading_fcn_file : false; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
327 } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
328 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
329 bool |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
330 base_reader::reading_classdef_file (void) const |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
331 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
332 return lexer ? lexer->reading_classdef_file : false; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
333 } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
334 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
335 bool |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
336 base_reader::reading_script_file (void) const |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
337 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
338 return lexer ? lexer->reading_script_file : false; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
339 } |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
340 } |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
341 |
581 | 342 // Fix things up so that input can come from the standard input. This |
343 // may need to become much more complicated, which is why it's in a | |
344 // separate function. | |
345 | |
1 | 346 FILE * |
347 get_input_from_stdin (void) | |
348 { | |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
349 octave::command_editor::set_input_stream (stdin); |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
350 return octave::command_editor::get_input_stream (); |
1 | 351 } |
352 | |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
353 // FIXME: make this generate filenames when appropriate. |
2921 | 354 |
2247 | 355 static string_vector |
3523 | 356 generate_possible_completions (const std::string& text, std::string& prefix, |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
357 std::string& hint, bool& deemed_struct) |
1280 | 358 { |
2247 | 359 string_vector names; |
1280 | 360 |
2921 | 361 prefix = ""; |
1280 | 362 |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
363 char prev_char = octave::command_editor::get_prev_char (text.length ()); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
364 deemed_struct = looks_like_struct (text, prev_char); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
365 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
366 if (deemed_struct) |
1430 | 367 names = generate_struct_completions (text, prefix, hint); |
368 else | |
2247 | 369 names = make_name_list (); |
1280 | 370 |
2944 | 371 // Sort and remove duplicates. |
2348 | 372 |
8503
8ba2ee57c594
remove qsort in favor of sort
Jaroslav Hajek <highegg@gmail.com>
parents:
8447
diff
changeset
|
373 names.sort (true); |
2348 | 374 |
1280 | 375 return names; |
376 } | |
377 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
378 static bool |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
379 is_completing_dirfns (void) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
380 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
381 static std::string dirfns_commands[] = {"cd", "ls"}; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
382 static const size_t dirfns_commands_length = 2; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
383 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
384 bool retval = false; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
385 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
386 std::string line = octave::command_editor::get_line_buffer (); |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
387 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
388 for (size_t i = 0; i < dirfns_commands_length; i++) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
389 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
390 int index = line.find (dirfns_commands[i] + " "); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
391 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
392 if (index == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
393 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
394 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
395 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
396 } |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
397 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
398 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
399 return retval; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
400 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
401 |
3536 | 402 static std::string |
3523 | 403 generate_completion (const std::string& text, int state) |
1280 | 404 { |
3523 | 405 std::string retval; |
2944 | 406 |
3523 | 407 static std::string prefix; |
408 static std::string hint; | |
1280 | 409 |
2921 | 410 static size_t hint_len = 0; |
1280 | 411 |
1 | 412 static int list_index = 0; |
2921 | 413 static int name_list_len = 0; |
4604 | 414 static int name_list_total_len = 0; |
2247 | 415 static string_vector name_list; |
4604 | 416 static string_vector file_name_list; |
1 | 417 |
1280 | 418 static int matches = 0; |
1 | 419 |
420 if (state == 0) | |
421 { | |
422 list_index = 0; | |
423 | |
2921 | 424 prefix = ""; |
1280 | 425 |
2921 | 426 hint = text; |
1280 | 427 |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
428 // No reason to display symbols while completing a |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
429 // file/directory operation. |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
430 |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
431 bool deemed_struct = false; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
432 |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
433 if (is_completing_dirfns ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
434 name_list = string_vector (); |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
435 else |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
436 name_list = generate_possible_completions (text, prefix, hint, |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
437 deemed_struct); |
1280 | 438 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20178
diff
changeset
|
439 name_list_len = name_list.numel (); |
2921 | 440 |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
441 // If the line was something like "a{1}." then text = "." but |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
442 // we don't want to expand all the . files. |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
443 if (! deemed_struct) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
444 { |
4604 | 445 |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
446 file_name_list = octave::command_editor::generate_filename_completions (text); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
447 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
448 name_list.append (file_name_list); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
449 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
450 } |
4604 | 451 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20178
diff
changeset
|
452 name_list_total_len = name_list.numel (); |
4604 | 453 |
2921 | 454 hint_len = hint.length (); |
1280 | 455 |
456 matches = 0; | |
2247 | 457 |
2921 | 458 for (int i = 0; i < name_list_len; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
459 if (hint == name_list[i].substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
460 matches++; |
1 | 461 } |
462 | |
4604 | 463 if (name_list_total_len > 0 && matches > 0) |
1 | 464 { |
4604 | 465 while (list_index < name_list_total_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
466 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
467 std::string name = name_list[list_index]; |
2247 | 468 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
469 list_index++; |
2247 | 470 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
471 if (hint == name.substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
472 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
473 // Special case: array reference forces prefix="." |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
474 // in generate_struct_completions () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
475 if (list_index <= name_list_len && ! prefix.empty ()) |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
476 retval = (prefix == "." ? "" : prefix) + "." + name; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
477 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
478 retval = name; |
1280 | 479 |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
480 char prev_char = octave::command_editor::get_prev_char |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
481 (text.length ()); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
482 if (matches == 1 && looks_like_struct (retval, prev_char)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
483 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
484 // Don't append anything, since we don't know |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
485 // whether it should be '(' or '.'. |
4179 | 486 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
487 octave::command_editor::set_completion_append_character ('\0'); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
488 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
489 else |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
490 octave::command_editor::set_completion_append_character |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
491 (Vcompletion_append_char); |
1280 | 492 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
493 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
494 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
495 } |
1 | 496 } |
497 | |
2944 | 498 return retval; |
1 | 499 } |
500 | |
6979 | 501 static std::string |
502 quoting_filename (const std::string &text, int, char quote) | |
503 { | |
504 if (quote) | |
505 return text; | |
506 else | |
507 return (std::string ("'") + text); | |
508 } | |
509 | |
22171
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
510 // Try to parse a partial command line in reverse, excluding trailing TEXT. |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
511 // If it appears a variable has been indexed by () or {}, |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
512 // return that expression, |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
513 // to allow autocomplete of field names of arrays of structures. |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
514 std::string |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
515 find_indexed_expression (const std::string& text) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
516 { |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
517 std::string line = octave::command_editor::get_line_buffer (); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
518 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
519 int pos = line.length () - text.length (); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
520 int curly_count = 0; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
521 int paren_count = 0; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
522 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
523 int last = --pos; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
524 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
525 while (pos >= 0 && (line[pos] == ')' || line[pos] == '}')) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
526 { |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
527 if (line[pos] == ')') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
528 paren_count++; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
529 else if (line[pos] == '}') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
530 curly_count++; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
531 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
532 while (curly_count + paren_count > 0 && --pos >= 0) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
533 { |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
534 if (line[pos] == ')') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
535 paren_count++; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
536 else if (line[pos] == '(') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
537 paren_count--; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
538 else if (line[pos] == '}') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
539 curly_count++; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
540 else if (line[pos] == '{') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
541 curly_count--; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
542 } |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
543 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
544 while (--pos >= 0 && line[pos] == ' ') |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
545 ; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
546 } |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
547 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
548 while (pos >= 0 && (isalnum (line[pos]) || line[pos] == '_')) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
549 pos--; |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
550 |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
551 if (++pos >= 0) |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
552 return (line.substr (pos, last + 1 - pos)); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
553 else |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
554 return std::string (); |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
555 } |
0a4c5a90f286
Allow tab completion of arrays of structures.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22164
diff
changeset
|
556 |
2927 | 557 void |
558 initialize_command_input (void) | |
559 { | |
560 // If we are using readline, this allows conditional parsing of the | |
561 // .inputrc file. | |
269 | 562 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
563 octave::command_editor::set_name ("Octave"); |
1358 | 564 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
565 // FIXME: this needs to include a comma too, but that |
3933 | 566 // causes trouble for the new struct element completion code. |
567 | |
4272 | 568 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
3933 | 569 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
570 octave::command_editor::set_basic_word_break_characters (s); |
3933 | 571 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
572 octave::command_editor::set_completer_word_break_characters (s); |
3933 | 573 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
574 octave::command_editor::set_basic_quote_characters ("\""); |
2944 | 575 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
576 octave::command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
577 octave::command_editor::set_completer_quote_characters ("'\""); |
6979 | 578 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
579 octave::command_editor::set_completion_function (generate_completion); |
6979 | 580 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
581 octave::command_editor::set_quoting_function (quoting_filename); |
269 | 582 } |
583 | |
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
|
584 static void |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
585 execute_in_debugger_handler (const std::pair<std::string, int>& arg) |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
586 { |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
587 octave_link::execute_in_debugger_event (arg.first, arg.second); |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
588 } |
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
589 |
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
590 static void |
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
|
591 get_debug_input (const std::string& prompt) |
269 | 592 { |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
593 octave::unwind_protect frame; |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
594 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
595 bool silent = octave::tree_evaluator::quiet_breakpoint_flag; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
596 octave::tree_evaluator::quiet_breakpoint_flag = false; |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19379
diff
changeset
|
597 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
598 octave_user_code *caller = octave::call_stack::caller_user_code (); |
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
|
599 std::string nm; |
18595
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
600 int curr_debug_line; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
601 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
602 bool have_file = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
603 |
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
|
604 if (caller) |
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
|
605 { |
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
|
606 nm = caller->fcn_file_name (); |
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
|
607 |
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
|
608 if (nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
609 nm = caller->name (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
610 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
611 have_file = true; |
18595
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
612 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
613 curr_debug_line = octave::call_stack::caller_user_code_line (); |
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
|
614 } |
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
|
615 else |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
616 curr_debug_line = octave::call_stack::current_line (); |
3180 | 617 |
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
|
618 std::ostringstream buf; |
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
|
619 |
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
|
620 if (! nm.empty ()) |
3180 | 621 { |
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
|
622 if (Vgud_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
623 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
624 static char ctrl_z = 'Z' & 0x1f; |
269 | 625 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
626 buf << ctrl_z << ctrl_z << nm << ":" << curr_debug_line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
627 } |
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
|
628 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
629 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
630 // FIXME: we should come up with a clean way to detect |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
631 // that we are stopped on the no-op command that marks the |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
632 // end of a function or script. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
633 |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
634 if (! silent) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
635 { |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
636 buf << "stopped in " << nm; |
1 | 637 |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
638 if (curr_debug_line > 0) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
639 buf << " at line " << curr_debug_line; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
640 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
641 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
642 if (have_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
643 { |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
644 octave_link::enter_debugger_event (nm, curr_debug_line); |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
645 |
16524
6a8e63dadfad
provide octave_link::set_workspace function with default values
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
646 octave_link::set_workspace (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
647 |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
648 frame.add_fcn (execute_in_debugger_handler, |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
649 std::pair<std::string, int> (nm, curr_debug_line)); |
16374
8b0a04cbdc9d
provide hook function for dbstop events
John W. Eaton <jwe@octave.org>
parents:
16373
diff
changeset
|
650 |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
651 if (! silent) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
652 { |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
653 std::string line_buf |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
654 = get_file_line (nm, curr_debug_line); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
655 |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
656 if (! line_buf.empty ()) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
657 buf << "\n" << curr_debug_line << ": " << line_buf; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
658 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
659 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
660 } |
3180 | 661 } |
662 | |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18694
diff
changeset
|
663 if (silent) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
664 octave::command_editor::erase_empty_line (true); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19379
diff
changeset
|
665 |
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
|
666 std::string msg = buf.str (); |
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
|
667 |
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
|
668 if (! msg.empty ()) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
669 std::cerr << msg << std::endl; |
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
|
670 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
671 frame.protect_var (VPS1); |
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
|
672 VPS1 = prompt; |
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
|
673 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
674 octave::application *app = octave::application::app (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
675 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
676 if (! app->interactive ()) |
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
|
677 { |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
678 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
679 frame.add_method (app, &octave::application::interactive, |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
680 app->interactive ()); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
681 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
682 frame.add_method (app, &octave::application::forced_interactive, |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
683 app->forced_interactive ()); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
684 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
685 app->interactive (true); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
686 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
687 app->forced_interactive (true); |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
688 } |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
689 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
690 octave::parser curr_parser; |
16151 | 691 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
692 while (Vdebugging) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
693 { |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
694 try |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
695 { |
22164
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
696 Vtrack_line_num = false; |
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
697 |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
698 reset_error_handler (); |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
699 |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
700 curr_parser.reset (); |
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
|
701 |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
702 int retval = curr_parser.run (); |
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
|
703 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
704 if (octave::command_editor::interrupt (false)) |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
705 break; |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
706 else |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
707 { |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
708 if (retval == 0 && curr_parser.stmt_list) |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
709 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
710 curr_parser.stmt_list->accept (*octave::current_evaluator); |
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
|
711 |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
712 if (octave_completion_matches_called) |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
713 octave_completion_matches_called = false; |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
714 } |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
715 |
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
716 octave_quit (); |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
717 } |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
718 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
719 catch (const octave::execution_exception& e) |
20639
31219c56874f
don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
720 { |
20739
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
721 std::string stack_trace = e.info (); |
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
722 |
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
723 if (! stack_trace.empty ()) |
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
724 std::cerr << stack_trace; |
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
725 |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20743
diff
changeset
|
726 // Ignore errors when in debugging mode; |
20739
9e8a6d6d6de9
restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
727 recover_from_exception (); |
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
|
728 } |
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
|
729 } |
529 | 730 } |
731 | |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
732 namespace octave |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
733 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
734 const std::string base_reader::in_src ("invalid"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
735 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
736 const std::string terminal_reader::in_src ("terminal"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
737 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
738 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
739 terminal_reader::get_input (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
740 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
741 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
742 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
743 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
744 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
745 return octave_gets (eof); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
746 } |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
747 |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
748 const std::string file_reader::in_src ("file"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
749 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
750 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
751 file_reader::get_input (bool& eof) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
752 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
753 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
754 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
755 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
756 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
757 return octave_fgets (file, eof); |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
758 } |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
759 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
760 const std::string eval_string_reader::in_src ("eval_string"); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
761 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
762 std::string |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
763 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
|
764 { |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
765 octave_quit (); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
766 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
767 eof = false; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
768 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
769 std::string retval; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
770 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
771 retval = eval_string; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
772 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
773 // 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
|
774 // an empty character string with EOF = true. |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
775 eval_string = ""; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
776 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
777 if (retval.empty ()) |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
778 eof = true; |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
779 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
780 return retval; |
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23060
diff
changeset
|
781 } |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
782 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
783 |
581 | 784 // If the user simply hits return, this will produce an empty matrix. |
785 | |
2086 | 786 static octave_value_list |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
787 get_user_input (const octave_value_list& args, int nargout) |
529 | 788 { |
3100 | 789 octave_value_list retval; |
529 | 790 |
791 int read_as_string = 0; | |
792 | |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
793 if (args.length () == 2) |
529 | 794 read_as_string++; |
795 | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20639
diff
changeset
|
796 std::string prompt = args(0).xstring_value ("input: unrecognized argument"); |
4975 | 797 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
798 octave::flush_stdout (); |
529 | 799 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
800 octave::pager_stream::reset (); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
801 octave::diary_stream::reset (); |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
802 |
4565 | 803 octave_diary << prompt; |
804 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
805 bool eof = false; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
806 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
807 std::string input_buf = interactive_input (prompt.c_str (), eof); |
529 | 808 |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
809 if (input_buf.empty ()) |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
810 error ("input: reading user-input failed!"); |
529 | 811 |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
812 size_t len = input_buf.length (); |
4565 | 813 |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
814 octave_diary << input_buf; |
4565 | 815 |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
816 if (input_buf[len - 1] != '\n') |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
817 octave_diary << "\n"; |
3772 | 818 |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
819 if (len < 1) |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
820 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
821 |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
822 if (read_as_string) |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
823 { |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
824 // FIXME: fix gnu_readline and octave_gets instead! |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
825 if (input_buf.length () == 1 && input_buf[0] == '\n') |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
826 retval(0) = ""; |
529 | 827 else |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
828 retval(0) = input_buf; |
529 | 829 } |
830 else | |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
831 { |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
832 int parse_status = 0; |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
833 |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
834 retval = eval_string (input_buf, true, parse_status, nargout); |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
835 |
21885
0806871e3e1e
maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents:
21852
diff
changeset
|
836 if (! Vdebugging && retval.empty ()) |
20981
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
837 retval(0) = Matrix (); |
c11cea70b638
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20941
diff
changeset
|
838 } |
529 | 839 |
840 return retval; | |
841 } | |
842 | |
3100 | 843 DEFUN (input, 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
|
844 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
|
845 @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
|
846 @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
|
847 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
|
848 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
849 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
|
850 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
851 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
852 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
|
853 @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
|
854 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
855 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
856 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
|
857 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
858 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
859 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
|
860 @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
|
861 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
862 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
863 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
|
864 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
|
865 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
|
866 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
867 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
|
868 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
|
869 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
870 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
|
871 @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
|
872 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
|
873 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
|
874 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 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
|
879 @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
|
880 @end deftypefn */) |
529 | 881 { |
882 int nargin = args.length (); | |
883 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
884 if (nargin < 1 || nargin > 2) |
5823 | 885 print_usage (); |
529 | 886 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
887 return get_user_input (args, std::max (nargout, 1)); |
529 | 888 } |
889 | |
5640 | 890 bool |
891 octave_yes_or_no (const std::string& prompt) | |
892 { | |
893 std::string prompt_string = prompt + "(yes or no) "; | |
894 | |
895 while (1) | |
896 { | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
897 bool eof = false; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
898 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
899 std::string input_buf = interactive_input (prompt_string, eof); |
5640 | 900 |
901 if (input_buf == "yes") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
902 return true; |
5640 | 903 else if (input_buf == "no") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
904 return false; |
5640 | 905 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
906 message (0, "Please answer yes or no."); |
5640 | 907 } |
908 } | |
909 | |
910 DEFUN (yes_or_no, 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
|
911 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
|
912 @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
|
913 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
|
914 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
915 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
|
916 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
917 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
|
918 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
|
919 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
|
920 @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
|
921 @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
|
922 @end deftypefn */) |
5640 | 923 { |
924 int nargin = args.length (); | |
925 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
926 if (nargin > 1) |
5823 | 927 print_usage (); |
5640 | 928 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
929 std::string prompt; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
930 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
931 if (nargin == 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
932 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
|
933 |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
934 return ovl (octave_yes_or_no (prompt)); |
5640 | 935 } |
936 | |
3707 | 937 octave_value |
938 do_keyboard (const octave_value_list& args) | |
939 { | |
940 octave_value retval; | |
941 | |
942 int nargin = args.length (); | |
943 | |
944 assert (nargin == 0 || nargin == 1); | |
945 | |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
946 octave::unwind_protect frame; |
3707 | 947 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
948 frame.add_fcn (octave::command_history::ignore_entries, |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
949 octave::command_history::ignoring_entries ()); |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
950 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
951 octave::command_history::ignore_entries (false); |
3707 | 952 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
953 frame.protect_var (Vdebugging); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
954 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
955 frame.add_fcn (octave::call_stack::restore_frame, |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
956 octave::call_stack::current_frame ()); |
3707 | 957 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
958 // FIXME: probably we just want to print one line, not the |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
959 // entire statement, which might span many lines... |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
960 // |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
961 // tree_print_code tpc (octave_stdout); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
962 // stmt.accept (tpc); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
963 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
964 Vdebugging = true; |
22164
5d4a286061c8
Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22094
diff
changeset
|
965 Vtrack_line_num = false; |
3707 | 966 |
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
|
967 std::string prompt = "debug> "; |
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
|
968 if (nargin > 0) |
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
|
969 prompt = args(0).string_value (); |
4233 | 970 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
971 get_debug_input (prompt); |
3707 | 972 |
973 return retval; | |
974 } | |
975 | |
1957 | 976 DEFUN (keyboard, 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
|
977 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
|
978 @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
|
979 @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
|
980 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
|
981 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
982 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
|
983 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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
989 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
|
990 @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
|
991 @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
|
992 @end deftypefn */) |
529 | 993 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
994 if (args.length () > 1) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
995 print_usage (); |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
996 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
997 octave::unwind_protect frame; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
998 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
999 frame.add_fcn (octave::call_stack::restore_frame, |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
1000 octave::call_stack::current_frame ()); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
1001 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1002 // Skip the frame assigned to the keyboard function. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
1003 octave::call_stack::goto_frame_relative (0); |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1004 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
1005 octave::tree_evaluator::debug_mode = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22171
diff
changeset
|
1006 octave::tree_evaluator::quiet_breakpoint_flag = false; |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1007 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22997
diff
changeset
|
1008 octave::tree_evaluator::current_frame = octave::call_stack::current_frame (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1009 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1010 do_keyboard (args); |
529 | 1011 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1012 return ovl (); |
529 | 1013 } |
1014 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
1015 DEFUN (echo, 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
|
1016 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
|
1017 @deftypefn {} {} echo |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1018 @deftypefnx {} {} echo on |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1019 @deftypefnx {} {} echo off |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1020 @deftypefnx {} {} echo on all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1021 @deftypefnx {} {} echo off all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1022 Control whether commands are displayed as they are executed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1023 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1024 Valid options are: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1025 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1026 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1027 @item on |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1028 Enable echoing of commands as they are executed in script files. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1029 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1030 @item off |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1031 Disable echoing of commands as they are executed in script files. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1032 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1033 @item on all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1034 Enable echoing of commands as they are executed in script files and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1035 functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1036 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1037 @item off all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1038 Disable echoing of commands as they are executed in script files and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1039 functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1040 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1041 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1042 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1043 With no arguments, @code{echo} toggles the current echo state. |
22982
aca714a80cfc
doc: Add more sealso links between docstrings.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1044 |
aca714a80cfc
doc: Add more sealso links between docstrings.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1045 @seealso{echo_executing_commands} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1046 @end deftypefn */) |
1588 | 1047 { |
20996 | 1048 string_vector argv = args.make_argv (); |
1755 | 1049 |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
1050 switch (args.length ()) |
1588 | 1051 { |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20801
diff
changeset
|
1052 case 0: |
1588 | 1053 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1054 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1055 || (Vecho_executing_commands & ECHO_FUNCTIONS)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1056 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1057 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1058 Vecho_executing_commands = ECHO_SCRIPTS; |
1588 | 1059 } |
1060 break; | |
1061 | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20801
diff
changeset
|
1062 case 1: |
1588 | 1063 { |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1064 std::string arg = argv[0]; |
1755 | 1065 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1066 if (arg == "on") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1067 Vecho_executing_commands = ECHO_SCRIPTS; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1068 else if (arg == "off") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1069 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1070 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1071 print_usage (); |
1588 | 1072 } |
1073 break; | |
1074 | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20801
diff
changeset
|
1075 case 2: |
1588 | 1076 { |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1077 std::string arg = argv[0]; |
1755 | 1078 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1079 if (arg == "on" && argv[1] == "all") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1080 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1081 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1082 Vecho_executing_commands = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1083 } |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1084 else if (arg == "off" && argv[1] == "all") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1085 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1086 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1087 print_usage (); |
1588 | 1088 } |
1089 break; | |
1090 | |
1091 default: | |
5823 | 1092 print_usage (); |
1588 | 1093 break; |
1094 } | |
1095 | |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1096 return ovl (); |
1588 | 1097 } |
1098 | |
20239
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1099 /* |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1100 %!test |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1101 %! state = echo_executing_commands (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1102 %! unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1103 %! echo (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1104 %! s1 = echo_executing_commands (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1105 %! assert (s1 != state); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1106 %! echo (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1107 %! s2 = echo_executing_commands (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1108 %! assert (s2 != s1); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1109 %! unwind_protect_cleanup |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1110 %! echo_executing_commands (state); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1111 %! end_unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1112 |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1113 %!test |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1114 %! state = echo_executing_commands (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1115 %! unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1116 %! echo ("off"); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1117 %! assert (echo_executing_commands () == 0); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1118 %! echo ("on"); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1119 %! assert (echo_executing_commands () != 0); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1120 %! echo ("off"); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1121 %! assert (echo_executing_commands () == 0); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1122 %! unwind_protect_cleanup |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1123 %! echo_executing_commands (state); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1124 %! end_unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1125 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1126 %!#test # FIXME: This passes, but produces a lot of onscreen output |
20239
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1127 %! state = echo_executing_commands (); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1128 %! unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1129 %! echo ("on", "all"); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1130 %! assert (echo_executing_commands () != 0); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1131 %! echo ("off", "all"); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1132 %! assert (echo_executing_commands () == 0); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1133 %! unwind_protect_cleanup |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1134 %! echo_executing_commands (state); |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1135 %! end_unwind_protect |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1136 |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1137 %!error echo ([]) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1138 %!error echo (0) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1139 %!error echo ("") |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1140 %!error echo ("Octave") |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1141 %!error echo ("off", "invalid") |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1142 %!error echo ("on", "invalid") |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1143 %!error echo ("on", "all", "all") |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1144 */ |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1145 |
2234 | 1146 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
|
1147 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
|
1148 @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
|
1149 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
|
1150 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 @end deftypefn */) |
2234 | 1156 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
1157 if (args.length () != 1) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1158 print_usage (); |
2234 | 1159 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1160 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1161 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1162 std::string hint = args(0).string_value (); |
2234 | 1163 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1164 int n = 32; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1165 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1166 string_vector list (n); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1167 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1168 int k = 0; |
2234 | 1169 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1170 for (;;) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1171 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1172 std::string cmd = generate_completion (hint, k); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1173 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1174 if (! cmd.empty ()) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1175 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1176 if (k == n) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1177 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1178 n *= 2; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1179 list.resize (n); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1180 } |
2234 | 1181 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1182 list[k++] = cmd; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1183 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1184 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1185 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1186 list.resize (k); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1187 break; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1188 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1189 } |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1190 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1191 if (nargout > 0) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1192 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1193 if (! list.empty ()) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1194 retval = list; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1195 else |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1196 retval = ""; |
2234 | 1197 } |
1198 else | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1199 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1200 // 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
|
1201 // 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
|
1202 // appear in a single column. |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1203 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1204 int len = list.numel (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1205 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1206 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
|
1207 octave_stdout << list[i] << "\n"; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1208 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1209 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1210 octave_completion_matches_called = true; |
2234 | 1211 |
1212 return retval; | |
1213 } | |
1214 | |
20239
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1215 /* |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1216 %!assert (ischar (completion_matches (""))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1217 %!assert (ischar (completion_matches ("a"))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1218 %!assert (ischar (completion_matches (" "))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1219 %!assert (isempty (completion_matches (" "))) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1220 %!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
|
1221 %!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
|
1222 %!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
|
1223 %!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
|
1224 %!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
|
1225 |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1226 %!error completion_matches () |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1227 %!error completion_matches (1, 2) |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1228 */ |
48284e32530b
test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents:
20232
diff
changeset
|
1229 |
16879
cc3743a91652
Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1230 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
|
1231 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
|
1232 @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
|
1233 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
|
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 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
|
1236 (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
|
1237 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1238 @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
|
1239 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
|
1240 @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
|
1241 @end deftypefn */) |
3189 | 1242 { |
1243 int nargin = args.length (); | |
1244 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1245 if (nargin > 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1246 print_usage (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1247 |
3189 | 1248 if (nargin == 0) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1249 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
|
1250 else |
3189 | 1251 { |
5872 | 1252 std::string file = args(0).string_value (); |
3189 | 1253 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1254 octave::command_editor::read_init_file (file); |
3189 | 1255 } |
1256 | |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1257 return ovl (); |
3189 | 1258 } |
1259 | |
16880
1aebb613a5ac
Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents:
16879
diff
changeset
|
1260 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
|
1261 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
|
1262 @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
|
1263 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
|
1264 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1265 @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
|
1266 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
|
1267 @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
|
1268 @end deftypefn */) |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1269 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1270 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
|
1271 print_usage (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1272 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1273 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
|
1274 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1275 return ovl (); |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1276 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1277 |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1278 static int |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1279 internal_input_event_hook_fcn (void) |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1280 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1281 input_event_hook_functions.run (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1282 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1283 if (input_event_hook_functions.empty ()) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1284 octave::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
|
1285 |
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1286 return 0; |
3498 | 1287 } |
1288 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1289 DEFUN (add_input_event_hook, 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
|
1290 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
|
1291 @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
|
1292 @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
|
1293 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
|
1294 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
|
1295 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1296 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
|
1297 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1298 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1299 @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
|
1300 @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
|
1301 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1302 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
|
1303 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1304 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
|
1305 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
|
1306 @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
|
1307 @end deftypefn */) |
3498 | 1308 { |
1309 int nargin = args.length (); | |
1310 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1311 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
|
1312 print_usage (); |
3498 | 1313 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1314 octave_value user_data; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1315 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1316 if (nargin == 2) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1317 user_data = args(1); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1318 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1319 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
|
1320 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1321 if (input_event_hook_functions.empty ()) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1322 octave::command_editor::add_event_hook (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
|
1323 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1324 input_event_hook_functions.insert (hook_fcn.id (), hook_fcn); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1325 |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1326 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
|
1327 } |
3498 | 1328 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1329 DEFUN (remove_input_event_hook, 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
|
1330 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
|
1331 @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
|
1332 @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
|
1333 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
|
1334 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
|
1335 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
|
1336 @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
|
1337 @end deftypefn */) |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1338 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1339 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
|
1340 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1341 if (nargin < 1 || nargin > 2) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1342 print_usage (); |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1343 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1344 std::string hook_fcn_id = args(0).string_value ("remove_input_event_hook: argument not valid as a hook function name or id"); |
3498 | 1345 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1346 bool warn = (nargin < 2); |
3498 | 1347 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1348 hook_function_list::iterator p |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1349 = input_event_hook_functions.find (hook_fcn_id); |
3498 | 1350 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1351 if (p != input_event_hook_functions.end ()) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1352 input_event_hook_functions.erase (p); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1353 else if (warn) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1354 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
|
1355 hook_fcn_id.c_str ()); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1356 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1357 if (input_event_hook_functions.empty ()) |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
1358 octave::command_editor::remove_event_hook (internal_input_event_hook_fcn); |
3498 | 1359 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1360 return ovl (); |
3498 | 1361 } |
1362 | |
5794 | 1363 DEFUN (PS1, 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
|
1364 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
|
1365 @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
|
1366 @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
|
1367 @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
|
1368 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
|
1369 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1370 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
|
1371 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
|
1372 |
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 default value of the primary prompt string is @qcode{"octave:\#> "}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1374 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
|
1375 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1376 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1377 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
|
1378 @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
|
1379 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1380 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1381 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
|
1382 @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
|
1383 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
|
1384 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
|
1385 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1386 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
|
1387 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
|
1388 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1389 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1390 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
|
1391 @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
|
1392 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1393 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1394 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
|
1395 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1396 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
|
1397 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
|
1398 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
|
1399 @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
|
1400 @end deftypefn */) |
5794 | 1401 { |
1402 return SET_INTERNAL_VARIABLE (PS1); | |
1403 } | |
2181 | 1404 |
5794 | 1405 DEFUN (PS2, 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
|
1406 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
|
1407 @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
|
1408 @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
|
1409 @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
|
1410 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
|
1411 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1412 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
|
1413 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
|
1414 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
|
1415 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
|
1416 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
|
1417 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1418 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
|
1419 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
|
1420 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
|
1421 @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
|
1422 @end deftypefn */) |
5794 | 1423 { |
1424 return SET_INTERNAL_VARIABLE (PS2); | |
1425 } | |
2181 | 1426 |
5794 | 1427 DEFUN (PS4, 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
|
1428 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
|
1429 @deftypefn {} {@var{val} =} PS4 () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1430 @deftypefnx {} {@var{old_val} =} PS4 (@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
|
1431 @deftypefnx {} {} PS4 (@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
|
1432 Query or set the character string used to prefix output produced |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1433 when echoing commands is enabled. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1434 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1435 The default value 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
|
1436 @xref{Diary and Echo Commands}, for a description of echoing commands. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1437 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1438 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
|
1439 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
|
1440 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
|
1441 @seealso{echo, echo_executing_commands, PS1, PS2} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1442 @end deftypefn */) |
5794 | 1443 { |
1444 return SET_INTERNAL_VARIABLE (PS4); | |
1445 } | |
2181 | 1446 |
5794 | 1447 DEFUN (completion_append_char, 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
|
1448 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
|
1449 @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
|
1450 @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
|
1451 @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
|
1452 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
|
1453 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
|
1454 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1455 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
|
1456 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1457 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
|
1458 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
|
1459 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
|
1460 @end deftypefn */) |
5794 | 1461 { |
1462 return SET_INTERNAL_VARIABLE (completion_append_char); | |
1463 } | |
3019 | 1464 |
5794 | 1465 DEFUN (echo_executing_commands, 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
|
1466 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
|
1467 @deftypefn {} {@var{val} =} echo_executing_commands () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1468 @deftypefnx {} {@var{old_val} =} echo_executing_commands (@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
|
1469 @deftypefnx {} {} echo_executing_commands (@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
|
1470 Query or set the internal variable that controls the echo state. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1471 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1472 It may be the sum of the following values: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1473 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1474 @table @asis |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1475 @item 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1476 Echo commands read from script files. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1477 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1478 @item 2 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1479 Echo commands from functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1480 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1481 @item 4 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1482 Echo commands read from command line. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1483 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1484 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1485 More than one state can be active at once. For example, a value of 3 is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1486 equivalent to the command @kbd{echo on all}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1487 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1488 The value of @code{echo_executing_commands} may be set by the @kbd{echo} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1489 command or the command line option @option{--echo-commands}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1490 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1491 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
|
1492 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
|
1493 The original variable value is restored when exiting the function. |
22982
aca714a80cfc
doc: Add more sealso links between docstrings.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1494 |
aca714a80cfc
doc: Add more sealso links between docstrings.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1495 @seealso{echo} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1496 @end deftypefn */) |
5794 | 1497 { |
1498 return SET_INTERNAL_VARIABLE (echo_executing_commands); | |
2181 | 1499 } |
1500 | |
6257 | 1501 DEFUN (__request_drawnow__, 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
|
1502 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
|
1503 @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
|
1504 @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
|
1505 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
|
1506 @end deftypefn */) |
6257 | 1507 { |
1508 int nargin = args.length (); | |
1509 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1510 if (nargin > 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1511 print_usage (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1512 |
6257 | 1513 if (nargin == 0) |
1514 Vdrawnow_requested = true; | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1515 else |
6257 | 1516 Vdrawnow_requested = args(0).bool_value (); |
1517 | |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1518 return ovl (); |
6257 | 1519 } |
1520 | |
7294 | 1521 DEFUN (__gud_mode__, 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
|
1522 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
|
1523 @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
|
1524 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
|
1525 @end deftypefn */) |
7294 | 1526 { |
1527 int nargin = args.length (); | |
1528 | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1529 if (nargin > 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1530 print_usage (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1531 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1532 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1533 |
7294 | 1534 if (nargin == 0) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1535 retval = ovl (Vgud_mode); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1536 else |
7294 | 1537 Vgud_mode = args(0).bool_value (); |
1538 | |
21006
ea779f11deae
strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents:
20996
diff
changeset
|
1539 return retval; |
7294 | 1540 } |
1541 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1542 DEFUN (filemarker, 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
|
1543 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
|
1544 @deftypefn {} {@var{val} =} filemarker () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1545 @deftypefnx {} {@var{old_val} =} filemarker (@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
|
1546 @deftypefnx {} {} filemarker (@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
|
1547 Query or set the character used to separate the filename 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
|
1548 subfunction names contained within the file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1549 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1550 By default this is the character @samp{>}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1551 This can be used in a generic manner to interact with subfunctions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1552 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
|
1553 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1554 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1555 help (["myfunc", filemarker, "mysubfunc"]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1556 @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
|
1557 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1558 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1559 returns the help string associated with the subfunction @code{mysubfunc} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1560 located in the file @file{myfunc.m}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1561 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1562 @code{filemarker} is also useful during debugging for placing breakpoints |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1563 within subfunctions or nested functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1564 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
|
1565 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1566 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1567 dbstop (["myfunc", filemarker, "mysubfunc"]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1568 @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
|
1569 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1570 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1571 will set a breakpoint at the first line of the subfunction @code{mysubfunc}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1572 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21920
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 @end deftypefn */) |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1577 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1578 char tmp = Vfilemarker; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1579 octave_value retval = SET_INTERNAL_VARIABLE (filemarker); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1580 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1581 // The character passed must not be a legal character for a function name |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20239
diff
changeset
|
1582 if (::isalnum (Vfilemarker) || Vfilemarker == '_') |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1583 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1584 Vfilemarker = tmp; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1585 error ("filemarker: character can not be a valid character for a function name"); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1586 } |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1587 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1588 return retval; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1589 } |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
1590 |