1
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
|
4 2002, 2003, 2004, 2005, 2006, 2007 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
1
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
1
|
21 |
|
22 */ |
|
23 |
2939
|
24 // Get command input interactively or from files. |
1
|
25 |
240
|
26 #ifdef HAVE_CONFIG_H |
1192
|
27 #include <config.h> |
1
|
28 #endif |
|
29 |
1343
|
30 #include <cstdio> |
|
31 #include <cstdlib> |
|
32 #include <cstring> |
|
33 #include <cassert> |
|
34 |
3503
|
35 #include <iostream> |
5765
|
36 #include <sstream> |
1728
|
37 #include <string> |
|
38 |
1350
|
39 #ifdef HAVE_UNISTD_H |
2442
|
40 #ifdef HAVE_SYS_TYPES_H |
529
|
41 #include <sys/types.h> |
2442
|
42 #endif |
529
|
43 #include <unistd.h> |
|
44 #endif |
1343
|
45 |
2927
|
46 #include "cmd-edit.h" |
3189
|
47 #include "file-ops.h" |
4153
|
48 #include "quit.h" |
1755
|
49 #include "str-vec.h" |
|
50 |
1352
|
51 #include "defun.h" |
|
52 #include "dirfns.h" |
1
|
53 #include "error.h" |
2181
|
54 #include "gripes.h" |
3016
|
55 #include "help.h" |
1
|
56 #include "input.h" |
5832
|
57 #include "load-path.h" |
1352
|
58 #include "oct-map.h" |
1742
|
59 #include "oct-hist.h" |
1670
|
60 #include "toplev.h" |
1755
|
61 #include "oct-obj.h" |
1
|
62 #include "pager.h" |
529
|
63 #include "parse.h" |
1352
|
64 #include "pathlen.h" |
3772
|
65 #include "pt.h" |
1755
|
66 #include "pt-const.h" |
3805
|
67 #include "pt-stmt.h" |
1352
|
68 #include "sighandlers.h" |
|
69 #include "symtab.h" |
1114
|
70 #include "sysdep.h" |
3098
|
71 #include "unwind-prot.h" |
1352
|
72 #include "utils.h" |
|
73 #include "variables.h" |
529
|
74 |
2181
|
75 // Primary prompt string. |
5794
|
76 static std::string VPS1 = "\\s:\\#> "; |
2181
|
77 |
|
78 // Secondary prompt string. |
5794
|
79 static std::string VPS2 = "> "; |
2181
|
80 |
|
81 // String printed before echoed input (enabled by --echo-input). |
5794
|
82 std::string VPS4 = "+ "; |
2181
|
83 |
3019
|
84 // Echo commands as they are executed? |
|
85 // |
|
86 // 1 ==> echo commands read from script files |
|
87 // 2 ==> echo commands from functions |
|
88 // 4 ==> echo commands read from command line |
|
89 // |
|
90 // more than one state can be active at once. |
5794
|
91 int Vecho_executing_commands = ECHO_OFF; |
3019
|
92 |
3165
|
93 // The time we last printed a prompt. |
5832
|
94 octave_time Vlast_prompt_time = 0.0; |
3165
|
95 |
2181
|
96 // Character to append after successful command-line completion attempts. |
5794
|
97 static char Vcompletion_append_char = ' '; |
2181
|
98 |
1
|
99 // Global pointer for eval(). |
3523
|
100 std::string current_eval_string; |
1
|
101 |
3019
|
102 // TRUE means get input from current_eval_string. |
|
103 bool get_input_from_eval_string = false; |
1
|
104 |
3877
|
105 // TRUE means we haven't been asked for the input from |
|
106 // current_eval_string yet. |
|
107 bool input_from_eval_string_pending = false; |
|
108 |
5189
|
109 // TRUE means that input is coming from a file that was named on |
|
110 // the command line. |
|
111 bool input_from_command_line_file = false; |
|
112 |
3019
|
113 // TRUE means we're parsing a function file. |
|
114 bool reading_fcn_file = false; |
1
|
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. |
|
145 static bool Vdrawnow_requested = false; |
|
146 |
7294
|
147 // TRUE if we are running in the Emacs GUD mode. |
|
148 static bool Vgud_mode = false; |
|
149 |
1044
|
150 static void |
3523
|
151 do_input_echo (const std::string& input_string) |
1044
|
152 { |
1588
|
153 int do_echo = reading_script_file ? |
2205
|
154 (Vecho_executing_commands & ECHO_SCRIPTS) |
2618
|
155 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; |
1588
|
156 |
|
157 if (do_echo) |
1044
|
158 { |
1403
|
159 if (forced_interactive) |
|
160 { |
1755
|
161 if (promptflag > 0) |
5794
|
162 octave_stdout << command_editor::decode_prompt_string (VPS1); |
1755
|
163 else |
5794
|
164 octave_stdout << command_editor::decode_prompt_string (VPS2); |
1403
|
165 } |
|
166 else |
5794
|
167 octave_stdout << command_editor::decode_prompt_string (VPS4); |
1044
|
168 |
1755
|
169 if (! input_string.empty ()) |
1044
|
170 { |
2095
|
171 octave_stdout << input_string; |
1755
|
172 |
|
173 if (input_string[input_string.length () - 1] != '\n') |
2095
|
174 octave_stdout << "\n"; |
1044
|
175 } |
|
176 } |
|
177 } |
|
178 |
3536
|
179 std::string |
3523
|
180 gnu_readline (const std::string& s, bool force_readline) |
1822
|
181 { |
5142
|
182 OCTAVE_QUIT; |
|
183 |
3523
|
184 std::string retval; |
1822
|
185 |
2927
|
186 if (line_editing || force_readline) |
1822
|
187 { |
3219
|
188 bool eof; |
1898
|
189 |
3219
|
190 retval = command_editor::readline (s, eof); |
|
191 |
|
192 if (! eof && retval.empty ()) |
2927
|
193 retval = "\n"; |
1822
|
194 } |
|
195 else |
|
196 { |
2927
|
197 if (! s.empty () && (interactive || forced_interactive)) |
2618
|
198 { |
2927
|
199 FILE *stream = command_editor::get_output_stream (); |
|
200 |
|
201 fprintf (stream, s.c_str ()); |
|
202 fflush (stream); |
2618
|
203 } |
1822
|
204 |
2927
|
205 FILE *curr_stream = command_editor::get_input_stream (); |
|
206 |
1822
|
207 if (reading_fcn_file || reading_script_file) |
|
208 curr_stream = ff_instream; |
|
209 |
2927
|
210 retval = octave_fgets (curr_stream); |
1822
|
211 } |
|
212 |
|
213 return retval; |
|
214 } |
581
|
215 |
6257
|
216 static inline std::string |
6317
|
217 interactive_input (const std::string& s, bool debug = false, |
|
218 bool force_readline = false) |
6257
|
219 { |
|
220 Vlast_prompt_time.stamp (); |
|
221 |
6317
|
222 if (! debug |
|
223 && (Vdrawnow_requested && (interactive || forced_interactive))) |
6257
|
224 { |
|
225 feval ("drawnow"); |
|
226 |
6367
|
227 flush_octave_stdout (); |
|
228 |
6305
|
229 // We set Vdrawnow_requested to false even if there is an error |
|
230 // in drawnow so that the error doesn't reappear at every prompt. |
|
231 |
6257
|
232 Vdrawnow_requested = false; |
6305
|
233 |
|
234 if (error_state) |
|
235 return "\n"; |
6257
|
236 } |
|
237 |
|
238 return gnu_readline (s, force_readline); |
|
239 } |
|
240 |
3536
|
241 static std::string |
1
|
242 octave_gets (void) |
|
243 { |
5142
|
244 OCTAVE_QUIT; |
|
245 |
3523
|
246 std::string retval; |
1
|
247 |
1822
|
248 if ((interactive || forced_interactive) |
5832
|
249 && (! (reading_fcn_file |
|
250 || reading_script_file |
|
251 || input_from_startup_file |
|
252 || input_from_command_line_file))) |
1
|
253 { |
5794
|
254 std::string ps = (promptflag > 0) ? VPS1 : VPS2; |
1755
|
255 |
3523
|
256 std::string prompt = command_editor::decode_prompt_string (ps); |
1
|
257 |
2618
|
258 pipe_handler_error_count = 0; |
|
259 |
|
260 flush_octave_stdout (); |
1
|
261 |
2095
|
262 octave_diary << prompt; |
581
|
263 |
6257
|
264 retval = interactive_input (prompt); |
5832
|
265 |
|
266 // There is no need to update the load_path cache if there is no |
|
267 // user input. |
|
268 if (! retval.empty ()) |
|
269 load_path::update (); |
1
|
270 } |
|
271 else |
1822
|
272 retval = gnu_readline (""); |
1
|
273 |
2927
|
274 current_input_line = retval; |
1
|
275 |
1822
|
276 if (! current_input_line.empty ()) |
1
|
277 { |
5189
|
278 if (! (input_from_startup_file || input_from_command_line_file)) |
2927
|
279 command_history::add (current_input_line); |
1
|
280 |
3176
|
281 if (! (reading_fcn_file || reading_script_file)) |
|
282 { |
|
283 octave_diary << current_input_line; |
|
284 |
|
285 if (current_input_line[current_input_line.length () - 1] != '\n') |
|
286 octave_diary << "\n"; |
|
287 } |
581
|
288 |
1822
|
289 do_input_echo (current_input_line); |
1
|
290 } |
3176
|
291 else if (! (reading_fcn_file || reading_script_file)) |
|
292 octave_diary << "\n"; |
581
|
293 |
1822
|
294 return retval; |
1
|
295 } |
|
296 |
581
|
297 // Read a line from the input stream. |
|
298 |
3536
|
299 static std::string |
1822
|
300 get_user_input (void) |
1
|
301 { |
5142
|
302 OCTAVE_QUIT; |
|
303 |
3523
|
304 std::string retval; |
1
|
305 |
|
306 if (get_input_from_eval_string) |
|
307 { |
3877
|
308 if (input_from_eval_string_pending) |
|
309 { |
|
310 input_from_eval_string_pending = false; |
|
311 |
|
312 retval = current_eval_string; |
1822
|
313 |
3877
|
314 size_t len = retval.length (); |
1822
|
315 |
6206
|
316 if (len > 0 && retval[len-1] != '\n') |
3877
|
317 retval.append ("\n"); |
|
318 } |
1822
|
319 } |
|
320 else |
|
321 retval = octave_gets (); |
|
322 |
2927
|
323 current_input_line = retval; |
1822
|
324 |
2114
|
325 if (! get_input_from_eval_string) |
|
326 input_line_number++; |
1822
|
327 |
|
328 return retval; |
|
329 } |
|
330 |
|
331 int |
|
332 octave_read (char *buf, unsigned max_size) |
|
333 { |
5775
|
334 // FIXME -- is this a safe way to buffer the input? |
2927
|
335 |
4046
|
336 static const char * const eol = "\n"; |
3523
|
337 static std::string input_buf; |
2927
|
338 static const char *pos = 0; |
|
339 static size_t chars_left = 0; |
1822
|
340 |
|
341 int status = 0; |
4046
|
342 if (chars_left == 0) |
1822
|
343 { |
2927
|
344 pos = 0; |
|
345 |
|
346 input_buf = get_user_input (); |
1822
|
347 |
2927
|
348 chars_left = input_buf.length (); |
|
349 |
|
350 pos = input_buf.c_str (); |
1822
|
351 } |
|
352 |
|
353 if (chars_left > 0) |
|
354 { |
4046
|
355 size_t len = max_size > chars_left ? chars_left : max_size; |
2927
|
356 assert (len > 0); |
|
357 |
4046
|
358 memcpy (buf, pos, len); |
1822
|
359 |
4046
|
360 chars_left -= len; |
|
361 pos += len; |
1822
|
362 |
4046
|
363 // Make sure input ends with a new line character. |
|
364 if (chars_left == 0 && buf[len-1] != '\n') |
|
365 { |
|
366 if (len < max_size) |
|
367 { |
|
368 // There is enough room to plug the newline character in |
|
369 // the buffer. |
|
370 buf[len++] = '\n'; |
|
371 } |
|
372 else |
|
373 { |
|
374 // There isn't enough room to plug the newline character |
|
375 // in the buffer so make sure it is returned on the next |
|
376 // octave_read call. |
|
377 pos = eol; |
|
378 chars_left = 1; |
|
379 } |
1
|
380 } |
1822
|
381 |
4046
|
382 status = len; |
1
|
383 |
1044
|
384 } |
1822
|
385 else if (chars_left == 0) |
2862
|
386 { |
|
387 status = 0; |
|
388 } |
1822
|
389 else |
|
390 status = -1; |
1044
|
391 |
1
|
392 return status; |
|
393 } |
|
394 |
581
|
395 // Fix things up so that input can come from file `name', printing a |
|
396 // warning if the file doesn't exist. |
|
397 |
1
|
398 FILE * |
3523
|
399 get_input_from_file (const std::string& name, int warn) |
1
|
400 { |
529
|
401 FILE *instream = 0; |
1
|
402 |
1750
|
403 if (name.length () > 0) |
|
404 instream = fopen (name.c_str (), "r"); |
1
|
405 |
529
|
406 if (! instream && warn) |
1750
|
407 warning ("%s: no such file or directory", name.c_str ()); |
1
|
408 |
338
|
409 if (reading_fcn_file || reading_script_file) |
339
|
410 ff_instream = instream; |
1
|
411 else |
2927
|
412 command_editor::set_input_stream (instream); |
1
|
413 |
|
414 return instream; |
|
415 } |
|
416 |
581
|
417 // Fix things up so that input can come from the standard input. This |
|
418 // may need to become much more complicated, which is why it's in a |
|
419 // separate function. |
|
420 |
1
|
421 FILE * |
|
422 get_input_from_stdin (void) |
|
423 { |
2927
|
424 command_editor::set_input_stream (stdin); |
|
425 return command_editor::get_input_stream (); |
1
|
426 } |
|
427 |
5775
|
428 // FIXME -- make this generate file names when appropriate. |
2921
|
429 |
2247
|
430 static string_vector |
3523
|
431 generate_possible_completions (const std::string& text, std::string& prefix, |
|
432 std::string& hint) |
1280
|
433 { |
2247
|
434 string_vector names; |
1280
|
435 |
2921
|
436 prefix = ""; |
1280
|
437 |
4604
|
438 if (looks_like_struct (text)) |
1430
|
439 names = generate_struct_completions (text, prefix, hint); |
|
440 else |
2247
|
441 names = make_name_list (); |
1280
|
442 |
2944
|
443 // Sort and remove duplicates. |
2348
|
444 |
2944
|
445 names.qsort (true); |
2348
|
446 |
1280
|
447 return names; |
|
448 } |
|
449 |
3536
|
450 static std::string |
3523
|
451 generate_completion (const std::string& text, int state) |
1280
|
452 { |
3523
|
453 std::string retval; |
2944
|
454 |
3523
|
455 static std::string prefix; |
|
456 static std::string hint; |
1280
|
457 |
2921
|
458 static size_t hint_len = 0; |
1280
|
459 |
1
|
460 static int list_index = 0; |
2921
|
461 static int name_list_len = 0; |
4604
|
462 static int name_list_total_len = 0; |
2247
|
463 static string_vector name_list; |
4604
|
464 static string_vector file_name_list; |
1
|
465 |
1280
|
466 static int matches = 0; |
1
|
467 |
|
468 if (state == 0) |
|
469 { |
|
470 list_index = 0; |
|
471 |
2921
|
472 prefix = ""; |
1280
|
473 |
2921
|
474 hint = text; |
1280
|
475 |
|
476 name_list = generate_possible_completions (text, prefix, hint); |
|
477 |
2921
|
478 name_list_len = name_list.length (); |
|
479 |
4604
|
480 file_name_list = command_editor::generate_filename_completions (text); |
|
481 |
|
482 name_list.append (file_name_list); |
|
483 |
|
484 name_list_total_len = name_list.length (); |
|
485 |
2921
|
486 hint_len = hint.length (); |
1280
|
487 |
|
488 matches = 0; |
2247
|
489 |
2921
|
490 for (int i = 0; i < name_list_len; i++) |
3565
|
491 if (hint == name_list[i].substr (0, hint_len)) |
2247
|
492 matches++; |
1
|
493 } |
|
494 |
4604
|
495 if (name_list_total_len > 0 && matches > 0) |
1
|
496 { |
4604
|
497 while (list_index < name_list_total_len) |
244
|
498 { |
3523
|
499 std::string name = name_list[list_index]; |
2247
|
500 |
1280
|
501 list_index++; |
2247
|
502 |
3565
|
503 if (hint == name.substr (0, hint_len)) |
1280
|
504 { |
4604
|
505 if (list_index <= name_list_len && ! prefix.empty ()) |
2944
|
506 retval = prefix + "." + name; |
|
507 else |
|
508 retval = name; |
1280
|
509 |
5775
|
510 // FIXME -- looks_like_struct is broken for now, |
4179
|
511 // so it always returns false. |
|
512 |
6979
|
513 if (matches == 1 && looks_like_struct (retval)) |
4179
|
514 { |
|
515 // Don't append anything, since we don't know |
|
516 // whether it should be '(' or '.'. |
|
517 |
|
518 command_editor::set_completion_append_character ('\0'); |
|
519 } |
|
520 else |
|
521 command_editor::set_completion_append_character |
|
522 (Vcompletion_append_char); |
1280
|
523 |
2944
|
524 break; |
1280
|
525 } |
244
|
526 } |
1
|
527 } |
|
528 |
2944
|
529 return retval; |
1
|
530 } |
|
531 |
6979
|
532 static std::string |
|
533 quoting_filename (const std::string &text, int, char quote) |
|
534 { |
|
535 if (quote) |
|
536 return text; |
|
537 else |
|
538 return (std::string ("'") + text); |
|
539 } |
|
540 |
2927
|
541 void |
|
542 initialize_command_input (void) |
|
543 { |
|
544 // If we are using readline, this allows conditional parsing of the |
|
545 // .inputrc file. |
269
|
546 |
2927
|
547 command_editor::set_name ("Octave"); |
1358
|
548 |
5775
|
549 // FIXME -- this needs to include a comma too, but that |
3933
|
550 // causes trouble for the new struct element completion code. |
|
551 |
4272
|
552 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
3933
|
553 |
|
554 command_editor::set_basic_word_break_characters (s); |
|
555 |
|
556 command_editor::set_completer_word_break_characters (s); |
|
557 |
3004
|
558 command_editor::set_basic_quote_characters ("\""); |
2944
|
559 |
6979
|
560 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
|
561 command_editor::set_completer_quote_characters ("'\""); |
|
562 |
2944
|
563 command_editor::set_completion_function (generate_completion); |
6979
|
564 |
|
565 command_editor::set_quoting_function (quoting_filename); |
269
|
566 } |
|
567 |
2927
|
568 static bool |
4170
|
569 match_sans_spaces_semi (const std::string& standard, const std::string& test) |
269
|
570 { |
3180
|
571 size_t beg = test.find_first_not_of (" \t"); |
|
572 |
|
573 if (beg != NPOS) |
|
574 { |
4170
|
575 size_t end = test.find_last_not_of ("; \t"); |
269
|
576 |
3180
|
577 size_t len = end == NPOS ? NPOS : end - beg + 1; |
1
|
578 |
3484
|
579 return (test.substr (beg, len) == standard); |
3180
|
580 } |
|
581 |
|
582 return false; |
529
|
583 } |
|
584 |
581
|
585 // If the user simply hits return, this will produce an empty matrix. |
|
586 |
2086
|
587 static octave_value_list |
3100
|
588 get_user_input (const octave_value_list& args, bool debug, int nargout) |
529
|
589 { |
3100
|
590 octave_value_list retval; |
529
|
591 |
|
592 int nargin = args.length (); |
|
593 |
|
594 int read_as_string = 0; |
|
595 |
712
|
596 if (nargin == 2) |
529
|
597 read_as_string++; |
|
598 |
4975
|
599 std::string nm; |
|
600 int line = -1; |
|
601 |
5743
|
602 if (debug) |
4975
|
603 { |
5744
|
604 octave_function *caller |
|
605 = octave_call_stack::caller_user_script_or_function (); |
5743
|
606 |
|
607 if (caller) |
|
608 { |
|
609 nm = caller->fcn_file_name (); |
4975
|
610 |
5743
|
611 if (nm.empty ()) |
|
612 nm = caller->name (); |
4975
|
613 |
5743
|
614 if (curr_statement) |
|
615 line = curr_statement->line (); |
|
616 } |
4975
|
617 } |
|
618 |
5765
|
619 std::ostringstream buf; |
4975
|
620 |
|
621 if (! nm.empty ()) |
|
622 { |
7294
|
623 if (Vgud_mode) |
|
624 { |
|
625 static char ctrl_z = 'Z' & 0x1f; |
4975
|
626 |
7294
|
627 buf << ctrl_z << ctrl_z << nm << ":" << line; |
|
628 } |
|
629 else |
|
630 { |
|
631 buf << "stopped in " << nm; |
|
632 |
|
633 if (line > 0) |
|
634 buf << " at line " << line; |
|
635 } |
4975
|
636 } |
|
637 |
5765
|
638 std::string msg = buf.str (); |
4975
|
639 |
|
640 if (! msg.empty ()) |
7294
|
641 message (Vgud_mode ? 0 : "keyboard", msg.c_str ()); |
4975
|
642 |
|
643 std::string prompt = "debug> "; |
1761
|
644 |
712
|
645 if (nargin > 0) |
3707
|
646 { |
|
647 prompt = args(0).string_value (); |
636
|
648 |
3707
|
649 if (error_state) |
|
650 { |
|
651 error ("input: unrecognized argument"); |
|
652 return retval; |
|
653 } |
529
|
654 } |
|
655 |
|
656 again: |
|
657 |
2095
|
658 flush_octave_stdout (); |
529
|
659 |
4565
|
660 octave_diary << prompt; |
|
661 |
6317
|
662 std::string input_buf = interactive_input (prompt.c_str (), debug, true); |
529
|
663 |
2927
|
664 if (! input_buf.empty ()) |
529
|
665 { |
1799
|
666 if (! input_from_startup_file) |
2927
|
667 command_history::add (input_buf); |
529
|
668 |
2927
|
669 size_t len = input_buf.length (); |
529
|
670 |
4565
|
671 octave_diary << input_buf; |
|
672 |
|
673 if (input_buf[len - 1] != '\n') |
|
674 octave_diary << "\n"; |
|
675 |
529
|
676 if (len < 1) |
|
677 { |
|
678 if (debug) |
|
679 goto again; |
|
680 else |
4233
|
681 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
529
|
682 } |
|
683 |
3772
|
684 if (debug) |
|
685 { |
4170
|
686 if (match_sans_spaces_semi ("exit", input_buf) |
|
687 || match_sans_spaces_semi ("quit", input_buf) |
|
688 || match_sans_spaces_semi ("return", input_buf) |
5388
|
689 || match_sans_spaces_semi ("dbcont", input_buf)) |
3772
|
690 { |
|
691 return retval; |
|
692 } |
5388
|
693 else if (match_sans_spaces_semi ("dbstep", input_buf)) |
3772
|
694 { |
|
695 tree::break_next = true; |
3805
|
696 |
|
697 tree::last_line = 0; |
|
698 |
5743
|
699 tree::break_function = octave_call_stack::current (); |
3805
|
700 |
|
701 return retval; |
|
702 } |
5388
|
703 else if (match_sans_spaces_semi ("dbnext", input_buf)) |
3805
|
704 { |
|
705 tree::break_next = true; |
|
706 |
|
707 tree::last_line = curr_statement->line (); |
|
708 |
5743
|
709 tree::break_function = octave_call_stack::current (); |
3805
|
710 |
3772
|
711 return retval; |
|
712 } |
963
|
713 } |
3772
|
714 |
|
715 if (read_as_string) |
963
|
716 { |
5775
|
717 // FIXME -- fix gnu_readline and octave_gets instead! |
3081
|
718 if (input_buf.length () == 1 && input_buf[0] == '\n') |
3100
|
719 retval(0) = ""; |
3081
|
720 else |
3100
|
721 retval(0) = input_buf; |
963
|
722 } |
529
|
723 else |
|
724 { |
|
725 int parse_status = 0; |
2900
|
726 |
3100
|
727 bool silent = ! debug; |
2900
|
728 |
3100
|
729 retval = eval_string (input_buf, silent, parse_status, nargout); |
|
730 |
3215
|
731 if (! debug && retval.length () == 0) |
3100
|
732 retval(0) = Matrix (); |
529
|
733 } |
|
734 } |
|
735 else |
|
736 error ("input: reading user-input failed!"); |
|
737 |
|
738 if (debug) |
3098
|
739 { |
|
740 // Clear error_state so that if errors were encountered while |
|
741 // evaluating user input, extra error messages will not be |
|
742 // printed after we return. |
|
743 |
|
744 error_state = 0; |
|
745 |
3100
|
746 retval = octave_value_list (); |
3098
|
747 |
|
748 goto again; |
|
749 } |
529
|
750 |
|
751 return retval; |
|
752 } |
|
753 |
3100
|
754 DEFUN (input, args, nargout, |
3372
|
755 "-*- texinfo -*-\n\ |
|
756 @deftypefn {Built-in Function} {} input (@var{prompt})\n\ |
|
757 @deftypefnx {Built-in Function} {} input (@var{prompt}, \"s\")\n\ |
|
758 Print a prompt and wait for user input. For example,\n\ |
|
759 \n\ |
|
760 @example\n\ |
|
761 input (\"Pick a number, any number! \")\n\ |
|
762 @end example\n\ |
|
763 \n\ |
|
764 @noindent\n\ |
|
765 prints the prompt\n\ |
|
766 \n\ |
|
767 @example\n\ |
|
768 Pick a number, any number!\n\ |
|
769 @end example\n\ |
529
|
770 \n\ |
3372
|
771 @noindent\n\ |
|
772 and waits for the user to enter a value. The string entered by the user\n\ |
|
773 is evaluated as an expression, so it may be a literal constant, a\n\ |
|
774 variable name, or any other valid expression.\n\ |
|
775 \n\ |
|
776 Currently, @code{input} only returns one value, regardless of the number\n\ |
|
777 of values produced by the evaluation of the expression.\n\ |
|
778 \n\ |
|
779 If you are only interested in getting a literal string value, you can\n\ |
|
780 call @code{input} with the character string @code{\"s\"} as the second\n\ |
|
781 argument. This tells Octave to return the string entered by the user\n\ |
|
782 directly, without evaluating it first.\n\ |
|
783 \n\ |
|
784 Because there may be output waiting to be displayed by the pager, it is\n\ |
|
785 a good idea to always call @code{fflush (stdout)} before calling\n\ |
|
786 @code{input}. This will ensure that all pending output is written to\n\ |
|
787 the screen before your prompt. @xref{Input and Output}.\n\ |
|
788 @end deftypefn") |
529
|
789 { |
2086
|
790 octave_value_list retval; |
529
|
791 |
|
792 int nargin = args.length (); |
|
793 |
712
|
794 if (nargin == 1 || nargin == 2) |
3100
|
795 retval = get_user_input (args, false, nargout); |
529
|
796 else |
5823
|
797 print_usage (); |
529
|
798 |
|
799 return retval; |
|
800 } |
|
801 |
5640
|
802 bool |
|
803 octave_yes_or_no (const std::string& prompt) |
|
804 { |
|
805 std::string prompt_string = prompt + "(yes or no) "; |
|
806 |
|
807 while (1) |
|
808 { |
6489
|
809 std::string input_buf = interactive_input (prompt_string, false, true); |
5640
|
810 |
|
811 if (input_buf == "yes") |
|
812 return true; |
|
813 else if (input_buf == "no") |
|
814 return false; |
|
815 else |
|
816 message (0, "Please answer yes or no."); |
|
817 } |
|
818 } |
|
819 |
|
820 DEFUN (yes_or_no, args, , |
|
821 "-*- texinfo -*-\n\ |
|
822 @deftypefn {Built-in Function} {} yes_or_no (@var{prompt})\n\ |
|
823 Ask the user a yes-or-no question. Return 1 if the answer is yes.\n\ |
|
824 Takes one argument, which is the string to display to ask the\n\ |
|
825 question. It should end in a space; @samp{yes-or-no-p} adds\n\ |
|
826 @samp{(yes or no) } to it. The user must confirm the answer with\n\ |
|
827 RET and can edit it until it has been confirmed.\n\ |
|
828 @end deftypefn") |
|
829 { |
|
830 octave_value retval; |
|
831 |
|
832 int nargin = args.length (); |
|
833 |
|
834 if (nargin == 0 || nargin == 1) |
|
835 { |
|
836 std::string prompt; |
|
837 |
|
838 if (nargin == 1) |
|
839 { |
|
840 prompt = args(0).string_value (); |
|
841 |
|
842 if (error_state) |
|
843 { |
|
844 error ("yes_or_no: expecting argument to be character string"); |
|
845 return retval; |
|
846 } |
|
847 } |
|
848 |
|
849 retval = octave_yes_or_no (prompt); |
|
850 } |
|
851 else |
5823
|
852 print_usage (); |
5640
|
853 |
|
854 return retval; |
|
855 } |
|
856 |
3098
|
857 static void |
|
858 restore_command_history (void *) |
|
859 { |
|
860 command_history::ignore_entries (! Vsaving_history); |
|
861 } |
|
862 |
3707
|
863 octave_value |
|
864 do_keyboard (const octave_value_list& args) |
|
865 { |
|
866 octave_value retval; |
|
867 |
|
868 int nargin = args.length (); |
|
869 |
|
870 assert (nargin == 0 || nargin == 1); |
|
871 |
|
872 unwind_protect::begin_frame ("do_keyboard"); |
|
873 |
5775
|
874 // FIXME -- we shouldn't need both the |
3707
|
875 // command_history object and the |
|
876 // Vsaving_history variable... |
|
877 command_history::ignore_entries (false); |
|
878 |
|
879 unwind_protect::add (restore_command_history, 0); |
|
880 |
|
881 unwind_protect_bool (Vsaving_history); |
|
882 |
|
883 Vsaving_history = true; |
|
884 |
4233
|
885 octave_value_list tmp = get_user_input (args, true, 0); |
|
886 |
|
887 retval = tmp(0); |
3707
|
888 |
|
889 unwind_protect::run_frame ("do_keyboard"); |
|
890 |
|
891 return retval; |
|
892 } |
|
893 |
1957
|
894 DEFUN (keyboard, args, , |
3372
|
895 "-*- texinfo -*-\n\ |
|
896 @deftypefn {Built-in Function} {} keyboard (@var{prompt})\n\ |
|
897 This function is normally used for simple debugging. When the\n\ |
|
898 @code{keyboard} function is executed, Octave prints a prompt and waits\n\ |
|
899 for user input. The input strings are then evaluated and the results\n\ |
|
900 are printed. This makes it possible to examine the values of variables\n\ |
|
901 within a function, and to assign new values to variables. No value is\n\ |
|
902 returned from the @code{keyboard} function, and it continues to prompt\n\ |
|
903 for input until the user types @samp{quit}, or @samp{exit}.\n\ |
529
|
904 \n\ |
3372
|
905 If @code{keyboard} is invoked without any arguments, a default prompt of\n\ |
|
906 @samp{debug> } is used.\n\ |
|
907 @end deftypefn") |
529
|
908 { |
2086
|
909 octave_value_list retval; |
529
|
910 |
|
911 int nargin = args.length (); |
|
912 |
712
|
913 if (nargin == 0 || nargin == 1) |
3707
|
914 do_keyboard (args); |
529
|
915 else |
5823
|
916 print_usage (); |
529
|
917 |
|
918 return retval; |
|
919 } |
|
920 |
4208
|
921 DEFCMD (echo, args, , |
3332
|
922 "-*- texinfo -*-\n\ |
|
923 @deffn {Command} echo options\n\ |
|
924 Control whether commands are displayed as they are executed. Valid\n\ |
|
925 options are:\n\ |
1588
|
926 \n\ |
3332
|
927 @table @code\n\ |
|
928 @item on\n\ |
|
929 Enable echoing of commands as they are executed in script files.\n\ |
|
930 \n\ |
|
931 @item off\n\ |
|
932 Disable echoing of commands as they are executed in script files.\n\ |
1588
|
933 \n\ |
3332
|
934 @item on all\n\ |
|
935 Enable echoing of commands as they are executed in script files and\n\ |
|
936 functions.\n\ |
1588
|
937 \n\ |
3332
|
938 @item off all\n\ |
|
939 Disable echoing of commands as they are executed in script files and\n\ |
|
940 functions.\n\ |
|
941 @end table\n\ |
|
942 \n\ |
|
943 @noindent\n\ |
|
944 If invoked without any arguments, @code{echo} toggles the current echo\n\ |
|
945 state.\n\ |
3333
|
946 @end deffn") |
1588
|
947 { |
2086
|
948 octave_value_list retval; |
1588
|
949 |
1755
|
950 int argc = args.length () + 1; |
|
951 |
1968
|
952 string_vector argv = args.make_argv ("echo"); |
1755
|
953 |
|
954 if (error_state) |
|
955 return retval; |
1588
|
956 |
|
957 switch (argc) |
|
958 { |
|
959 case 1: |
|
960 { |
2205
|
961 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
|
962 || (Vecho_executing_commands & ECHO_FUNCTIONS)) |
5794
|
963 Vecho_executing_commands = ECHO_OFF; |
1588
|
964 else |
5794
|
965 Vecho_executing_commands = ECHO_SCRIPTS; |
1588
|
966 } |
|
967 break; |
|
968 |
|
969 case 2: |
|
970 { |
3523
|
971 std::string arg = argv[1]; |
1755
|
972 |
|
973 if (arg == "on") |
5794
|
974 Vecho_executing_commands = ECHO_SCRIPTS; |
1755
|
975 else if (arg == "off") |
5794
|
976 Vecho_executing_commands = ECHO_OFF; |
1588
|
977 else |
5823
|
978 print_usage (); |
1588
|
979 } |
|
980 break; |
|
981 |
|
982 case 3: |
|
983 { |
3523
|
984 std::string arg = argv[1]; |
1755
|
985 |
|
986 if (arg == "on" && argv[2] == "all") |
2800
|
987 { |
|
988 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); |
5794
|
989 Vecho_executing_commands = tmp; |
2800
|
990 } |
1755
|
991 else if (arg == "off" && argv[2] == "all") |
5794
|
992 Vecho_executing_commands = ECHO_OFF; |
1588
|
993 else |
5823
|
994 print_usage (); |
1588
|
995 } |
|
996 break; |
|
997 |
|
998 default: |
5823
|
999 print_usage (); |
1588
|
1000 break; |
|
1001 } |
|
1002 |
|
1003 return retval; |
|
1004 } |
|
1005 |
2234
|
1006 DEFUN (completion_matches, args, nargout, |
3332
|
1007 "-*- texinfo -*-\n\ |
|
1008 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ |
|
1009 Generate possible completions given @var{hint}.\n\ |
2299
|
1010 \n\ |
|
1011 This function is provided for the benefit of programs like Emacs which\n\ |
3332
|
1012 might be controlling Octave and handling user input. The current\n\ |
|
1013 command number is not incremented when this function is called. This is\n\ |
|
1014 a feature, not a bug.\n\ |
3333
|
1015 @end deftypefn") |
2234
|
1016 { |
2281
|
1017 octave_value retval; |
2234
|
1018 |
|
1019 int nargin = args.length (); |
|
1020 |
|
1021 if (nargin == 1) |
|
1022 { |
3523
|
1023 std::string hint = args(0).string_value (); |
2234
|
1024 |
|
1025 if (! error_state) |
|
1026 { |
|
1027 int n = 32; |
|
1028 |
|
1029 string_vector list (n); |
|
1030 |
|
1031 int k = 0; |
|
1032 |
|
1033 for (;;) |
|
1034 { |
3523
|
1035 std::string cmd = generate_completion (hint, k); |
2234
|
1036 |
2944
|
1037 if (! cmd.empty ()) |
2234
|
1038 { |
2944
|
1039 if (k == n) |
2234
|
1040 { |
2944
|
1041 n *= 2; |
|
1042 list.resize (n); |
|
1043 } |
2235
|
1044 |
2944
|
1045 list[k++] = cmd; |
2234
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 list.resize (k); |
|
1050 break; |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 if (nargout > 0) |
2281
|
1055 { |
|
1056 if (! list.empty ()) |
|
1057 retval = list; |
2282
|
1058 else |
|
1059 retval = ""; |
2281
|
1060 } |
2234
|
1061 else |
|
1062 { |
2235
|
1063 // We don't use string_vector::list_in_columns here |
|
1064 // because it will be easier for Emacs if the names |
|
1065 // appear in a single column. |
|
1066 |
2234
|
1067 int len = list.length (); |
|
1068 |
|
1069 for (int i = 0; i < len; i++) |
|
1070 octave_stdout << list[i] << "\n"; |
|
1071 } |
2299
|
1072 |
|
1073 octave_completion_matches_called = true; |
2234
|
1074 } |
|
1075 } |
|
1076 else |
5823
|
1077 print_usage (); |
2234
|
1078 |
|
1079 return retval; |
|
1080 } |
|
1081 |
3189
|
1082 DEFUN (read_readline_init_file, args, , |
3448
|
1083 "-*- texinfo -*-\n\ |
|
1084 @deftypefn {Built-in Function} {} read_readline_init_file (@var{file})\n\ |
7007
|
1085 Read the readline library initialization file @var{file}. If\n\ |
3448
|
1086 @var{file} is omitted, read the default initialization file (normally\n\ |
6615
|
1087 @file{~/.inputrc}).\n\ |
|
1088 \n\ |
|
1089 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ |
|
1090 for details.\n\ |
3448
|
1091 @end deftypefn") |
3189
|
1092 { |
|
1093 octave_value_list retval; |
|
1094 |
|
1095 int nargin = args.length (); |
|
1096 |
|
1097 if (nargin == 0) |
|
1098 command_editor::read_init_file (); |
|
1099 else if (nargin == 1) |
|
1100 { |
5872
|
1101 std::string file = args(0).string_value (); |
3189
|
1102 |
|
1103 if (! error_state) |
|
1104 command_editor::read_init_file (file); |
|
1105 } |
|
1106 else |
5823
|
1107 print_usage (); |
3189
|
1108 |
|
1109 return retval; |
|
1110 } |
|
1111 |
3523
|
1112 static std::string hook_fcn; |
3498
|
1113 static octave_value user_data; |
|
1114 |
4802
|
1115 static int |
3519
|
1116 input_event_hook (void) |
3498
|
1117 { |
4526
|
1118 if (is_valid_function (hook_fcn)) |
|
1119 { |
|
1120 if (user_data.is_defined ()) |
|
1121 feval (hook_fcn, user_data, 0); |
|
1122 else |
|
1123 feval (hook_fcn, octave_value_list (), 0); |
|
1124 } |
3498
|
1125 else |
4526
|
1126 { |
|
1127 hook_fcn = std::string (); |
|
1128 user_data = octave_value (); |
|
1129 |
6913
|
1130 command_editor::remove_event_hook (input_event_hook); |
4802
|
1131 } |
|
1132 |
|
1133 return 0; |
3498
|
1134 } |
|
1135 |
|
1136 DEFUN (input_event_hook, args, , |
|
1137 "-*- texinfo -*-\n\ |
|
1138 @deftypefn {Built-in Function} {[@var{ofcn}, @var{odata}] =} input_event_hook (@var{fcn}, @var{data})\n\ |
|
1139 Given the name of a function as a string and any Octave value object,\n\ |
|
1140 install @var{fcn} as a function to call periodically, when Octave is\n\ |
|
1141 waiting for input. The function should have the form\n\ |
|
1142 @example\n\ |
|
1143 @var{fcn} (@var{data})\n\ |
|
1144 @end example\n\ |
|
1145 \n\ |
|
1146 If @var{data} is omitted, Octave calls the function without any\n\ |
|
1147 arguments. If both @var{fcn} and @var{data} are omitted, Octave\n\ |
|
1148 clears the hook. In all cases, the name of the previous hook function\n\ |
|
1149 and the user data are returned.\n\ |
|
1150 @end deftypefn") |
|
1151 { |
|
1152 octave_value_list retval; |
|
1153 |
|
1154 int nargin = args.length (); |
|
1155 |
|
1156 if (nargin > 2) |
5823
|
1157 print_usage (); |
3498
|
1158 else |
|
1159 { |
|
1160 octave_value tmp_user_data; |
|
1161 |
3523
|
1162 std::string tmp_hook_fcn; |
3498
|
1163 |
|
1164 if (nargin > 1) |
|
1165 tmp_user_data = args(1); |
|
1166 |
|
1167 if (nargin > 0) |
|
1168 { |
|
1169 tmp_hook_fcn = args(0).string_value (); |
|
1170 |
|
1171 if (error_state) |
|
1172 { |
|
1173 error ("input_event_hook: expecting string as first arg"); |
|
1174 return retval; |
|
1175 } |
|
1176 |
6913
|
1177 command_editor::add_event_hook (input_event_hook); |
3498
|
1178 } |
|
1179 |
|
1180 if (nargin == 0) |
6913
|
1181 command_editor::remove_event_hook (input_event_hook); |
3498
|
1182 |
|
1183 retval(1) = user_data; |
|
1184 retval(0) = hook_fcn; |
|
1185 |
|
1186 hook_fcn = tmp_hook_fcn; |
|
1187 user_data = tmp_user_data; |
|
1188 } |
|
1189 |
|
1190 return retval; |
|
1191 } |
|
1192 |
5794
|
1193 DEFUN (PS1, args, nargout, |
|
1194 "-*- texinfo -*-\n\ |
|
1195 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ |
|
1196 @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\ |
|
1197 Query or set the primary prompt string. When executing interactively,\n\ |
|
1198 Octave displays the primary prompt when it is ready to read a command.\n\ |
3332
|
1199 \n\ |
5794
|
1200 The default value of the primary prompt string is @code{\"\\s:\\#> \"}.\n\ |
|
1201 To change it, use a command like\n\ |
3332
|
1202 \n\ |
|
1203 @example\n\ |
7097
|
1204 octave:13> PS1 (\"\\\\u@@\\\\H> \")\n\ |
3332
|
1205 @end example\n\ |
|
1206 \n\ |
|
1207 @noindent\n\ |
|
1208 which will result in the prompt @samp{boris@@kremvax> } for the user\n\ |
|
1209 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ |
5794
|
1210 backslashes are required to enter a backslash into a double-quoted\n\ |
|
1211 character string.\n\ |
3332
|
1212 @xref{Strings}.\n\ |
6373
|
1213 @seealso{PS2, PS4}\n\ |
5794
|
1214 @end deftypefn") |
|
1215 { |
|
1216 return SET_INTERNAL_VARIABLE (PS1); |
|
1217 } |
2181
|
1218 |
5794
|
1219 DEFUN (PS2, args, nargout, |
|
1220 "-*- texinfo -*-\n\ |
|
1221 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ |
|
1222 @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\ |
|
1223 Query or set the secondary prompt string. The secondary prompt is\n\ |
|
1224 printed when Octave is expecting additional input to complete a\n\ |
|
1225 command. For example, if you are typing a for loop that spans several\n\ |
|
1226 lines, Octave will print the secondary prompt at the beginning of\n\ |
|
1227 each line after the first. The default value of the secondary prompt\n\ |
|
1228 string is @code{\"> \"}.\n\ |
|
1229 @seealso{PS1, PS4}\n\ |
|
1230 @end deftypefn") |
|
1231 { |
|
1232 return SET_INTERNAL_VARIABLE (PS2); |
|
1233 } |
2181
|
1234 |
5794
|
1235 DEFUN (PS4, args, nargout, |
|
1236 "-*- texinfo -*-\n\ |
|
1237 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ |
|
1238 @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\ |
|
1239 Query or set the character string used to prefix output produced\n\ |
|
1240 when echoing commands when @code{echo_executing_commands} is enabled.\n\ |
6620
|
1241 The default value is @code{\"+ \"}.\n\ |
|
1242 @xref{Invoking Octave from the Command Line}, for a description of\n\ |
|
1243 @code{--echo-commands}.\n\ |
5794
|
1244 @seealso{echo_executing_commands, PS1, PS2}\n\ |
|
1245 @end deftypefn") |
|
1246 { |
|
1247 return SET_INTERNAL_VARIABLE (PS4); |
|
1248 } |
2181
|
1249 |
5794
|
1250 DEFUN (completion_append_char, args, nargout, |
|
1251 "-*- texinfo -*-\n\ |
|
1252 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ |
|
1253 @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\ |
|
1254 Query or set the internal character variable that is appended to\n\ |
|
1255 successful command-line completion attempts. The default\n\ |
3332
|
1256 value is @code{\" \"} (a single space).\n\ |
5794
|
1257 @end deftypefn") |
|
1258 { |
|
1259 return SET_INTERNAL_VARIABLE (completion_append_char); |
|
1260 } |
3019
|
1261 |
5794
|
1262 DEFUN (echo_executing_commands, args, nargout, |
|
1263 "-*- texinfo -*-\n\ |
|
1264 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ |
|
1265 @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\ |
|
1266 Query or set the internal variable that controls the echo state.\n\ |
|
1267 It may be the sum of the following values:\n\ |
3332
|
1268 \n\ |
|
1269 @table @asis\n\ |
|
1270 @item 1\n\ |
|
1271 Echo commands read from script files.\n\ |
|
1272 \n\ |
|
1273 @item 2\n\ |
|
1274 Echo commands from functions.\n\ |
|
1275 \n\ |
|
1276 @item 4\n\ |
|
1277 Echo commands read from command line.\n\ |
|
1278 @end table\n\ |
|
1279 \n\ |
|
1280 More than one state can be active at once. For example, a value of 3 is\n\ |
|
1281 equivalent to the command @kbd{echo on all}.\n\ |
|
1282 \n\ |
|
1283 The value of @code{echo_executing_commands} is set by the @kbd{echo}\n\ |
|
1284 command and the command line option @code{--echo-input}.\n\ |
5794
|
1285 @end deftypefn") |
|
1286 { |
|
1287 return SET_INTERNAL_VARIABLE (echo_executing_commands); |
2181
|
1288 } |
|
1289 |
6257
|
1290 DEFUN (__request_drawnow__, args, , |
|
1291 "-*- texinfo -*-\n\ |
|
1292 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ |
|
1293 @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ |
6945
|
1294 Undocumented internal function.\n\ |
6257
|
1295 @end deftypefn") |
|
1296 { |
|
1297 octave_value retval; |
|
1298 |
|
1299 int nargin = args.length (); |
|
1300 |
|
1301 if (nargin == 0) |
|
1302 Vdrawnow_requested = true; |
|
1303 else if (nargin == 1) |
|
1304 Vdrawnow_requested = args(0).bool_value (); |
|
1305 else |
|
1306 print_usage (); |
|
1307 |
|
1308 return retval; |
|
1309 } |
|
1310 |
7294
|
1311 DEFUN (__gud_mode__, args, , |
|
1312 "-*- texinfo -*-\n\ |
|
1313 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ |
|
1314 Undocumented internal function.\n\ |
|
1315 @end deftypefn") |
|
1316 { |
|
1317 octave_value retval; |
|
1318 |
|
1319 int nargin = args.length (); |
|
1320 |
|
1321 if (nargin == 0) |
|
1322 retval = Vgud_mode; |
|
1323 else if (nargin == 1) |
|
1324 Vgud_mode = args(0).bool_value (); |
|
1325 else |
|
1326 print_usage (); |
|
1327 |
|
1328 return retval; |
|
1329 } |
|
1330 |
1
|
1331 /* |
|
1332 ;;; Local Variables: *** |
|
1333 ;;; mode: C++ *** |
|
1334 ;;; End: *** |
|
1335 */ |