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