Mercurial > hg > octave-lyh
annotate src/input.cc @ 7552:6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
author | ryanru@PrinceHumperdinck |
---|---|
date | Tue, 04 Mar 2008 17:01:05 -0500 |
parents | d3fe4d466bc2 |
children | 87eda1f8faaa |
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 { |
5744 | 601 octave_function *caller |
602 = octave_call_stack::caller_user_script_or_function (); | |
5743 | 603 |
604 if (caller) | |
605 { | |
606 nm = caller->fcn_file_name (); | |
4975 | 607 |
5743 | 608 if (nm.empty ()) |
609 nm = caller->name (); | |
4975 | 610 |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7459
diff
changeset
|
611 line = tree_statement_stack::current_line (); |
5743 | 612 } |
4975 | 613 } |
614 | |
5765 | 615 std::ostringstream buf; |
4975 | 616 |
617 if (! nm.empty ()) | |
618 { | |
7294 | 619 if (Vgud_mode) |
620 { | |
621 static char ctrl_z = 'Z' & 0x1f; | |
4975 | 622 |
7294 | 623 buf << ctrl_z << ctrl_z << nm << ":" << line; |
624 } | |
625 else | |
626 { | |
627 buf << "stopped in " << nm; | |
628 | |
629 if (line > 0) | |
630 buf << " at line " << line; | |
631 } | |
4975 | 632 } |
633 | |
5765 | 634 std::string msg = buf.str (); |
4975 | 635 |
636 if (! msg.empty ()) | |
7294 | 637 message (Vgud_mode ? 0 : "keyboard", msg.c_str ()); |
4975 | 638 |
639 std::string prompt = "debug> "; | |
1761 | 640 |
712 | 641 if (nargin > 0) |
3707 | 642 { |
643 prompt = args(0).string_value (); | |
636 | 644 |
3707 | 645 if (error_state) |
646 { | |
647 error ("input: unrecognized argument"); | |
648 return retval; | |
649 } | |
529 | 650 } |
651 | |
652 again: | |
653 | |
2095 | 654 flush_octave_stdout (); |
529 | 655 |
4565 | 656 octave_diary << prompt; |
657 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
658 std::string input_buf = interactive_input (prompt.c_str (), true); |
529 | 659 |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
660 if (! (error_state || input_buf.empty ())) |
529 | 661 { |
1799 | 662 if (! input_from_startup_file) |
2927 | 663 command_history::add (input_buf); |
529 | 664 |
2927 | 665 size_t len = input_buf.length (); |
529 | 666 |
4565 | 667 octave_diary << input_buf; |
668 | |
669 if (input_buf[len - 1] != '\n') | |
670 octave_diary << "\n"; | |
671 | |
529 | 672 if (len < 1) |
673 { | |
674 if (debug) | |
675 goto again; | |
676 else | |
4233 | 677 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
529 | 678 } |
679 | |
3772 | 680 if (debug) |
681 { | |
4170 | 682 if (match_sans_spaces_semi ("exit", input_buf) |
683 || match_sans_spaces_semi ("quit", input_buf) | |
684 || match_sans_spaces_semi ("return", input_buf) | |
5388 | 685 || match_sans_spaces_semi ("dbcont", input_buf)) |
3772 | 686 { |
687 return retval; | |
688 } | |
5388 | 689 else if (match_sans_spaces_semi ("dbstep", input_buf)) |
3772 | 690 { |
691 tree::break_next = true; | |
3805 | 692 |
693 tree::last_line = 0; | |
694 | |
5743 | 695 tree::break_function = octave_call_stack::current (); |
3805 | 696 |
697 return retval; | |
698 } | |
5388 | 699 else if (match_sans_spaces_semi ("dbnext", input_buf)) |
3805 | 700 { |
701 tree::break_next = true; | |
702 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7459
diff
changeset
|
703 tree::last_line = tree_statement_stack::current_line (); |
3805 | 704 |
5743 | 705 tree::break_function = octave_call_stack::current (); |
3805 | 706 |
3772 | 707 return retval; |
708 } | |
963 | 709 } |
3772 | 710 |
711 if (read_as_string) | |
963 | 712 { |
5775 | 713 // FIXME -- fix gnu_readline and octave_gets instead! |
3081 | 714 if (input_buf.length () == 1 && input_buf[0] == '\n') |
3100 | 715 retval(0) = ""; |
3081 | 716 else |
3100 | 717 retval(0) = input_buf; |
963 | 718 } |
529 | 719 else |
720 { | |
721 int parse_status = 0; | |
2900 | 722 |
3100 | 723 bool silent = ! debug; |
2900 | 724 |
3100 | 725 retval = eval_string (input_buf, silent, parse_status, nargout); |
726 | |
3215 | 727 if (! debug && retval.length () == 0) |
3100 | 728 retval(0) = Matrix (); |
529 | 729 } |
730 } | |
731 else | |
732 error ("input: reading user-input failed!"); | |
733 | |
734 if (debug) | |
3098 | 735 { |
736 // Clear error_state so that if errors were encountered while | |
737 // evaluating user input, extra error messages will not be | |
738 // printed after we return. | |
739 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
740 reset_error_handler (); |
3098 | 741 |
3100 | 742 retval = octave_value_list (); |
3098 | 743 |
744 goto again; | |
745 } | |
529 | 746 |
747 return retval; | |
748 } | |
749 | |
3100 | 750 DEFUN (input, args, nargout, |
3372 | 751 "-*- texinfo -*-\n\ |
752 @deftypefn {Built-in Function} {} input (@var{prompt})\n\ | |
753 @deftypefnx {Built-in Function} {} input (@var{prompt}, \"s\")\n\ | |
754 Print a prompt and wait for user input. For example,\n\ | |
755 \n\ | |
756 @example\n\ | |
757 input (\"Pick a number, any number! \")\n\ | |
758 @end example\n\ | |
759 \n\ | |
760 @noindent\n\ | |
761 prints the prompt\n\ | |
762 \n\ | |
763 @example\n\ | |
764 Pick a number, any number!\n\ | |
765 @end example\n\ | |
529 | 766 \n\ |
3372 | 767 @noindent\n\ |
768 and waits for the user to enter a value. The string entered by the user\n\ | |
769 is evaluated as an expression, so it may be a literal constant, a\n\ | |
770 variable name, or any other valid expression.\n\ | |
771 \n\ | |
772 Currently, @code{input} only returns one value, regardless of the number\n\ | |
773 of values produced by the evaluation of the expression.\n\ | |
774 \n\ | |
775 If you are only interested in getting a literal string value, you can\n\ | |
776 call @code{input} with the character string @code{\"s\"} as the second\n\ | |
777 argument. This tells Octave to return the string entered by the user\n\ | |
778 directly, without evaluating it first.\n\ | |
779 \n\ | |
780 Because there may be output waiting to be displayed by the pager, it is\n\ | |
781 a good idea to always call @code{fflush (stdout)} before calling\n\ | |
782 @code{input}. This will ensure that all pending output is written to\n\ | |
783 the screen before your prompt. @xref{Input and Output}.\n\ | |
784 @end deftypefn") | |
529 | 785 { |
2086 | 786 octave_value_list retval; |
529 | 787 |
788 int nargin = args.length (); | |
789 | |
712 | 790 if (nargin == 1 || nargin == 2) |
3100 | 791 retval = get_user_input (args, false, nargout); |
529 | 792 else |
5823 | 793 print_usage (); |
529 | 794 |
795 return retval; | |
796 } | |
797 | |
5640 | 798 bool |
799 octave_yes_or_no (const std::string& prompt) | |
800 { | |
801 std::string prompt_string = prompt + "(yes or no) "; | |
802 | |
803 while (1) | |
804 { | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
805 std::string input_buf = interactive_input (prompt_string, true); |
5640 | 806 |
807 if (input_buf == "yes") | |
808 return true; | |
809 else if (input_buf == "no") | |
810 return false; | |
811 else | |
812 message (0, "Please answer yes or no."); | |
813 } | |
814 } | |
815 | |
816 DEFUN (yes_or_no, args, , | |
817 "-*- texinfo -*-\n\ | |
818 @deftypefn {Built-in Function} {} yes_or_no (@var{prompt})\n\ | |
819 Ask the user a yes-or-no question. Return 1 if the answer is yes.\n\ | |
820 Takes one argument, which is the string to display to ask the\n\ | |
821 question. It should end in a space; @samp{yes-or-no-p} adds\n\ | |
822 @samp{(yes or no) } to it. The user must confirm the answer with\n\ | |
823 RET and can edit it until it has been confirmed.\n\ | |
824 @end deftypefn") | |
825 { | |
826 octave_value retval; | |
827 | |
828 int nargin = args.length (); | |
829 | |
830 if (nargin == 0 || nargin == 1) | |
831 { | |
832 std::string prompt; | |
833 | |
834 if (nargin == 1) | |
835 { | |
836 prompt = args(0).string_value (); | |
837 | |
838 if (error_state) | |
839 { | |
840 error ("yes_or_no: expecting argument to be character string"); | |
841 return retval; | |
842 } | |
843 } | |
844 | |
845 retval = octave_yes_or_no (prompt); | |
846 } | |
847 else | |
5823 | 848 print_usage (); |
5640 | 849 |
850 return retval; | |
851 } | |
852 | |
3098 | 853 static void |
854 restore_command_history (void *) | |
855 { | |
856 command_history::ignore_entries (! Vsaving_history); | |
857 } | |
858 | |
3707 | 859 octave_value |
860 do_keyboard (const octave_value_list& args) | |
861 { | |
862 octave_value retval; | |
863 | |
864 int nargin = args.length (); | |
865 | |
866 assert (nargin == 0 || nargin == 1); | |
867 | |
868 unwind_protect::begin_frame ("do_keyboard"); | |
869 | |
5775 | 870 // FIXME -- we shouldn't need both the |
3707 | 871 // command_history object and the |
872 // Vsaving_history variable... | |
873 command_history::ignore_entries (false); | |
874 | |
875 unwind_protect::add (restore_command_history, 0); | |
876 | |
877 unwind_protect_bool (Vsaving_history); | |
878 | |
879 Vsaving_history = true; | |
880 | |
4233 | 881 octave_value_list tmp = get_user_input (args, true, 0); |
882 | |
883 retval = tmp(0); | |
3707 | 884 |
885 unwind_protect::run_frame ("do_keyboard"); | |
886 | |
887 return retval; | |
888 } | |
889 | |
1957 | 890 DEFUN (keyboard, args, , |
3372 | 891 "-*- texinfo -*-\n\ |
892 @deftypefn {Built-in Function} {} keyboard (@var{prompt})\n\ | |
893 This function is normally used for simple debugging. When the\n\ | |
894 @code{keyboard} function is executed, Octave prints a prompt and waits\n\ | |
895 for user input. The input strings are then evaluated and the results\n\ | |
896 are printed. This makes it possible to examine the values of variables\n\ | |
897 within a function, and to assign new values to variables. No value is\n\ | |
898 returned from the @code{keyboard} function, and it continues to prompt\n\ | |
899 for input until the user types @samp{quit}, or @samp{exit}.\n\ | |
529 | 900 \n\ |
3372 | 901 If @code{keyboard} is invoked without any arguments, a default prompt of\n\ |
902 @samp{debug> } is used.\n\ | |
903 @end deftypefn") | |
529 | 904 { |
2086 | 905 octave_value_list retval; |
529 | 906 |
907 int nargin = args.length (); | |
908 | |
712 | 909 if (nargin == 0 || nargin == 1) |
3707 | 910 do_keyboard (args); |
529 | 911 else |
5823 | 912 print_usage (); |
529 | 913 |
914 return retval; | |
915 } | |
916 | |
4208 | 917 DEFCMD (echo, args, , |
3332 | 918 "-*- texinfo -*-\n\ |
919 @deffn {Command} echo options\n\ | |
920 Control whether commands are displayed as they are executed. Valid\n\ | |
921 options are:\n\ | |
1588 | 922 \n\ |
3332 | 923 @table @code\n\ |
924 @item on\n\ | |
925 Enable echoing of commands as they are executed in script files.\n\ | |
926 \n\ | |
927 @item off\n\ | |
928 Disable echoing of commands as they are executed in script files.\n\ | |
1588 | 929 \n\ |
3332 | 930 @item on all\n\ |
931 Enable echoing of commands as they are executed in script files and\n\ | |
932 functions.\n\ | |
1588 | 933 \n\ |
3332 | 934 @item off all\n\ |
935 Disable echoing of commands as they are executed in script files and\n\ | |
936 functions.\n\ | |
937 @end table\n\ | |
938 \n\ | |
939 @noindent\n\ | |
940 If invoked without any arguments, @code{echo} toggles the current echo\n\ | |
941 state.\n\ | |
3333 | 942 @end deffn") |
1588 | 943 { |
2086 | 944 octave_value_list retval; |
1588 | 945 |
1755 | 946 int argc = args.length () + 1; |
947 | |
1968 | 948 string_vector argv = args.make_argv ("echo"); |
1755 | 949 |
950 if (error_state) | |
951 return retval; | |
1588 | 952 |
953 switch (argc) | |
954 { | |
955 case 1: | |
956 { | |
2205 | 957 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
958 || (Vecho_executing_commands & ECHO_FUNCTIONS)) | |
5794 | 959 Vecho_executing_commands = ECHO_OFF; |
1588 | 960 else |
5794 | 961 Vecho_executing_commands = ECHO_SCRIPTS; |
1588 | 962 } |
963 break; | |
964 | |
965 case 2: | |
966 { | |
3523 | 967 std::string arg = argv[1]; |
1755 | 968 |
969 if (arg == "on") | |
5794 | 970 Vecho_executing_commands = ECHO_SCRIPTS; |
1755 | 971 else if (arg == "off") |
5794 | 972 Vecho_executing_commands = ECHO_OFF; |
1588 | 973 else |
5823 | 974 print_usage (); |
1588 | 975 } |
976 break; | |
977 | |
978 case 3: | |
979 { | |
3523 | 980 std::string arg = argv[1]; |
1755 | 981 |
982 if (arg == "on" && argv[2] == "all") | |
2800 | 983 { |
984 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); | |
5794 | 985 Vecho_executing_commands = tmp; |
2800 | 986 } |
1755 | 987 else if (arg == "off" && argv[2] == "all") |
5794 | 988 Vecho_executing_commands = ECHO_OFF; |
1588 | 989 else |
5823 | 990 print_usage (); |
1588 | 991 } |
992 break; | |
993 | |
994 default: | |
5823 | 995 print_usage (); |
1588 | 996 break; |
997 } | |
998 | |
999 return retval; | |
1000 } | |
1001 | |
2234 | 1002 DEFUN (completion_matches, args, nargout, |
3332 | 1003 "-*- texinfo -*-\n\ |
1004 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ | |
1005 Generate possible completions given @var{hint}.\n\ | |
2299 | 1006 \n\ |
1007 This function is provided for the benefit of programs like Emacs which\n\ | |
3332 | 1008 might be controlling Octave and handling user input. The current\n\ |
1009 command number is not incremented when this function is called. This is\n\ | |
1010 a feature, not a bug.\n\ | |
3333 | 1011 @end deftypefn") |
2234 | 1012 { |
2281 | 1013 octave_value retval; |
2234 | 1014 |
1015 int nargin = args.length (); | |
1016 | |
1017 if (nargin == 1) | |
1018 { | |
3523 | 1019 std::string hint = args(0).string_value (); |
2234 | 1020 |
1021 if (! error_state) | |
1022 { | |
1023 int n = 32; | |
1024 | |
1025 string_vector list (n); | |
1026 | |
1027 int k = 0; | |
1028 | |
1029 for (;;) | |
1030 { | |
3523 | 1031 std::string cmd = generate_completion (hint, k); |
2234 | 1032 |
2944 | 1033 if (! cmd.empty ()) |
2234 | 1034 { |
2944 | 1035 if (k == n) |
2234 | 1036 { |
2944 | 1037 n *= 2; |
1038 list.resize (n); | |
1039 } | |
2235 | 1040 |
2944 | 1041 list[k++] = cmd; |
2234 | 1042 } |
1043 else | |
1044 { | |
1045 list.resize (k); | |
1046 break; | |
1047 } | |
1048 } | |
1049 | |
1050 if (nargout > 0) | |
2281 | 1051 { |
1052 if (! list.empty ()) | |
1053 retval = list; | |
2282 | 1054 else |
1055 retval = ""; | |
2281 | 1056 } |
2234 | 1057 else |
1058 { | |
2235 | 1059 // We don't use string_vector::list_in_columns here |
1060 // because it will be easier for Emacs if the names | |
1061 // appear in a single column. | |
1062 | |
2234 | 1063 int len = list.length (); |
1064 | |
1065 for (int i = 0; i < len; i++) | |
1066 octave_stdout << list[i] << "\n"; | |
1067 } | |
2299 | 1068 |
1069 octave_completion_matches_called = true; | |
2234 | 1070 } |
1071 } | |
1072 else | |
5823 | 1073 print_usage (); |
2234 | 1074 |
1075 return retval; | |
1076 } | |
1077 | |
3189 | 1078 DEFUN (read_readline_init_file, args, , |
3448 | 1079 "-*- texinfo -*-\n\ |
1080 @deftypefn {Built-in Function} {} read_readline_init_file (@var{file})\n\ | |
7007 | 1081 Read the readline library initialization file @var{file}. If\n\ |
3448 | 1082 @var{file} is omitted, read the default initialization file (normally\n\ |
6615 | 1083 @file{~/.inputrc}).\n\ |
1084 \n\ | |
1085 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ | |
1086 for details.\n\ | |
3448 | 1087 @end deftypefn") |
3189 | 1088 { |
1089 octave_value_list retval; | |
1090 | |
1091 int nargin = args.length (); | |
1092 | |
1093 if (nargin == 0) | |
1094 command_editor::read_init_file (); | |
1095 else if (nargin == 1) | |
1096 { | |
5872 | 1097 std::string file = args(0).string_value (); |
3189 | 1098 |
1099 if (! error_state) | |
1100 command_editor::read_init_file (file); | |
1101 } | |
1102 else | |
5823 | 1103 print_usage (); |
3189 | 1104 |
1105 return retval; | |
1106 } | |
1107 | |
3523 | 1108 static std::string hook_fcn; |
3498 | 1109 static octave_value user_data; |
1110 | |
4802 | 1111 static int |
3519 | 1112 input_event_hook (void) |
3498 | 1113 { |
4526 | 1114 if (is_valid_function (hook_fcn)) |
1115 { | |
1116 if (user_data.is_defined ()) | |
1117 feval (hook_fcn, user_data, 0); | |
1118 else | |
1119 feval (hook_fcn, octave_value_list (), 0); | |
1120 } | |
3498 | 1121 else |
4526 | 1122 { |
1123 hook_fcn = std::string (); | |
1124 user_data = octave_value (); | |
1125 | |
6913 | 1126 command_editor::remove_event_hook (input_event_hook); |
4802 | 1127 } |
1128 | |
1129 return 0; | |
3498 | 1130 } |
1131 | |
1132 DEFUN (input_event_hook, args, , | |
1133 "-*- texinfo -*-\n\ | |
1134 @deftypefn {Built-in Function} {[@var{ofcn}, @var{odata}] =} input_event_hook (@var{fcn}, @var{data})\n\ | |
1135 Given the name of a function as a string and any Octave value object,\n\ | |
1136 install @var{fcn} as a function to call periodically, when Octave is\n\ | |
1137 waiting for input. The function should have the form\n\ | |
1138 @example\n\ | |
1139 @var{fcn} (@var{data})\n\ | |
1140 @end example\n\ | |
1141 \n\ | |
1142 If @var{data} is omitted, Octave calls the function without any\n\ | |
1143 arguments. If both @var{fcn} and @var{data} are omitted, Octave\n\ | |
1144 clears the hook. In all cases, the name of the previous hook function\n\ | |
1145 and the user data are returned.\n\ | |
1146 @end deftypefn") | |
1147 { | |
1148 octave_value_list retval; | |
1149 | |
1150 int nargin = args.length (); | |
1151 | |
1152 if (nargin > 2) | |
5823 | 1153 print_usage (); |
3498 | 1154 else |
1155 { | |
1156 octave_value tmp_user_data; | |
1157 | |
3523 | 1158 std::string tmp_hook_fcn; |
3498 | 1159 |
1160 if (nargin > 1) | |
1161 tmp_user_data = args(1); | |
1162 | |
1163 if (nargin > 0) | |
1164 { | |
1165 tmp_hook_fcn = args(0).string_value (); | |
1166 | |
1167 if (error_state) | |
1168 { | |
1169 error ("input_event_hook: expecting string as first arg"); | |
1170 return retval; | |
1171 } | |
1172 | |
6913 | 1173 command_editor::add_event_hook (input_event_hook); |
3498 | 1174 } |
1175 | |
1176 if (nargin == 0) | |
6913 | 1177 command_editor::remove_event_hook (input_event_hook); |
3498 | 1178 |
1179 retval(1) = user_data; | |
1180 retval(0) = hook_fcn; | |
1181 | |
1182 hook_fcn = tmp_hook_fcn; | |
1183 user_data = tmp_user_data; | |
1184 } | |
1185 | |
1186 return retval; | |
1187 } | |
1188 | |
5794 | 1189 DEFUN (PS1, args, nargout, |
1190 "-*- texinfo -*-\n\ | |
1191 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ | |
1192 @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\ | |
1193 Query or set the primary prompt string. When executing interactively,\n\ | |
1194 Octave displays the primary prompt when it is ready to read a command.\n\ | |
3332 | 1195 \n\ |
5794 | 1196 The default value of the primary prompt string is @code{\"\\s:\\#> \"}.\n\ |
1197 To change it, use a command like\n\ | |
3332 | 1198 \n\ |
1199 @example\n\ | |
7097 | 1200 octave:13> PS1 (\"\\\\u@@\\\\H> \")\n\ |
3332 | 1201 @end example\n\ |
1202 \n\ | |
1203 @noindent\n\ | |
1204 which will result in the prompt @samp{boris@@kremvax> } for the user\n\ | |
1205 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ | |
5794 | 1206 backslashes are required to enter a backslash into a double-quoted\n\ |
1207 character string.\n\ | |
3332 | 1208 @xref{Strings}.\n\ |
6373 | 1209 @seealso{PS2, PS4}\n\ |
5794 | 1210 @end deftypefn") |
1211 { | |
1212 return SET_INTERNAL_VARIABLE (PS1); | |
1213 } | |
2181 | 1214 |
5794 | 1215 DEFUN (PS2, args, nargout, |
1216 "-*- texinfo -*-\n\ | |
1217 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ | |
1218 @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\ | |
1219 Query or set the secondary prompt string. The secondary prompt is\n\ | |
1220 printed when Octave is expecting additional input to complete a\n\ | |
1221 command. For example, if you are typing a for loop that spans several\n\ | |
1222 lines, Octave will print the secondary prompt at the beginning of\n\ | |
1223 each line after the first. The default value of the secondary prompt\n\ | |
1224 string is @code{\"> \"}.\n\ | |
1225 @seealso{PS1, PS4}\n\ | |
1226 @end deftypefn") | |
1227 { | |
1228 return SET_INTERNAL_VARIABLE (PS2); | |
1229 } | |
2181 | 1230 |
5794 | 1231 DEFUN (PS4, args, nargout, |
1232 "-*- texinfo -*-\n\ | |
1233 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ | |
1234 @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\ | |
1235 Query or set the character string used to prefix output produced\n\ | |
1236 when echoing commands when @code{echo_executing_commands} is enabled.\n\ | |
6620 | 1237 The default value is @code{\"+ \"}.\n\ |
1238 @xref{Invoking Octave from the Command Line}, for a description of\n\ | |
1239 @code{--echo-commands}.\n\ | |
5794 | 1240 @seealso{echo_executing_commands, PS1, PS2}\n\ |
1241 @end deftypefn") | |
1242 { | |
1243 return SET_INTERNAL_VARIABLE (PS4); | |
1244 } | |
2181 | 1245 |
5794 | 1246 DEFUN (completion_append_char, args, nargout, |
1247 "-*- texinfo -*-\n\ | |
1248 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ | |
1249 @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\ | |
1250 Query or set the internal character variable that is appended to\n\ | |
1251 successful command-line completion attempts. The default\n\ | |
3332 | 1252 value is @code{\" \"} (a single space).\n\ |
5794 | 1253 @end deftypefn") |
1254 { | |
1255 return SET_INTERNAL_VARIABLE (completion_append_char); | |
1256 } | |
3019 | 1257 |
5794 | 1258 DEFUN (echo_executing_commands, args, nargout, |
1259 "-*- texinfo -*-\n\ | |
1260 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ | |
1261 @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\ | |
1262 Query or set the internal variable that controls the echo state.\n\ | |
1263 It may be the sum of the following values:\n\ | |
3332 | 1264 \n\ |
1265 @table @asis\n\ | |
1266 @item 1\n\ | |
1267 Echo commands read from script files.\n\ | |
1268 \n\ | |
1269 @item 2\n\ | |
1270 Echo commands from functions.\n\ | |
1271 \n\ | |
1272 @item 4\n\ | |
1273 Echo commands read from command line.\n\ | |
1274 @end table\n\ | |
1275 \n\ | |
1276 More than one state can be active at once. For example, a value of 3 is\n\ | |
1277 equivalent to the command @kbd{echo on all}.\n\ | |
1278 \n\ | |
1279 The value of @code{echo_executing_commands} is set by the @kbd{echo}\n\ | |
1280 command and the command line option @code{--echo-input}.\n\ | |
5794 | 1281 @end deftypefn") |
1282 { | |
1283 return SET_INTERNAL_VARIABLE (echo_executing_commands); | |
2181 | 1284 } |
1285 | |
6257 | 1286 DEFUN (__request_drawnow__, args, , |
1287 "-*- texinfo -*-\n\ | |
1288 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ | |
1289 @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ | |
6945 | 1290 Undocumented internal function.\n\ |
6257 | 1291 @end deftypefn") |
1292 { | |
1293 octave_value retval; | |
1294 | |
1295 int nargin = args.length (); | |
1296 | |
1297 if (nargin == 0) | |
1298 Vdrawnow_requested = true; | |
1299 else if (nargin == 1) | |
1300 Vdrawnow_requested = args(0).bool_value (); | |
1301 else | |
1302 print_usage (); | |
1303 | |
1304 return retval; | |
1305 } | |
1306 | |
7294 | 1307 DEFUN (__gud_mode__, args, , |
1308 "-*- texinfo -*-\n\ | |
1309 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ | |
1310 Undocumented internal function.\n\ | |
1311 @end deftypefn") | |
1312 { | |
1313 octave_value retval; | |
1314 | |
1315 int nargin = args.length (); | |
1316 | |
1317 if (nargin == 0) | |
1318 retval = Vgud_mode; | |
1319 else if (nargin == 1) | |
1320 Vgud_mode = args(0).bool_value (); | |
1321 else | |
1322 print_usage (); | |
1323 | |
1324 return retval; | |
1325 } | |
1326 | |
1 | 1327 /* |
1328 ;;; Local Variables: *** | |
1329 ;;; mode: C++ *** | |
1330 ;;; End: *** | |
1331 */ |