Mercurial > hg > octave-lyh
annotate libinterp/interpfcn/input.cc @ 16139:2fd39ab12209
move a function and data member from lexical_feedback to octave_parser
* parse.h: Include lex.h.
* parse.h, oct-parse.yy (octave_parser::reset): New function.
(octave_parser::end_of_input): New data member.
(octave_parser::octave_parser): Initialize it.
* lex.h, lex.ll (lexical_feedback::reset): Rename from reset_parser.
(lexical_feedback::parser_end_of_input): Delete.
* input.cc (get_debug_input): Call octave_parser::reset, not
lexical_feedback::reset_parser.
* toplev.cc (main_loop): Likewise.
* oct-parse.yy (eval_string, parse_fcn_file): Likewise.
* toplev.cc (main_loop): Set octave_parser::end_of_input, not
lexical_feedback::parser_end_of_input.
* oct-parse.yy: Use octave_parser::end_of_input, not
lexical_feedback::parser_end_of_input.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 27 Feb 2013 13:09:33 -0500 |
parents | 284e2ca86ef7 |
children | 49dfba4fd3c5 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13970
diff
changeset
|
3 Copyright (C) 1993-2012 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 | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
2939 | 23 // Get command input interactively or from files. |
1 | 24 |
240 | 25 #ifdef HAVE_CONFIG_H |
1192 | 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 | |
529 | 38 #include <sys/types.h> |
39 #include <unistd.h> | |
1343 | 40 |
2927 | 41 #include "cmd-edit.h" |
3189 | 42 #include "file-ops.h" |
4153 | 43 #include "quit.h" |
1755 | 44 #include "str-vec.h" |
45 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
46 #include "debug.h" |
1352 | 47 #include "defun.h" |
48 #include "dirfns.h" | |
1 | 49 #include "error.h" |
2181 | 50 #include "gripes.h" |
3016 | 51 #include "help.h" |
1 | 52 #include "input.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" |
1352 | 55 #include "oct-map.h" |
1742 | 56 #include "oct-hist.h" |
1670 | 57 #include "toplev.h" |
1755 | 58 #include "oct-obj.h" |
1 | 59 #include "pager.h" |
529 | 60 #include "parse.h" |
1352 | 61 #include "pathlen.h" |
3772 | 62 #include "pt.h" |
1755 | 63 #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
|
64 #include "pt-eval.h" |
3805 | 65 #include "pt-stmt.h" |
1352 | 66 #include "sighandlers.h" |
1114 | 67 #include "sysdep.h" |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
68 #include "toplev.h" |
3098 | 69 #include "unwind-prot.h" |
1352 | 70 #include "utils.h" |
71 #include "variables.h" | |
529 | 72 |
2181 | 73 // Primary prompt string. |
5794 | 74 static std::string VPS1 = "\\s:\\#> "; |
2181 | 75 |
76 // Secondary prompt string. | |
5794 | 77 static std::string VPS2 = "> "; |
2181 | 78 |
79 // String printed before echoed input (enabled by --echo-input). | |
5794 | 80 std::string VPS4 = "+ "; |
2181 | 81 |
3019 | 82 // Echo commands as they are executed? |
83 // | |
84 // 1 ==> echo commands read from script files | |
85 // 2 ==> echo commands from functions | |
86 // 4 ==> echo commands read from command line | |
87 // | |
88 // more than one state can be active at once. | |
5794 | 89 int Vecho_executing_commands = ECHO_OFF; |
3019 | 90 |
3165 | 91 // The time we last printed a prompt. |
5832 | 92 octave_time Vlast_prompt_time = 0.0; |
3165 | 93 |
2181 | 94 // Character to append after successful command-line completion attempts. |
5794 | 95 static char Vcompletion_append_char = ' '; |
2181 | 96 |
1 | 97 // Global pointer for eval(). |
3523 | 98 std::string current_eval_string; |
1 | 99 |
3019 | 100 // TRUE means get input from current_eval_string. |
101 bool get_input_from_eval_string = false; | |
1 | 102 |
5189 | 103 // TRUE means that input is coming from a file that was named on |
104 // the command line. | |
105 bool input_from_command_line_file = false; | |
106 | |
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
|
107 // TRUE means that stdin is a terminal, not a pipe or redirected file. |
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
|
108 bool stdin_is_tty = false; |
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
|
109 |
3019 | 110 // TRUE means we're parsing a function file. |
111 bool reading_fcn_file = false; | |
1 | 112 |
9476 | 113 // TRUE means we're parsing a classdef file. |
114 bool reading_classdef_file = false; | |
115 | |
338 | 116 // Simple name of function file we are reading. |
3523 | 117 std::string curr_fcn_file_name; |
1606 | 118 |
119 // Full name of file we are reading. | |
3523 | 120 std::string curr_fcn_file_full_name; |
1 | 121 |
3019 | 122 // TRUE means we're parsing a script file. |
123 bool reading_script_file = false; | |
1 | 124 |
125 // If we are reading from an M-file, this is it. | |
529 | 126 FILE *ff_instream = 0; |
1 | 127 |
3019 | 128 // TRUE means this is an interactive shell. |
129 bool interactive = false; | |
1 | 130 |
3019 | 131 // TRUE means the user forced this shell to be interactive (-i). |
132 bool forced_interactive = false; | |
1 | 133 |
134 // Should we issue a prompt? | |
135 int promptflag = 1; | |
136 | |
137 // The current line of input, from wherever. | |
3523 | 138 std::string current_input_line; |
1 | 139 |
3804 | 140 // TRUE after a call to completion_matches. |
2299 | 141 bool octave_completion_matches_called = false; |
142 | |
6257 | 143 // TRUE if the plotting system has requested a call to drawnow at |
144 // the next user prompt. | |
7409 | 145 bool Vdrawnow_requested = false; |
6257 | 146 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
147 // TRUE if we are in debugging mode. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
148 bool Vdebugging = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
149 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
150 // 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
|
151 // that we can repeat the previous command if the user just types RET. |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
152 static std::string last_debugging_command; |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
153 |
7294 | 154 // TRUE if we are running in the Emacs GUD mode. |
155 static bool Vgud_mode = false; | |
156 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
157 // 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
|
158 char Vfilemarker = '>'; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
159 |
1044 | 160 static void |
3523 | 161 do_input_echo (const std::string& input_string) |
1044 | 162 { |
1588 | 163 int do_echo = reading_script_file ? |
2205 | 164 (Vecho_executing_commands & ECHO_SCRIPTS) |
2618 | 165 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; |
1588 | 166 |
167 if (do_echo) | |
1044 | 168 { |
1403 | 169 if (forced_interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
170 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
171 if (promptflag > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
172 octave_stdout << command_editor::decode_prompt_string (VPS1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
173 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
174 octave_stdout << command_editor::decode_prompt_string (VPS2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
175 } |
1403 | 176 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
177 octave_stdout << command_editor::decode_prompt_string (VPS4); |
1044 | 178 |
1755 | 179 if (! input_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
180 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
181 octave_stdout << input_string; |
1755 | 182 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
183 if (input_string[input_string.length () - 1] != '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
184 octave_stdout << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
185 } |
1044 | 186 } |
187 } | |
188 | |
3536 | 189 std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
190 gnu_readline (const std::string& s, bool& eof, bool force_readline) |
1822 | 191 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
192 octave_quit (); |
5142 | 193 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
194 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
195 |
3523 | 196 std::string retval; |
1822 | 197 |
2927 | 198 if (line_editing || force_readline) |
1822 | 199 { |
3219 | 200 retval = command_editor::readline (s, eof); |
201 | |
202 if (! eof && retval.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
203 retval = "\n"; |
1822 | 204 } |
205 else | |
206 { | |
2927 | 207 if (! s.empty () && (interactive || forced_interactive)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
208 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
209 FILE *stream = command_editor::get_output_stream (); |
2927 | 210 |
10411 | 211 gnulib::fputs (s.c_str (), stream); |
12912
e116dd862879
use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
212 gnulib::fflush (stream); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
213 } |
1822 | 214 |
2927 | 215 FILE *curr_stream = command_editor::get_input_stream (); |
216 | |
9476 | 217 if (reading_fcn_file || reading_script_file || reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
218 curr_stream = ff_instream; |
1822 | 219 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
220 retval = octave_fgets (curr_stream, eof); |
1822 | 221 } |
222 | |
223 return retval; | |
224 } | |
581 | 225 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
226 extern std::string |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
227 gnu_readline (const std::string& s, bool force_readline) |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
228 { |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
229 bool eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
230 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
231 return gnu_readline (s, eof, force_readline); |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
232 } |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
233 |
6257 | 234 static inline std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
235 interactive_input (const std::string& s, bool& eof, bool force_readline) |
6257 | 236 { |
237 Vlast_prompt_time.stamp (); | |
238 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
239 if (Vdrawnow_requested && (interactive || forced_interactive)) |
6257 | 240 { |
241 feval ("drawnow"); | |
242 | |
6367 | 243 flush_octave_stdout (); |
244 | |
6305 | 245 // We set Vdrawnow_requested to false even if there is an error |
246 // in drawnow so that the error doesn't reappear at every prompt. | |
247 | |
6257 | 248 Vdrawnow_requested = false; |
6305 | 249 |
250 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
251 return "\n"; |
6257 | 252 } |
253 | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
254 return gnu_readline (s, eof, force_readline); |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
255 } |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
256 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
257 static inline std::string |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
258 interactive_input (const std::string& s, bool force_readline = false) |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
259 { |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
260 bool eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
261 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
262 return interactive_input (s, eof, force_readline); |
6257 | 263 } |
264 | |
3536 | 265 static std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
266 octave_gets (bool& eof) |
1 | 267 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
268 octave_quit (); |
5142 | 269 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
270 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
271 |
3523 | 272 std::string retval; |
1 | 273 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
274 bool history_skip_auto_repeated_debugging_command = false; |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
275 |
1822 | 276 if ((interactive || forced_interactive) |
5832 | 277 && (! (reading_fcn_file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
278 || reading_classdef_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
279 || reading_script_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
280 || get_input_from_eval_string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
281 || input_from_startup_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
282 || input_from_command_line_file))) |
1 | 283 { |
5794 | 284 std::string ps = (promptflag > 0) ? VPS1 : VPS2; |
1755 | 285 |
3523 | 286 std::string prompt = command_editor::decode_prompt_string (ps); |
1 | 287 |
2618 | 288 pipe_handler_error_count = 0; |
289 | |
290 flush_octave_stdout (); | |
1 | 291 |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
292 octave_pager_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
293 octave_diary_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
294 |
2095 | 295 octave_diary << prompt; |
581 | 296 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
297 retval = interactive_input (prompt, eof, false); |
5832 | 298 |
299 // There is no need to update the load_path cache if there is no | |
300 // user input. | |
8019
0ef13e15319b
replace NPOS with std::string::npos
John W. Eaton <jwe@octave.org>
parents:
7913
diff
changeset
|
301 if (! retval.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
302 && retval.find_first_not_of (" \t\n\r") != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
303 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
304 load_path::update (); |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
305 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
306 if (Vdebugging) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
307 last_debugging_command = retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
308 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
309 last_debugging_command = std::string (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
310 } |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
311 else if (Vdebugging) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
312 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
313 retval = last_debugging_command; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
314 history_skip_auto_repeated_debugging_command = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
315 } |
1 | 316 } |
317 else | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
318 retval = gnu_readline ("", eof, false); |
1 | 319 |
2927 | 320 current_input_line = retval; |
1 | 321 |
1822 | 322 if (! current_input_line.empty ()) |
1 | 323 { |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
324 if (! (input_from_startup_file || input_from_command_line_file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
325 || history_skip_auto_repeated_debugging_command)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
326 command_history::add (current_input_line); |
1 | 327 |
9476 | 328 if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
329 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
330 octave_diary << current_input_line; |
3176 | 331 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
332 if (current_input_line[current_input_line.length () - 1] != '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
333 octave_diary << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
334 } |
581 | 335 |
1822 | 336 do_input_echo (current_input_line); |
1 | 337 } |
9476 | 338 else if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) |
3176 | 339 octave_diary << "\n"; |
9476 | 340 |
1822 | 341 return retval; |
1 | 342 } |
343 | |
581 | 344 // Read a line from the input stream. |
345 | |
16098
24b3800d30e7
move octave_read to lex.ll
John W. Eaton <jwe@octave.org>
parents:
16097
diff
changeset
|
346 std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
347 get_user_input (bool& eof) |
1 | 348 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
349 octave_quit (); |
5142 | 350 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
351 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
352 |
3523 | 353 std::string retval; |
1 | 354 |
355 if (get_input_from_eval_string) | |
356 { | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
357 retval = current_eval_string; |
3877 | 358 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
359 size_t len = retval.length (); |
1822 | 360 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
361 // Clear the global eval string so that the next call will return |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
362 // an empty character string with EOF = true. |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
363 current_eval_string = ""; |
1822 | 364 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
365 eof = true; |
1822 | 366 } |
367 else | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
368 retval = octave_gets (eof); |
1822 | 369 |
2927 | 370 current_input_line = retval; |
1822 | 371 |
372 return retval; | |
373 } | |
374 | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14880
diff
changeset
|
375 // Fix things up so that input can come from file 'name', printing a |
581 | 376 // warning if the file doesn't exist. |
377 | |
1 | 378 FILE * |
3523 | 379 get_input_from_file (const std::string& name, int warn) |
1 | 380 { |
529 | 381 FILE *instream = 0; |
1 | 382 |
1750 | 383 if (name.length () > 0) |
12941
9a498efac5f1
use gnulib::fseek and gnulib::fopen
John W. Eaton <jwe@octave.org>
parents:
12912
diff
changeset
|
384 instream = gnulib::fopen (name.c_str (), "rb"); |
1 | 385 |
529 | 386 if (! instream && warn) |
1750 | 387 warning ("%s: no such file or directory", name.c_str ()); |
1 | 388 |
9476 | 389 if (reading_fcn_file || reading_script_file || reading_classdef_file) |
339 | 390 ff_instream = instream; |
1 | 391 else |
2927 | 392 command_editor::set_input_stream (instream); |
1 | 393 |
394 return instream; | |
395 } | |
396 | |
581 | 397 // Fix things up so that input can come from the standard input. This |
398 // may need to become much more complicated, which is why it's in a | |
399 // separate function. | |
400 | |
1 | 401 FILE * |
402 get_input_from_stdin (void) | |
403 { | |
2927 | 404 command_editor::set_input_stream (stdin); |
405 return command_editor::get_input_stream (); | |
1 | 406 } |
407 | |
5775 | 408 // FIXME -- make this generate file names when appropriate. |
2921 | 409 |
2247 | 410 static string_vector |
3523 | 411 generate_possible_completions (const std::string& text, std::string& prefix, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
412 std::string& hint) |
1280 | 413 { |
2247 | 414 string_vector names; |
1280 | 415 |
2921 | 416 prefix = ""; |
1280 | 417 |
4604 | 418 if (looks_like_struct (text)) |
1430 | 419 names = generate_struct_completions (text, prefix, hint); |
420 else | |
2247 | 421 names = make_name_list (); |
1280 | 422 |
2944 | 423 // Sort and remove duplicates. |
2348 | 424 |
8503
8ba2ee57c594
remove qsort in favor of sort
Jaroslav Hajek <highegg@gmail.com>
parents:
8447
diff
changeset
|
425 names.sort (true); |
2348 | 426 |
1280 | 427 return names; |
428 } | |
429 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
430 static bool |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
431 is_completing_dirfns (void) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
432 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
433 static std::string dirfns_commands[] = {"cd", "ls"}; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
434 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
|
435 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
436 bool retval = false; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
437 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
438 std::string line = command_editor::get_line_buffer (); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
439 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
440 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
|
441 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
442 int index = line.find (dirfns_commands[i] + " "); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
443 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
444 if (index == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
445 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
446 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
447 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
448 } |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
449 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
450 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
451 return retval; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
452 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
453 |
3536 | 454 static std::string |
3523 | 455 generate_completion (const std::string& text, int state) |
1280 | 456 { |
3523 | 457 std::string retval; |
2944 | 458 |
3523 | 459 static std::string prefix; |
460 static std::string hint; | |
1280 | 461 |
2921 | 462 static size_t hint_len = 0; |
1280 | 463 |
1 | 464 static int list_index = 0; |
2921 | 465 static int name_list_len = 0; |
4604 | 466 static int name_list_total_len = 0; |
2247 | 467 static string_vector name_list; |
4604 | 468 static string_vector file_name_list; |
1 | 469 |
1280 | 470 static int matches = 0; |
1 | 471 |
472 if (state == 0) | |
473 { | |
474 list_index = 0; | |
475 | |
2921 | 476 prefix = ""; |
1280 | 477 |
2921 | 478 hint = text; |
1280 | 479 |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
480 // 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
|
481 // file/directory operation. |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
482 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
483 if (is_completing_dirfns ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
484 name_list = string_vector (); |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
485 else |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
486 name_list = generate_possible_completions (text, prefix, hint); |
1280 | 487 |
2921 | 488 name_list_len = name_list.length (); |
489 | |
4604 | 490 file_name_list = command_editor::generate_filename_completions (text); |
491 | |
492 name_list.append (file_name_list); | |
493 | |
494 name_list_total_len = name_list.length (); | |
495 | |
2921 | 496 hint_len = hint.length (); |
1280 | 497 |
498 matches = 0; | |
2247 | 499 |
2921 | 500 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
|
501 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
|
502 matches++; |
1 | 503 } |
504 | |
4604 | 505 if (name_list_total_len > 0 && matches > 0) |
1 | 506 { |
4604 | 507 while (list_index < name_list_total_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
508 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
509 std::string name = name_list[list_index]; |
2247 | 510 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
511 list_index++; |
2247 | 512 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
513 if (hint == name.substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
514 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
515 if (list_index <= name_list_len && ! prefix.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
516 retval = prefix + "." + name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
517 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
518 retval = name; |
1280 | 519 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
520 // FIXME -- looks_like_struct is broken for now, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
521 // so it always returns false. |
4179 | 522 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
523 if (matches == 1 && looks_like_struct (retval)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
524 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
525 // 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
|
526 // whether it should be '(' or '.'. |
4179 | 527 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
528 command_editor::set_completion_append_character ('\0'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
529 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
530 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
531 command_editor::set_completion_append_character |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
532 (Vcompletion_append_char); |
1280 | 533 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
534 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
535 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
536 } |
1 | 537 } |
538 | |
2944 | 539 return retval; |
1 | 540 } |
541 | |
6979 | 542 static std::string |
543 quoting_filename (const std::string &text, int, char quote) | |
544 { | |
545 if (quote) | |
546 return text; | |
547 else | |
548 return (std::string ("'") + text); | |
549 } | |
550 | |
2927 | 551 void |
552 initialize_command_input (void) | |
553 { | |
554 // If we are using readline, this allows conditional parsing of the | |
555 // .inputrc file. | |
269 | 556 |
2927 | 557 command_editor::set_name ("Octave"); |
1358 | 558 |
5775 | 559 // FIXME -- this needs to include a comma too, but that |
3933 | 560 // causes trouble for the new struct element completion code. |
561 | |
4272 | 562 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
3933 | 563 |
564 command_editor::set_basic_word_break_characters (s); | |
565 | |
566 command_editor::set_completer_word_break_characters (s); | |
567 | |
3004 | 568 command_editor::set_basic_quote_characters ("\""); |
2944 | 569 |
6979 | 570 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
571 command_editor::set_completer_quote_characters ("'\""); | |
572 | |
2944 | 573 command_editor::set_completion_function (generate_completion); |
6979 | 574 |
575 command_editor::set_quoting_function (quoting_filename); | |
269 | 576 } |
577 | |
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
|
578 static void |
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
|
579 get_debug_input (const std::string& prompt) |
269 | 580 { |
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
|
581 octave_user_code *caller = octave_call_stack::caller_user_code (); |
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
|
582 std::string nm; |
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
|
583 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
584 int curr_debug_line = octave_call_stack::current_line (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
585 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
586 bool have_file = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
587 |
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
|
588 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
|
589 { |
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
|
590 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
|
591 |
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
|
592 if (nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
593 nm = caller->name (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
594 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
595 have_file = true; |
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
|
596 } |
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
|
597 else |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
598 curr_debug_line = -1; |
3180 | 599 |
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
|
600 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
|
601 |
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
|
602 if (! nm.empty ()) |
3180 | 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 (Vgud_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
605 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
606 static char ctrl_z = 'Z' & 0x1f; |
269 | 607 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
608 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
|
609 } |
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
|
610 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
611 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
612 // FIXME -- we should come up with a clean way to detect |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
613 // 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
|
614 // 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
|
615 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
616 buf << "stopped in " << nm; |
1 | 617 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
618 if (curr_debug_line > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
619 buf << " at line " << curr_debug_line; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
620 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
621 if (have_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
622 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
623 std::string line_buf |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
624 = 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
|
625 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
626 if (! line_buf.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
627 buf << "\n" << curr_debug_line << ": " << line_buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
628 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
629 } |
3180 | 630 } |
631 | |
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
|
632 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
|
633 |
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
|
634 if (! msg.empty ()) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
635 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
|
636 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
637 unwind_protect frame; |
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
|
638 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
639 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
|
640 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
|
641 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
642 if (! (interactive || forced_interactive) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
643 || (reading_fcn_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
644 || reading_classdef_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
645 || reading_script_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
646 || get_input_from_eval_string |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
647 || input_from_startup_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
648 || input_from_command_line_file)) |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
649 { |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
650 frame.protect_var (forced_interactive); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
651 forced_interactive = true; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
652 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
653 frame.protect_var (reading_fcn_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
654 reading_fcn_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
655 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
656 frame.protect_var (reading_classdef_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
657 reading_classdef_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
658 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
659 frame.protect_var (reading_script_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
660 reading_script_file = false; |
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
|
661 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
662 frame.protect_var (input_from_startup_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
663 input_from_startup_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
664 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
665 frame.protect_var (input_from_command_line_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
666 input_from_command_line_file = false; |
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
|
667 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
668 frame.protect_var (get_input_from_eval_string); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
669 get_input_from_eval_string = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
670 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
671 YY_BUFFER_STATE old_buf = current_buffer (); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
672 YY_BUFFER_STATE new_buf = create_buffer (get_input_from_stdin ()); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
673 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
674 // FIXME: are these safe? |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
675 frame.add_fcn (switch_to_buffer, old_buf); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
676 frame.add_fcn (delete_buffer, new_buf); |
7903
8018e10d2b87
save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
677 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
678 switch_to_buffer (new_buf); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
679 } |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
680 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
681 frame.protect_var (curr_lexer); |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
682 curr_lexer = new lexical_feedback (); |
16115
4f6c37cfbdce
cleanup lexical_feedback objects
John W. Eaton <jwe@octave.org>
parents:
16110
diff
changeset
|
683 frame.add_fcn (lexical_feedback::cleanup, curr_lexer); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
684 |
16133
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16127
diff
changeset
|
685 frame.protect_var (curr_parser); |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16127
diff
changeset
|
686 curr_parser = new octave_parser (); |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16127
diff
changeset
|
687 frame.add_fcn (octave_parser::cleanup, curr_parser); |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16127
diff
changeset
|
688 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
689 while (Vdebugging) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
690 { |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
691 unwind_protect middle_frame; |
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
692 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
693 reset_error_handler (); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
694 |
16139
2fd39ab12209
move a function and data member from lexical_feedback to octave_parser
John W. Eaton <jwe@octave.org>
parents:
16138
diff
changeset
|
695 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
|
696 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
697 // Save current value of global_command. |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
698 middle_frame.protect_var (global_command); |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
699 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
700 global_command = 0; |
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 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
702 // Do this with an unwind-protect cleanup function so that the |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
703 // forced variables will be unmarked in the event of an interrupt. |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
704 symbol_table::scope_id scope = symbol_table::top_scope (); |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
705 middle_frame.add_fcn (symbol_table::unmark_forced_variables, scope); |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9215
diff
changeset
|
706 |
16138
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
707 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
|
708 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
709 if (retval == 0 && global_command) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
710 { |
13970 | 711 unwind_protect inner_frame; |
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
|
712 |
13970 | 713 // Use an unwind-protect cleanup function so that the |
714 // global_command list will be deleted in the event of an | |
715 // interrupt. | |
716 | |
717 inner_frame.add_fcn (cleanup_statement_list, &global_command); | |
718 | |
719 global_command->accept (*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
|
720 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
721 if (octave_completion_matches_called) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
722 octave_completion_matches_called = false; |
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
|
723 } |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
724 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
725 octave_quit (); |
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
|
726 } |
529 | 727 } |
728 | |
581 | 729 // If the user simply hits return, this will produce an empty matrix. |
730 | |
2086 | 731 static octave_value_list |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
732 get_user_input (const octave_value_list& args, int nargout) |
529 | 733 { |
3100 | 734 octave_value_list retval; |
529 | 735 |
736 int nargin = args.length (); | |
737 | |
738 int read_as_string = 0; | |
739 | |
712 | 740 if (nargin == 2) |
529 | 741 read_as_string++; |
742 | |
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
|
743 std::string prompt = args(0).string_value (); |
4975 | 744 |
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
|
745 if (error_state) |
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
|
746 { |
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
|
747 error ("input: unrecognized argument"); |
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
|
748 return retval; |
4975 | 749 } |
750 | |
2095 | 751 flush_octave_stdout (); |
529 | 752 |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
753 octave_pager_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
754 octave_diary_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
755 |
4565 | 756 octave_diary << prompt; |
757 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
758 std::string input_buf = interactive_input (prompt.c_str (), true); |
529 | 759 |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
760 if (! (error_state || input_buf.empty ())) |
529 | 761 { |
1799 | 762 if (! input_from_startup_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
763 command_history::add (input_buf); |
529 | 764 |
2927 | 765 size_t len = input_buf.length (); |
529 | 766 |
4565 | 767 octave_diary << input_buf; |
768 | |
769 if (input_buf[len - 1] != '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
770 octave_diary << "\n"; |
4565 | 771 |
529 | 772 if (len < 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
773 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
3772 | 774 |
775 if (read_as_string) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
776 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
777 // FIXME -- fix gnu_readline and octave_gets instead! |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
778 if (input_buf.length () == 1 && input_buf[0] == '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
779 retval(0) = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
780 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
781 retval(0) = input_buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
782 } |
529 | 783 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
784 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
785 int parse_status = 0; |
2900 | 786 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
787 retval = eval_string (input_buf, true, parse_status, nargout); |
3100 | 788 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
789 if (! Vdebugging && retval.length () == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
790 retval(0) = Matrix (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
791 } |
529 | 792 } |
793 else | |
794 error ("input: reading user-input failed!"); | |
795 | |
796 return retval; | |
797 } | |
798 | |
3100 | 799 DEFUN (input, args, nargout, |
3372 | 800 "-*- texinfo -*-\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
801 @deftypefn {Built-in Function} {@var{ans} =} input (@var{prompt})\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
802 @deftypefnx {Built-in Function} {@var{ans} =} input (@var{prompt}, \"s\")\n\ |
3372 | 803 Print a prompt and wait for user input. For example,\n\ |
804 \n\ | |
805 @example\n\ | |
806 input (\"Pick a number, any number! \")\n\ | |
807 @end example\n\ | |
808 \n\ | |
809 @noindent\n\ | |
810 prints the prompt\n\ | |
811 \n\ | |
812 @example\n\ | |
813 Pick a number, any number!\n\ | |
814 @end example\n\ | |
529 | 815 \n\ |
3372 | 816 @noindent\n\ |
817 and waits for the user to enter a value. The string entered by the user\n\ | |
818 is evaluated as an expression, so it may be a literal constant, a\n\ | |
819 variable name, or any other valid expression.\n\ | |
820 \n\ | |
821 Currently, @code{input} only returns one value, regardless of the number\n\ | |
822 of values produced by the evaluation of the expression.\n\ | |
823 \n\ | |
824 If you are only interested in getting a literal string value, you can\n\ | |
825 call @code{input} with the character string @code{\"s\"} as the second\n\ | |
826 argument. This tells Octave to return the string entered by the user\n\ | |
827 directly, without evaluating it first.\n\ | |
828 \n\ | |
829 Because there may be output waiting to be displayed by the pager, it is\n\ | |
830 a good idea to always call @code{fflush (stdout)} before calling\n\ | |
831 @code{input}. This will ensure that all pending output is written to\n\ | |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
832 the screen before your prompt.\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
833 @seealso{yes_or_no, kbhit}\n\ |
3372 | 834 @end deftypefn") |
529 | 835 { |
2086 | 836 octave_value_list retval; |
529 | 837 |
838 int nargin = args.length (); | |
839 | |
712 | 840 if (nargin == 1 || nargin == 2) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
841 retval = get_user_input (args, nargout); |
529 | 842 else |
5823 | 843 print_usage (); |
529 | 844 |
845 return retval; | |
846 } | |
847 | |
5640 | 848 bool |
849 octave_yes_or_no (const std::string& prompt) | |
850 { | |
851 std::string prompt_string = prompt + "(yes or no) "; | |
852 | |
853 while (1) | |
854 { | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
855 std::string input_buf = interactive_input (prompt_string, true); |
5640 | 856 |
857 if (input_buf == "yes") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
858 return true; |
5640 | 859 else if (input_buf == "no") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
860 return false; |
5640 | 861 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
862 message (0, "Please answer yes or no."); |
5640 | 863 } |
864 } | |
865 | |
866 DEFUN (yes_or_no, args, , | |
867 "-*- texinfo -*-\n\ | |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
868 @deftypefn {Built-in Function} {@var{ans} =} yes_or_no (\"@var{prompt}\")\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
869 Ask the user a yes-or-no question. Return logical true if the answer is yes\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
870 or false if the answer is no. Takes one argument, @var{prompt}, which is\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
871 the string to display when asking the question. @var{prompt} should end in\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
872 a space; @code{yes-or-no} adds the string @samp{(yes or no) } to it. The\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
873 user must confirm the answer with @key{RET} and can edit it until it has\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
874 been confirmed.\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
875 @seealso{input}\n\ |
5640 | 876 @end deftypefn") |
877 { | |
878 octave_value retval; | |
879 | |
880 int nargin = args.length (); | |
881 | |
882 if (nargin == 0 || nargin == 1) | |
883 { | |
884 std::string prompt; | |
885 | |
886 if (nargin == 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
887 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
888 prompt = args(0).string_value (); |
5640 | 889 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
890 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
891 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
892 error ("yes_or_no: PROMPT must be a character string"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
893 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
894 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
895 } |
5640 | 896 |
897 retval = octave_yes_or_no (prompt); | |
898 } | |
899 else | |
5823 | 900 print_usage (); |
5640 | 901 |
902 return retval; | |
903 } | |
904 | |
3707 | 905 octave_value |
906 do_keyboard (const octave_value_list& args) | |
907 { | |
908 octave_value retval; | |
909 | |
910 int nargin = args.length (); | |
911 | |
912 assert (nargin == 0 || nargin == 1); | |
913 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
914 unwind_protect frame; |
3707 | 915 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
916 frame.add_fcn (command_history::ignore_entries, |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
917 command_history::ignoring_entries ()); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
918 |
3707 | 919 command_history::ignore_entries (false); |
920 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
921 frame.protect_var (Vdebugging); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
922 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
923 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
924 octave_call_stack::current_frame ()); |
3707 | 925 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
926 // FIXME -- probably we just want to print one line, not the |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
927 // 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
|
928 // |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
929 // 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
|
930 // stmt.accept (tpc); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
931 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
932 Vdebugging = true; |
3707 | 933 |
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
|
934 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
|
935 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
|
936 prompt = args(0).string_value (); |
4233 | 937 |
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
|
938 if (! error_state) |
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
|
939 get_debug_input (prompt); |
3707 | 940 |
941 return retval; | |
942 } | |
943 | |
1957 | 944 DEFUN (keyboard, args, , |
3372 | 945 "-*- texinfo -*-\n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
946 @deftypefn {Built-in Function} {} keyboard ()\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
947 @deftypefnx {Built-in Function} {} keyboard (\"@var{prompt}\")\n\ |
3372 | 948 This function is normally used for simple debugging. When the\n\ |
949 @code{keyboard} function is executed, Octave prints a prompt and waits\n\ | |
950 for user input. The input strings are then evaluated and the results\n\ | |
951 are printed. This makes it possible to examine the values of variables\n\ | |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
952 within a function, and to assign new values if necessary. To leave the\n\ |
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
953 prompt and return to normal execution type @samp{return} or @samp{dbcont}.\n\ |
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
954 The @code{keyboard} function does not return an exit status.\n\ |
529 | 955 \n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
956 If @code{keyboard} is invoked without arguments, a default prompt of\n\ |
3372 | 957 @samp{debug> } is used.\n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
958 @seealso{dbcont, dbquit}\n\ |
3372 | 959 @end deftypefn") |
529 | 960 { |
2086 | 961 octave_value_list retval; |
529 | 962 |
963 int nargin = args.length (); | |
964 | |
712 | 965 if (nargin == 0 || nargin == 1) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
966 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
967 unwind_protect frame; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
968 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
969 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
970 octave_call_stack::current_frame ()); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
971 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
972 // Skip the frame assigned to the keyboard function. |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
973 octave_call_stack::goto_frame_relative (0); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
974 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
975 tree_evaluator::debug_mode = true; |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
976 |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
977 tree_evaluator::current_frame = octave_call_stack::current_frame (); |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
978 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
979 do_keyboard (args); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
980 } |
529 | 981 else |
5823 | 982 print_usage (); |
529 | 983 |
984 return retval; | |
985 } | |
986 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
987 DEFUN (echo, args, , |
3332 | 988 "-*- texinfo -*-\n\ |
11547 | 989 @deftypefn {Command} {} echo options\n\ |
3332 | 990 Control whether commands are displayed as they are executed. Valid\n\ |
991 options are:\n\ | |
1588 | 992 \n\ |
3332 | 993 @table @code\n\ |
994 @item on\n\ | |
995 Enable echoing of commands as they are executed in script files.\n\ | |
996 \n\ | |
997 @item off\n\ | |
998 Disable echoing of commands as they are executed in script files.\n\ | |
1588 | 999 \n\ |
3332 | 1000 @item on all\n\ |
1001 Enable echoing of commands as they are executed in script files and\n\ | |
1002 functions.\n\ | |
1588 | 1003 \n\ |
3332 | 1004 @item off all\n\ |
1005 Disable echoing of commands as they are executed in script files and\n\ | |
1006 functions.\n\ | |
1007 @end table\n\ | |
1008 \n\ | |
1009 @noindent\n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1010 With no arguments, @code{echo} toggles the current echo state.\n\ |
11547 | 1011 @end deftypefn") |
1588 | 1012 { |
2086 | 1013 octave_value_list retval; |
1588 | 1014 |
1755 | 1015 int argc = args.length () + 1; |
1016 | |
1968 | 1017 string_vector argv = args.make_argv ("echo"); |
1755 | 1018 |
1019 if (error_state) | |
1020 return retval; | |
1588 | 1021 |
1022 switch (argc) | |
1023 { | |
1024 case 1: | |
1025 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1026 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1027 || (Vecho_executing_commands & ECHO_FUNCTIONS)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1028 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1029 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1030 Vecho_executing_commands = ECHO_SCRIPTS; |
1588 | 1031 } |
1032 break; | |
1033 | |
1034 case 2: | |
1035 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1036 std::string arg = argv[1]; |
1755 | 1037 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1038 if (arg == "on") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1039 Vecho_executing_commands = ECHO_SCRIPTS; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1040 else if (arg == "off") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1041 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1042 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1043 print_usage (); |
1588 | 1044 } |
1045 break; | |
1046 | |
1047 case 3: | |
1048 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1049 std::string arg = argv[1]; |
1755 | 1050 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1051 if (arg == "on" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1052 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1053 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1054 Vecho_executing_commands = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1055 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1056 else if (arg == "off" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1057 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1058 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1059 print_usage (); |
1588 | 1060 } |
1061 break; | |
1062 | |
1063 default: | |
5823 | 1064 print_usage (); |
1588 | 1065 break; |
1066 } | |
1067 | |
1068 return retval; | |
1069 } | |
1070 | |
2234 | 1071 DEFUN (completion_matches, args, nargout, |
3332 | 1072 "-*- texinfo -*-\n\ |
1073 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ | |
1074 Generate possible completions given @var{hint}.\n\ | |
2299 | 1075 \n\ |
1076 This function is provided for the benefit of programs like Emacs which\n\ | |
3332 | 1077 might be controlling Octave and handling user input. The current\n\ |
1078 command number is not incremented when this function is called. This is\n\ | |
1079 a feature, not a bug.\n\ | |
3333 | 1080 @end deftypefn") |
2234 | 1081 { |
2281 | 1082 octave_value retval; |
2234 | 1083 |
1084 int nargin = args.length (); | |
1085 | |
1086 if (nargin == 1) | |
1087 { | |
3523 | 1088 std::string hint = args(0).string_value (); |
2234 | 1089 |
1090 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1091 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1092 int n = 32; |
2234 | 1093 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1094 string_vector list (n); |
2234 | 1095 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1096 int k = 0; |
2234 | 1097 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1098 for (;;) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1099 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1100 std::string cmd = generate_completion (hint, k); |
2234 | 1101 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1102 if (! cmd.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1103 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1104 if (k == n) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1105 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1106 n *= 2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1107 list.resize (n); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1108 } |
2235 | 1109 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1110 list[k++] = cmd; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1111 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1112 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1113 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1114 list.resize (k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1115 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1116 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1117 } |
2234 | 1118 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1119 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1120 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1121 if (! list.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1122 retval = list; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1123 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1124 retval = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1125 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1126 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1127 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1128 // We don't use string_vector::list_in_columns here |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1129 // because it will be easier for Emacs if the names |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1130 // appear in a single column. |
2235 | 1131 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1132 int len = list.length (); |
2234 | 1133 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1134 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1135 octave_stdout << list[i] << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1136 } |
2299 | 1137 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1138 octave_completion_matches_called = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1139 } |
2234 | 1140 } |
1141 else | |
5823 | 1142 print_usage (); |
2234 | 1143 |
1144 return retval; | |
1145 } | |
1146 | |
3189 | 1147 DEFUN (read_readline_init_file, args, , |
3448 | 1148 "-*- texinfo -*-\n\ |
1149 @deftypefn {Built-in Function} {} read_readline_init_file (@var{file})\n\ | |
7007 | 1150 Read the readline library initialization file @var{file}. If\n\ |
3448 | 1151 @var{file} is omitted, read the default initialization file (normally\n\ |
6615 | 1152 @file{~/.inputrc}).\n\ |
1153 \n\ | |
1154 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ | |
1155 for details.\n\ | |
3448 | 1156 @end deftypefn") |
3189 | 1157 { |
1158 octave_value_list retval; | |
1159 | |
1160 int nargin = args.length (); | |
1161 | |
1162 if (nargin == 0) | |
1163 command_editor::read_init_file (); | |
1164 else if (nargin == 1) | |
1165 { | |
5872 | 1166 std::string file = args(0).string_value (); |
3189 | 1167 |
1168 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1169 command_editor::read_init_file (file); |
3189 | 1170 } |
1171 else | |
5823 | 1172 print_usage (); |
3189 | 1173 |
1174 return retval; | |
1175 } | |
1176 | |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1177 DEFUN (re_read_readline_init_file, args, , |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1178 "-*- texinfo -*-\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1179 @deftypefn {Built-in Function} {} re_read_readline_init_file ()\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1180 Re-read the last readline library initialization file that was read.\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1181 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1182 for details.\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1183 @end deftypefn") |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1184 { |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1185 octave_value_list retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1186 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1187 if (args.length () == 0) |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1188 command_editor::re_read_init_file (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1189 else |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1190 print_usage (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1191 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1192 return retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1193 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1194 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1195 typedef std::map<std::string, octave_value> hook_fcn_map_type; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1196 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1197 static hook_fcn_map_type hook_fcn_map; |
3498 | 1198 |
4802 | 1199 static int |
3519 | 1200 input_event_hook (void) |
3498 | 1201 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1202 if (! curr_lexer->defining_func) |
4526 | 1203 { |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1204 hook_fcn_map_type::iterator p = hook_fcn_map.begin (); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1205 |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1206 while (p != hook_fcn_map.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1207 { |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1208 std::string hook_fcn = p->first; |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1209 octave_value user_data = p->second; |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1210 |
12179
0947d399cff4
input.cc (input_event_hook): fix incorrect use of iterator
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1211 hook_fcn_map_type::iterator q = p++; |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1212 |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1213 if (is_valid_function (hook_fcn)) |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1214 { |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1215 if (user_data.is_defined ()) |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1216 feval (hook_fcn, user_data, 0); |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1217 else |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1218 feval (hook_fcn, octave_value_list (), 0); |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1219 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1220 else |
12179
0947d399cff4
input.cc (input_event_hook): fix incorrect use of iterator
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1221 hook_fcn_map.erase (q); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1222 } |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1223 |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1224 if (hook_fcn_map.empty ()) |
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1225 command_editor::remove_event_hook (input_event_hook); |
4526 | 1226 } |
1227 | |
4802 | 1228 return 0; |
3498 | 1229 } |
1230 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1231 DEFUN (add_input_event_hook, args, , |
3498 | 1232 "-*- texinfo -*-\n\ |
12573
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1233 @deftypefn {Built-in Function} {} add_input_event_hook (@var{fcn})\n\ |
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1234 @deftypefnx {Built-in Function} {} add_input_event_hook (@var{fcn}, @var{data})\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1235 Add the named function @var{fcn} to the list of functions to call\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1236 periodically when Octave is waiting for input. The function should\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1237 have the form\n\ |
10840 | 1238 \n\ |
3498 | 1239 @example\n\ |
1240 @var{fcn} (@var{data})\n\ | |
1241 @end example\n\ | |
1242 \n\ | |
1243 If @var{data} is omitted, Octave calls the function without any\n\ | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1244 arguments.\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1245 @seealso{remove_input_event_hook}\n\ |
3498 | 1246 @end deftypefn") |
1247 { | |
1248 octave_value_list retval; | |
1249 | |
1250 int nargin = args.length (); | |
1251 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1252 if (nargin == 1 || nargin == 2) |
3498 | 1253 { |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1254 octave_value user_data; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1255 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1256 if (nargin == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1257 user_data = args(1); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1258 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1259 std::string hook_fcn = args(0).string_value (); |
3498 | 1260 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1261 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1262 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1263 if (hook_fcn_map.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1264 command_editor::add_event_hook (input_event_hook); |
3498 | 1265 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1266 hook_fcn_map[hook_fcn] = user_data; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1267 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1268 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1269 error ("add_input_event_hook: expecting string as first arg"); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1270 } |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1271 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1272 print_usage (); |
3498 | 1273 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1274 return retval; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1275 } |
3498 | 1276 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1277 DEFUN (remove_input_event_hook, args, , |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1278 "-*- texinfo -*-\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1279 @deftypefn {Built-in Function} {} remove_input_event_hook (@var{fcn})\n\ |
12573
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1280 Remove the named function @var{fcn} from the list of functions to call\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1281 periodically when Octave is waiting for input.\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1282 @seealso{add_input_event_hook}\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1283 @end deftypefn") |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1284 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1285 octave_value_list retval; |
3498 | 1286 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1287 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
|
1288 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1289 if (nargin == 1) |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1290 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1291 std::string hook_fcn = args(0).string_value (); |
3498 | 1292 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1293 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1294 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1295 hook_fcn_map_type::iterator p = hook_fcn_map.find (hook_fcn); |
3498 | 1296 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1297 if (p != hook_fcn_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1298 hook_fcn_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1299 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1300 error ("remove_input_event_hook: %s not found in list", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1301 hook_fcn.c_str ()); |
3498 | 1302 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1303 if (hook_fcn_map.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1304 command_editor::remove_event_hook (input_event_hook); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1305 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1306 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1307 error ("remove_input_event_hook: expecting string as first arg"); |
3498 | 1308 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1309 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1310 print_usage (); |
3498 | 1311 |
1312 return retval; | |
1313 } | |
1314 | |
5794 | 1315 DEFUN (PS1, args, nargout, |
1316 "-*- texinfo -*-\n\ | |
10840 | 1317 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ |
5794 | 1318 @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1319 @deftypefnx {Built-in Function} {} PS1 (@var{new_val}, \"local\")\n\ |
5794 | 1320 Query or set the primary prompt string. When executing interactively,\n\ |
1321 Octave displays the primary prompt when it is ready to read a command.\n\ | |
3332 | 1322 \n\ |
5794 | 1323 The default value of the primary prompt string is @code{\"\\s:\\#> \"}.\n\ |
1324 To change it, use a command like\n\ | |
3332 | 1325 \n\ |
1326 @example\n\ | |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1327 PS1 (\"\\\\u@@\\\\H> \")\n\ |
3332 | 1328 @end example\n\ |
1329 \n\ | |
1330 @noindent\n\ | |
1331 which will result in the prompt @samp{boris@@kremvax> } for the user\n\ | |
1332 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ | |
5794 | 1333 backslashes are required to enter a backslash into a double-quoted\n\ |
11413
ae0deb52af27
Correct use of xref macro to prevent Texinfo warning.
Rik <octave@nomad.inbox5.com>
parents:
11405
diff
changeset
|
1334 character string. @xref{Strings}.\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1335 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1336 You can also use ANSI escape sequences if your terminal supports them.\n\ |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11572
diff
changeset
|
1337 This can be useful for coloring the prompt. For example,\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1338 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1339 @example\n\ |
14880
9e5df4d6cefa
doc: typo on PS1 documentation example
Carnë Draug <carandraug+dev@gmail.com>
parents:
14138
diff
changeset
|
1340 PS1 (\"\\\\[\\\\033[01;31m\\\\]\\\\s:\\\\#> \\\\[\\\\033[0m\\\\]\")\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1341 @end example\n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1342 \n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
1343 @noindent\n\ |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11572
diff
changeset
|
1344 will give the default Octave prompt a red coloring.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1345 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1346 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1347 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1348 variable value is restored when exiting the function.\n\ |
6373 | 1349 @seealso{PS2, PS4}\n\ |
5794 | 1350 @end deftypefn") |
1351 { | |
1352 return SET_INTERNAL_VARIABLE (PS1); | |
1353 } | |
2181 | 1354 |
5794 | 1355 DEFUN (PS2, args, nargout, |
1356 "-*- texinfo -*-\n\ | |
10840 | 1357 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ |
5794 | 1358 @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1359 @deftypefnx {Built-in Function} {} PS2 (@var{new_val}, \"local\")\n\ |
5794 | 1360 Query or set the secondary prompt string. The secondary prompt is\n\ |
1361 printed when Octave is expecting additional input to complete a\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1362 command. For example, if you are typing a @code{for} loop that spans several\n\ |
5794 | 1363 lines, Octave will print the secondary prompt at the beginning of\n\ |
1364 each line after the first. The default value of the secondary prompt\n\ | |
1365 string is @code{\"> \"}.\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1366 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1367 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1368 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1369 variable value is restored when exiting the function.\n\ |
5794 | 1370 @seealso{PS1, PS4}\n\ |
1371 @end deftypefn") | |
1372 { | |
1373 return SET_INTERNAL_VARIABLE (PS2); | |
1374 } | |
2181 | 1375 |
5794 | 1376 DEFUN (PS4, args, nargout, |
1377 "-*- texinfo -*-\n\ | |
10840 | 1378 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ |
5794 | 1379 @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1380 @deftypefnx {Built-in Function} {} PS4 (@var{new_val}, \"local\")\n\ |
5794 | 1381 Query or set the character string used to prefix output produced\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1382 when echoing commands is enabled.\n\ |
6620 | 1383 The default value is @code{\"+ \"}.\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1384 @xref{Diary and Echo Commands}, for a description of echoing commands.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1385 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1386 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1387 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1388 variable value is restored when exiting the function.\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1389 @seealso{echo, echo_executing_commands, PS1, PS2}\n\ |
5794 | 1390 @end deftypefn") |
1391 { | |
1392 return SET_INTERNAL_VARIABLE (PS4); | |
1393 } | |
2181 | 1394 |
5794 | 1395 DEFUN (completion_append_char, args, nargout, |
1396 "-*- texinfo -*-\n\ | |
10840 | 1397 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ |
5794 | 1398 @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1399 @deftypefnx {Built-in Function} {} completion_append_char (@var{new_val}, \"local\")\n\ |
5794 | 1400 Query or set the internal character variable that is appended to\n\ |
1401 successful command-line completion attempts. The default\n\ | |
3332 | 1402 value is @code{\" \"} (a single space).\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1403 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1404 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1405 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1406 variable value is restored when exiting the function.\n\ |
5794 | 1407 @end deftypefn") |
1408 { | |
1409 return SET_INTERNAL_VARIABLE (completion_append_char); | |
1410 } | |
3019 | 1411 |
5794 | 1412 DEFUN (echo_executing_commands, args, nargout, |
1413 "-*- texinfo -*-\n\ | |
10840 | 1414 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ |
5794 | 1415 @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1416 @deftypefnx {Built-in Function} {} echo_executing_commands (@var{new_val}, \"local\")\n\ |
5794 | 1417 Query or set the internal variable that controls the echo state.\n\ |
1418 It may be the sum of the following values:\n\ | |
3332 | 1419 \n\ |
1420 @table @asis\n\ | |
1421 @item 1\n\ | |
1422 Echo commands read from script files.\n\ | |
1423 \n\ | |
1424 @item 2\n\ | |
1425 Echo commands from functions.\n\ | |
1426 \n\ | |
1427 @item 4\n\ | |
1428 Echo commands read from command line.\n\ | |
1429 @end table\n\ | |
1430 \n\ | |
1431 More than one state can be active at once. For example, a value of 3 is\n\ | |
1432 equivalent to the command @kbd{echo on all}.\n\ | |
1433 \n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1434 The value of @code{echo_executing_commands} may be set by the @kbd{echo}\n\ |
10840 | 1435 command or the command line option @option{--echo-commands}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1436 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1437 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1438 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1439 variable value is restored when exiting the function.\n\ |
5794 | 1440 @end deftypefn") |
1441 { | |
1442 return SET_INTERNAL_VARIABLE (echo_executing_commands); | |
2181 | 1443 } |
1444 | |
6257 | 1445 DEFUN (__request_drawnow__, args, , |
1446 "-*- texinfo -*-\n\ | |
10840 | 1447 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ |
6257 | 1448 @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ |
6945 | 1449 Undocumented internal function.\n\ |
6257 | 1450 @end deftypefn") |
1451 { | |
1452 octave_value retval; | |
1453 | |
1454 int nargin = args.length (); | |
1455 | |
1456 if (nargin == 0) | |
1457 Vdrawnow_requested = true; | |
1458 else if (nargin == 1) | |
1459 Vdrawnow_requested = args(0).bool_value (); | |
1460 else | |
1461 print_usage (); | |
1462 | |
1463 return retval; | |
1464 } | |
1465 | |
7294 | 1466 DEFUN (__gud_mode__, args, , |
1467 "-*- texinfo -*-\n\ | |
1468 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ | |
1469 Undocumented internal function.\n\ | |
1470 @end deftypefn") | |
1471 { | |
1472 octave_value retval; | |
1473 | |
1474 int nargin = args.length (); | |
1475 | |
1476 if (nargin == 0) | |
1477 retval = Vgud_mode; | |
1478 else if (nargin == 1) | |
1479 Vgud_mode = args(0).bool_value (); | |
1480 else | |
1481 print_usage (); | |
1482 | |
1483 return retval; | |
1484 } | |
1485 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1486 DEFUN (filemarker, args, nargout, |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1487 "-*- texinfo -*-\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12179
diff
changeset
|
1488 @deftypefn {Built-in Function} {@var{val} =} filemarker ()\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12179
diff
changeset
|
1489 @deftypefnx {Built-in Function} {} filemarker (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1490 @deftypefnx {Built-in Function} {} filemarker (@var{new_val}, \"local\")\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
1491 Query or set the character used to separate filename from the\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
1492 the subfunction names contained within the file. This can be used in\n\ |
10840 | 1493 a generic manner to interact with subfunctions. For example,\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1494 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1495 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1496 help ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1497 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1498 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1499 @noindent\n\ |
14852
53d2c3598d33
doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1500 returns the help string associated with the subfunction @code{mysubfunc}\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
1501 of the function @code{myfunc}. Another use of @code{filemarker} is when\n\ |
14852
53d2c3598d33
doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1502 debugging it allows easier placement of breakpoints within subfunctions.\n\ |
10840 | 1503 For example,\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1504 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1505 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1506 dbstop ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1507 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1508 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1509 @noindent\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1510 will set a breakpoint at the first line of the subfunction @code{mysubfunc}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1511 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1512 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1513 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1514 variable value is restored when exiting the function.\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1515 @end deftypefn") |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1516 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1517 char tmp = Vfilemarker; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1518 octave_value retval = SET_INTERNAL_VARIABLE (filemarker); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1519 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1520 // The character passed must not be a legal character for a function name |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1521 if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_')) |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1522 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1523 Vfilemarker = tmp; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1524 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
|
1525 } |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1526 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1527 return retval; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1528 } |