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