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