Mercurial > octave
annotate libinterp/interpfcn/input.cc @ 16195:b52d2f9294b6
use class for reading lexer input
* input.h, input.cc (octave_base_input_reader, octave_terminal_reader,
octave_file_reader, octave_eval_string_reader): New classes.
(octave_gets): Now a member function of octave_base_reader.
(get_user_input): Delete function. Move actions to
octave_terminal_reader::get_input and
octave_eval_string_reader::get_input.
function. Call from octave_file_reader::get_input. Don't check
whether reading an eval string.
(current_eval_string, get_input_from_eval_string): Delete global
variables.
(get_debug_input): Check CURR_LEXER->input_from_eval_string instead of
global get_input_from_eval_string variable. Don't protect
get_input_from_eval_string.
* lex.h (octave_lexer::input_reader): New data member.
(octave_lexer::octave_lexer (void)): Initialize it.
(octave_lexer::octave_lexer (const std::string&),
octave_lexer::octave_lexer (FILE *)): New constructors.
* lex.h, lex.cc (octave_lexer::input_buffer::fill): New function.
(octave_lexer::input_buffer::read): Delete.
(octave_lexer::read): Rename from octave_read. Call reader to get
input, and then hand it to the input_buffer instead of asking the
input buffer to read input. Change all callers.
(octave_lexer::input_source, octave_lexer::input_from_eval_string):
New functions. Call octave_lexer::input_from_eval_string instead of
using get_input_from_eval_string.
* oct-parse.in.yy (octave_parser::octave_parser (FILE *),
octave_parser::octave_parser (const std::string&)): New constructors.
(parse_fcn_file): Pass FILE pointer to octave_parser constructor.
(eval_string): Pass string to octave_parser constructor instead of
setting global current_eval_string variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Mar 2013 10:19:51 -0500 |
parents | 490625211945 |
children | 2c5c538be353 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13970
diff
changeset
|
3 Copyright (C) 1993-2012 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
2939 | 23 // Get command input interactively or from files. |
1 | 24 |
240 | 25 #ifdef HAVE_CONFIG_H |
1192 | 26 #include <config.h> |
1 | 27 #endif |
28 | |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
29 #include <cstdio> |
1343 | 30 #include <cstdlib> |
31 #include <cstring> | |
32 #include <cassert> | |
33 | |
3503 | 34 #include <iostream> |
5765 | 35 #include <sstream> |
1728 | 36 #include <string> |
37 | |
529 | 38 #include <sys/types.h> |
39 #include <unistd.h> | |
1343 | 40 |
2927 | 41 #include "cmd-edit.h" |
3189 | 42 #include "file-ops.h" |
4153 | 43 #include "quit.h" |
1755 | 44 #include "str-vec.h" |
45 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
46 #include "debug.h" |
1352 | 47 #include "defun.h" |
48 #include "dirfns.h" | |
1 | 49 #include "error.h" |
2181 | 50 #include "gripes.h" |
3016 | 51 #include "help.h" |
1 | 52 #include "input.h" |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
53 #include "lex.h" |
5832 | 54 #include "load-path.h" |
1352 | 55 #include "oct-map.h" |
1742 | 56 #include "oct-hist.h" |
1670 | 57 #include "toplev.h" |
1755 | 58 #include "oct-obj.h" |
1 | 59 #include "pager.h" |
529 | 60 #include "parse.h" |
1352 | 61 #include "pathlen.h" |
3772 | 62 #include "pt.h" |
1755 | 63 #include "pt-const.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
64 #include "pt-eval.h" |
3805 | 65 #include "pt-stmt.h" |
1352 | 66 #include "sighandlers.h" |
1114 | 67 #include "sysdep.h" |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
68 #include "toplev.h" |
3098 | 69 #include "unwind-prot.h" |
1352 | 70 #include "utils.h" |
71 #include "variables.h" | |
529 | 72 |
2181 | 73 // Primary prompt string. |
5794 | 74 static std::string VPS1 = "\\s:\\#> "; |
2181 | 75 |
76 // Secondary prompt string. | |
5794 | 77 static std::string VPS2 = "> "; |
2181 | 78 |
79 // String printed before echoed input (enabled by --echo-input). | |
5794 | 80 std::string VPS4 = "+ "; |
2181 | 81 |
3019 | 82 // Echo commands as they are executed? |
83 // | |
84 // 1 ==> echo commands read from script files | |
85 // 2 ==> echo commands from functions | |
86 // 4 ==> echo commands read from command line | |
87 // | |
88 // more than one state can be active at once. | |
5794 | 89 int Vecho_executing_commands = ECHO_OFF; |
3019 | 90 |
3165 | 91 // The time we last printed a prompt. |
5832 | 92 octave_time Vlast_prompt_time = 0.0; |
3165 | 93 |
2181 | 94 // Character to append after successful command-line completion attempts. |
5794 | 95 static char Vcompletion_append_char = ' '; |
2181 | 96 |
5189 | 97 // TRUE means that input is coming from a file that was named on |
98 // the command line. | |
99 bool input_from_command_line_file = false; | |
100 | |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
101 // TRUE means that stdin is a terminal, not a pipe or redirected file. |
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
102 bool stdin_is_tty = false; |
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
103 |
3019 | 104 // TRUE means we're parsing a function file. |
105 bool reading_fcn_file = false; | |
1 | 106 |
9476 | 107 // TRUE means we're parsing a classdef file. |
108 bool reading_classdef_file = false; | |
109 | |
338 | 110 // Simple name of function file we are reading. |
3523 | 111 std::string curr_fcn_file_name; |
1606 | 112 |
113 // Full name of file we are reading. | |
3523 | 114 std::string curr_fcn_file_full_name; |
1 | 115 |
3019 | 116 // TRUE means we're parsing a script file. |
117 bool reading_script_file = false; | |
1 | 118 |
119 // If we are reading from an M-file, this is it. | |
529 | 120 FILE *ff_instream = 0; |
1 | 121 |
3019 | 122 // TRUE means this is an interactive shell. |
123 bool interactive = false; | |
1 | 124 |
3019 | 125 // TRUE means the user forced this shell to be interactive (-i). |
126 bool forced_interactive = false; | |
1 | 127 |
128 // Should we issue a prompt? | |
129 int promptflag = 1; | |
130 | |
131 // The current line of input, from wherever. | |
3523 | 132 std::string current_input_line; |
1 | 133 |
3804 | 134 // TRUE after a call to completion_matches. |
2299 | 135 bool octave_completion_matches_called = false; |
136 | |
6257 | 137 // TRUE if the plotting system has requested a call to drawnow at |
138 // the next user prompt. | |
7409 | 139 bool Vdrawnow_requested = false; |
6257 | 140 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
141 // TRUE if we are in debugging mode. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
142 bool Vdebugging = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
143 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
144 // If we are in debugging mode, this is the last command entered, so |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
145 // that we can repeat the previous command if the user just types RET. |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
146 static std::string last_debugging_command; |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
147 |
7294 | 148 // TRUE if we are running in the Emacs GUD mode. |
149 static bool Vgud_mode = false; | |
150 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
151 // The filemarker used to separate filenames from subfunction names |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
152 char Vfilemarker = '>'; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
153 |
1044 | 154 static void |
3523 | 155 do_input_echo (const std::string& input_string) |
1044 | 156 { |
1588 | 157 int do_echo = reading_script_file ? |
2205 | 158 (Vecho_executing_commands & ECHO_SCRIPTS) |
2618 | 159 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; |
1588 | 160 |
161 if (do_echo) | |
1044 | 162 { |
1403 | 163 if (forced_interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
164 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
165 if (promptflag > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
166 octave_stdout << command_editor::decode_prompt_string (VPS1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
167 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
168 octave_stdout << command_editor::decode_prompt_string (VPS2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
169 } |
1403 | 170 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
171 octave_stdout << command_editor::decode_prompt_string (VPS4); |
1044 | 172 |
1755 | 173 if (! input_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
174 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
175 octave_stdout << input_string; |
1755 | 176 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
177 if (input_string[input_string.length () - 1] != '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
178 octave_stdout << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
179 } |
1044 | 180 } |
181 } | |
182 | |
3536 | 183 std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
184 gnu_readline (const std::string& s, bool& eof, bool force_readline) |
1822 | 185 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
186 octave_quit (); |
5142 | 187 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
188 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
189 |
3523 | 190 std::string retval; |
1822 | 191 |
2927 | 192 if (line_editing || force_readline) |
1822 | 193 { |
3219 | 194 retval = command_editor::readline (s, eof); |
195 | |
196 if (! eof && retval.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
197 retval = "\n"; |
1822 | 198 } |
199 else | |
200 { | |
2927 | 201 if (! s.empty () && (interactive || forced_interactive)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
202 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
203 FILE *stream = command_editor::get_output_stream (); |
2927 | 204 |
10411 | 205 gnulib::fputs (s.c_str (), stream); |
12912
e116dd862879
use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
206 gnulib::fflush (stream); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
207 } |
1822 | 208 |
2927 | 209 FILE *curr_stream = command_editor::get_input_stream (); |
210 | |
9476 | 211 if (reading_fcn_file || reading_script_file || reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
212 curr_stream = ff_instream; |
1822 | 213 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
214 retval = octave_fgets (curr_stream, eof); |
1822 | 215 } |
216 | |
217 return retval; | |
218 } | |
581 | 219 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
220 extern std::string |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
221 gnu_readline (const std::string& s, bool force_readline) |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
222 { |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
223 bool eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
224 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
225 return gnu_readline (s, eof, force_readline); |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
226 } |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
227 |
6257 | 228 static inline std::string |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
229 interactive_input (const std::string& s, bool& eof, bool force_readline) |
6257 | 230 { |
231 Vlast_prompt_time.stamp (); | |
232 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
233 if (Vdrawnow_requested && (interactive || forced_interactive)) |
6257 | 234 { |
235 feval ("drawnow"); | |
236 | |
6367 | 237 flush_octave_stdout (); |
238 | |
6305 | 239 // We set Vdrawnow_requested to false even if there is an error |
240 // in drawnow so that the error doesn't reappear at every prompt. | |
241 | |
6257 | 242 Vdrawnow_requested = false; |
6305 | 243 |
244 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
245 return "\n"; |
6257 | 246 } |
247 | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
248 return gnu_readline (s, eof, force_readline); |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
249 } |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
250 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
251 static inline std::string |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
252 interactive_input (const std::string& s, bool force_readline = false) |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
253 { |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
254 bool eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
255 |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
256 return interactive_input (s, eof, force_readline); |
6257 | 257 } |
258 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
259 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
260 octave_base_reader::octave_gets (bool& eof) |
1 | 261 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
262 octave_quit (); |
5142 | 263 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
264 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
265 |
3523 | 266 std::string retval; |
1 | 267 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
268 bool history_skip_auto_repeated_debugging_command = false; |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
269 |
1822 | 270 if ((interactive || forced_interactive) |
5832 | 271 && (! (reading_fcn_file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
272 || reading_classdef_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
273 || reading_script_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
274 || input_from_startup_file |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
275 || input_from_command_line_file))) |
1 | 276 { |
5794 | 277 std::string ps = (promptflag > 0) ? VPS1 : VPS2; |
1755 | 278 |
3523 | 279 std::string prompt = command_editor::decode_prompt_string (ps); |
1 | 280 |
2618 | 281 pipe_handler_error_count = 0; |
282 | |
283 flush_octave_stdout (); | |
1 | 284 |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
285 octave_pager_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
286 octave_diary_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
287 |
2095 | 288 octave_diary << prompt; |
581 | 289 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
290 retval = interactive_input (prompt, eof, false); |
5832 | 291 |
292 // There is no need to update the load_path cache if there is no | |
293 // user input. | |
8019
0ef13e15319b
replace NPOS with std::string::npos
John W. Eaton <jwe@octave.org>
parents:
7913
diff
changeset
|
294 if (! retval.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
295 && retval.find_first_not_of (" \t\n\r") != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
296 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
297 load_path::update (); |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
298 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
299 if (Vdebugging) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
300 last_debugging_command = retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
301 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
302 last_debugging_command = std::string (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
303 } |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
304 else if (Vdebugging) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
305 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
306 retval = last_debugging_command; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
307 history_skip_auto_repeated_debugging_command = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
308 } |
1 | 309 } |
310 else | |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
311 retval = gnu_readline ("", eof, false); |
1 | 312 |
2927 | 313 current_input_line = retval; |
1 | 314 |
1822 | 315 if (! current_input_line.empty ()) |
1 | 316 { |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
317 if (! (input_from_startup_file || input_from_command_line_file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
318 || history_skip_auto_repeated_debugging_command)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
319 command_history::add (current_input_line); |
1 | 320 |
9476 | 321 if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
322 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
323 octave_diary << current_input_line; |
3176 | 324 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
325 if (current_input_line[current_input_line.length () - 1] != '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
326 octave_diary << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
327 } |
581 | 328 |
1822 | 329 do_input_echo (current_input_line); |
1 | 330 } |
9476 | 331 else if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) |
3176 | 332 octave_diary << "\n"; |
9476 | 333 |
1822 | 334 return retval; |
1 | 335 } |
336 | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14880
diff
changeset
|
337 // Fix things up so that input can come from file 'name', printing a |
581 | 338 // warning if the file doesn't exist. |
339 | |
1 | 340 FILE * |
3523 | 341 get_input_from_file (const std::string& name, int warn) |
1 | 342 { |
529 | 343 FILE *instream = 0; |
1 | 344 |
1750 | 345 if (name.length () > 0) |
12941
9a498efac5f1
use gnulib::fseek and gnulib::fopen
John W. Eaton <jwe@octave.org>
parents:
12912
diff
changeset
|
346 instream = gnulib::fopen (name.c_str (), "rb"); |
1 | 347 |
529 | 348 if (! instream && warn) |
1750 | 349 warning ("%s: no such file or directory", name.c_str ()); |
1 | 350 |
9476 | 351 if (reading_fcn_file || reading_script_file || reading_classdef_file) |
339 | 352 ff_instream = instream; |
1 | 353 else |
2927 | 354 command_editor::set_input_stream (instream); |
1 | 355 |
356 return instream; | |
357 } | |
358 | |
581 | 359 // Fix things up so that input can come from the standard input. This |
360 // may need to become much more complicated, which is why it's in a | |
361 // separate function. | |
362 | |
1 | 363 FILE * |
364 get_input_from_stdin (void) | |
365 { | |
2927 | 366 command_editor::set_input_stream (stdin); |
367 return command_editor::get_input_stream (); | |
1 | 368 } |
369 | |
5775 | 370 // FIXME -- make this generate file names when appropriate. |
2921 | 371 |
2247 | 372 static string_vector |
3523 | 373 generate_possible_completions (const std::string& text, std::string& prefix, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
374 std::string& hint) |
1280 | 375 { |
2247 | 376 string_vector names; |
1280 | 377 |
2921 | 378 prefix = ""; |
1280 | 379 |
4604 | 380 if (looks_like_struct (text)) |
1430 | 381 names = generate_struct_completions (text, prefix, hint); |
382 else | |
2247 | 383 names = make_name_list (); |
1280 | 384 |
2944 | 385 // Sort and remove duplicates. |
2348 | 386 |
8503
8ba2ee57c594
remove qsort in favor of sort
Jaroslav Hajek <highegg@gmail.com>
parents:
8447
diff
changeset
|
387 names.sort (true); |
2348 | 388 |
1280 | 389 return names; |
390 } | |
391 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
392 static bool |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
393 is_completing_dirfns (void) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
394 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
395 static std::string dirfns_commands[] = {"cd", "ls"}; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
396 static const size_t dirfns_commands_length = 2; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
397 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
398 bool retval = false; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
399 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
400 std::string line = command_editor::get_line_buffer (); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
401 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
402 for (size_t i = 0; i < dirfns_commands_length; i++) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
403 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
404 int index = line.find (dirfns_commands[i] + " "); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
405 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
406 if (index == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
407 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
408 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
409 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
410 } |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
411 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
412 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
413 return retval; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
414 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
415 |
3536 | 416 static std::string |
3523 | 417 generate_completion (const std::string& text, int state) |
1280 | 418 { |
3523 | 419 std::string retval; |
2944 | 420 |
3523 | 421 static std::string prefix; |
422 static std::string hint; | |
1280 | 423 |
2921 | 424 static size_t hint_len = 0; |
1280 | 425 |
1 | 426 static int list_index = 0; |
2921 | 427 static int name_list_len = 0; |
4604 | 428 static int name_list_total_len = 0; |
2247 | 429 static string_vector name_list; |
4604 | 430 static string_vector file_name_list; |
1 | 431 |
1280 | 432 static int matches = 0; |
1 | 433 |
434 if (state == 0) | |
435 { | |
436 list_index = 0; | |
437 | |
2921 | 438 prefix = ""; |
1280 | 439 |
2921 | 440 hint = text; |
1280 | 441 |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
442 // No reason to display symbols while completing a |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
443 // file/directory operation. |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
444 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
445 if (is_completing_dirfns ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
446 name_list = string_vector (); |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
447 else |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
448 name_list = generate_possible_completions (text, prefix, hint); |
1280 | 449 |
2921 | 450 name_list_len = name_list.length (); |
451 | |
4604 | 452 file_name_list = command_editor::generate_filename_completions (text); |
453 | |
454 name_list.append (file_name_list); | |
455 | |
456 name_list_total_len = name_list.length (); | |
457 | |
2921 | 458 hint_len = hint.length (); |
1280 | 459 |
460 matches = 0; | |
2247 | 461 |
2921 | 462 for (int i = 0; i < name_list_len; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
463 if (hint == name_list[i].substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
464 matches++; |
1 | 465 } |
466 | |
4604 | 467 if (name_list_total_len > 0 && matches > 0) |
1 | 468 { |
4604 | 469 while (list_index < name_list_total_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
470 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
471 std::string name = name_list[list_index]; |
2247 | 472 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
473 list_index++; |
2247 | 474 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
475 if (hint == name.substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
476 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
477 if (list_index <= name_list_len && ! prefix.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
478 retval = prefix + "." + name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
479 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
480 retval = name; |
1280 | 481 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
482 // FIXME -- looks_like_struct is broken for now, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
483 // so it always returns false. |
4179 | 484 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
485 if (matches == 1 && looks_like_struct (retval)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
486 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
487 // Don't append anything, since we don't know |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
488 // whether it should be '(' or '.'. |
4179 | 489 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
490 command_editor::set_completion_append_character ('\0'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
491 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
492 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
493 command_editor::set_completion_append_character |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
494 (Vcompletion_append_char); |
1280 | 495 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
496 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
497 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
498 } |
1 | 499 } |
500 | |
2944 | 501 return retval; |
1 | 502 } |
503 | |
6979 | 504 static std::string |
505 quoting_filename (const std::string &text, int, char quote) | |
506 { | |
507 if (quote) | |
508 return text; | |
509 else | |
510 return (std::string ("'") + text); | |
511 } | |
512 | |
2927 | 513 void |
514 initialize_command_input (void) | |
515 { | |
516 // If we are using readline, this allows conditional parsing of the | |
517 // .inputrc file. | |
269 | 518 |
2927 | 519 command_editor::set_name ("Octave"); |
1358 | 520 |
5775 | 521 // FIXME -- this needs to include a comma too, but that |
3933 | 522 // causes trouble for the new struct element completion code. |
523 | |
4272 | 524 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
3933 | 525 |
526 command_editor::set_basic_word_break_characters (s); | |
527 | |
528 command_editor::set_completer_word_break_characters (s); | |
529 | |
3004 | 530 command_editor::set_basic_quote_characters ("\""); |
2944 | 531 |
6979 | 532 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
533 command_editor::set_completer_quote_characters ("'\""); | |
534 | |
2944 | 535 command_editor::set_completion_function (generate_completion); |
6979 | 536 |
537 command_editor::set_quoting_function (quoting_filename); | |
269 | 538 } |
539 | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
540 static void |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
541 get_debug_input (const std::string& prompt) |
269 | 542 { |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
543 octave_user_code *caller = octave_call_stack::caller_user_code (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
544 std::string nm; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
545 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
546 int curr_debug_line = octave_call_stack::current_line (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
547 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
548 bool have_file = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
549 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
550 if (caller) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
551 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
552 nm = caller->fcn_file_name (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
553 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
554 if (nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
555 nm = caller->name (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
556 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
557 have_file = true; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
558 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
559 else |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
560 curr_debug_line = -1; |
3180 | 561 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
562 std::ostringstream buf; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
563 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
564 if (! nm.empty ()) |
3180 | 565 { |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
566 if (Vgud_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
567 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
568 static char ctrl_z = 'Z' & 0x1f; |
269 | 569 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
570 buf << ctrl_z << ctrl_z << nm << ":" << curr_debug_line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
571 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
572 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
573 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
574 // FIXME -- we should come up with a clean way to detect |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
575 // that we are stopped on the no-op command that marks the |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
576 // end of a function or script. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
577 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
578 buf << "stopped in " << nm; |
1 | 579 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
580 if (curr_debug_line > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
581 buf << " at line " << curr_debug_line; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
582 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
583 if (have_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
584 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
585 std::string line_buf |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
586 = get_file_line (nm, curr_debug_line); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
587 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
588 if (! line_buf.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
589 buf << "\n" << curr_debug_line << ": " << line_buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
590 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
591 } |
3180 | 592 } |
593 | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
594 std::string msg = buf.str (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
595 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
596 if (! msg.empty ()) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
597 std::cerr << msg << std::endl; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
598 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
599 unwind_protect frame; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
600 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
601 frame.protect_var (VPS1); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
602 VPS1 = prompt; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
603 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
604 if (! (interactive || forced_interactive) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
605 || (reading_fcn_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
606 || reading_classdef_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
607 || reading_script_file |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
608 || CURR_LEXER->input_from_eval_string () |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
609 || input_from_startup_file |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
610 || input_from_command_line_file)) |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
611 { |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
612 frame.protect_var (forced_interactive); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
613 forced_interactive = true; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
614 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
615 frame.protect_var (reading_fcn_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
616 reading_fcn_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
617 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
618 frame.protect_var (reading_classdef_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
619 reading_classdef_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
620 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
621 frame.protect_var (reading_script_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
622 reading_script_file = false; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
623 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
624 frame.protect_var (input_from_startup_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
625 input_from_startup_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
626 |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
627 frame.protect_var (input_from_command_line_file); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
628 input_from_command_line_file = false; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
629 } |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
630 |
16151 | 631 // octave_parser constructor sets this for us. |
632 frame.protect_var (CURR_LEXER); | |
633 | |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
634 octave_parser curr_parser; |
16151 | 635 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
636 while (Vdebugging) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
637 { |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
638 unwind_protect middle_frame; |
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
639 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
640 reset_error_handler (); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
641 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
642 curr_parser.reset (); |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
643 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
644 // Do this with an unwind-protect cleanup function so that the |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
645 // forced variables will be unmarked in the event of an interrupt. |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
646 symbol_table::scope_id scope = symbol_table::top_scope (); |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
647 middle_frame.add_fcn (symbol_table::unmark_forced_variables, scope); |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9215
diff
changeset
|
648 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
649 int retval = curr_parser.run (); |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
650 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
651 if (retval == 0 && curr_parser.stmt_list) |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
652 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
653 curr_parser.stmt_list->accept (*current_evaluator); |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
654 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
655 if (octave_completion_matches_called) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
656 octave_completion_matches_called = false; |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9485
diff
changeset
|
657 } |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
658 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
659 octave_quit (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
660 } |
529 | 661 } |
662 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
663 const std::string octave_base_reader::in_src ("invalid"); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
664 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
665 const std::string octave_terminal_reader::in_src ("terminal"); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
666 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
667 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
668 octave_terminal_reader::get_input (bool& eof) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
669 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
670 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
671 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
672 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
673 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
674 std::string retval = octave_gets (eof); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
675 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
676 current_input_line = retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
677 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
678 return retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
679 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
680 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
681 const std::string octave_file_reader::in_src ("file"); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
682 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
683 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
684 octave_file_reader::get_input (bool& eof) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
685 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
686 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
687 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
688 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
689 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
690 std::string retval = octave_fgets (file, eof); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
691 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
692 current_input_line = retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
693 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
694 return retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
695 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
696 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
697 const std::string octave_eval_string_reader::in_src ("eval_string"); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
698 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
699 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
700 octave_eval_string_reader::get_input (bool& eof) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
701 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
702 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
703 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
704 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
705 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
706 std::string retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
707 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
708 retval = eval_string; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
709 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
710 // Clear the eval string so that the next call will return |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
711 // an empty character string with EOF = true. |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
712 eval_string = ""; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
713 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
714 if (retval.empty ()) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
715 eof = true; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
716 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
717 current_input_line = retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
718 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
719 return retval; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
720 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
721 |
581 | 722 // If the user simply hits return, this will produce an empty matrix. |
723 | |
2086 | 724 static octave_value_list |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
725 get_user_input (const octave_value_list& args, int nargout) |
529 | 726 { |
3100 | 727 octave_value_list retval; |
529 | 728 |
729 int nargin = args.length (); | |
730 | |
731 int read_as_string = 0; | |
732 | |
712 | 733 if (nargin == 2) |
529 | 734 read_as_string++; |
735 | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
736 std::string prompt = args(0).string_value (); |
4975 | 737 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
738 if (error_state) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
739 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
740 error ("input: unrecognized argument"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
741 return retval; |
4975 | 742 } |
743 | |
2095 | 744 flush_octave_stdout (); |
529 | 745 |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
746 octave_pager_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
747 octave_diary_stream::reset (); |
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
748 |
4565 | 749 octave_diary << prompt; |
750 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
751 std::string input_buf = interactive_input (prompt.c_str (), true); |
529 | 752 |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
753 if (! (error_state || input_buf.empty ())) |
529 | 754 { |
1799 | 755 if (! input_from_startup_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
756 command_history::add (input_buf); |
529 | 757 |
2927 | 758 size_t len = input_buf.length (); |
529 | 759 |
4565 | 760 octave_diary << input_buf; |
761 | |
762 if (input_buf[len - 1] != '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
763 octave_diary << "\n"; |
4565 | 764 |
529 | 765 if (len < 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
766 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
3772 | 767 |
768 if (read_as_string) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
769 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
770 // FIXME -- fix gnu_readline and octave_gets instead! |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
771 if (input_buf.length () == 1 && input_buf[0] == '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
772 retval(0) = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
773 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
774 retval(0) = input_buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
775 } |
529 | 776 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
777 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
778 int parse_status = 0; |
2900 | 779 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
780 retval = eval_string (input_buf, true, parse_status, nargout); |
3100 | 781 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
782 if (! Vdebugging && retval.length () == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
783 retval(0) = Matrix (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
784 } |
529 | 785 } |
786 else | |
787 error ("input: reading user-input failed!"); | |
788 | |
789 return retval; | |
790 } | |
791 | |
3100 | 792 DEFUN (input, args, nargout, |
3372 | 793 "-*- texinfo -*-\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
794 @deftypefn {Built-in Function} {@var{ans} =} input (@var{prompt})\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
795 @deftypefnx {Built-in Function} {@var{ans} =} input (@var{prompt}, \"s\")\n\ |
3372 | 796 Print a prompt and wait for user input. For example,\n\ |
797 \n\ | |
798 @example\n\ | |
799 input (\"Pick a number, any number! \")\n\ | |
800 @end example\n\ | |
801 \n\ | |
802 @noindent\n\ | |
803 prints the prompt\n\ | |
804 \n\ | |
805 @example\n\ | |
806 Pick a number, any number!\n\ | |
807 @end example\n\ | |
529 | 808 \n\ |
3372 | 809 @noindent\n\ |
810 and waits for the user to enter a value. The string entered by the user\n\ | |
811 is evaluated as an expression, so it may be a literal constant, a\n\ | |
812 variable name, or any other valid expression.\n\ | |
813 \n\ | |
814 Currently, @code{input} only returns one value, regardless of the number\n\ | |
815 of values produced by the evaluation of the expression.\n\ | |
816 \n\ | |
817 If you are only interested in getting a literal string value, you can\n\ | |
818 call @code{input} with the character string @code{\"s\"} as the second\n\ | |
819 argument. This tells Octave to return the string entered by the user\n\ | |
820 directly, without evaluating it first.\n\ | |
821 \n\ | |
822 Because there may be output waiting to be displayed by the pager, it is\n\ | |
823 a good idea to always call @code{fflush (stdout)} before calling\n\ | |
824 @code{input}. This will ensure that all pending output is written to\n\ | |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
825 the screen before your prompt.\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
826 @seealso{yes_or_no, kbhit}\n\ |
3372 | 827 @end deftypefn") |
529 | 828 { |
2086 | 829 octave_value_list retval; |
529 | 830 |
831 int nargin = args.length (); | |
832 | |
712 | 833 if (nargin == 1 || nargin == 2) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
834 retval = get_user_input (args, nargout); |
529 | 835 else |
5823 | 836 print_usage (); |
529 | 837 |
838 return retval; | |
839 } | |
840 | |
5640 | 841 bool |
842 octave_yes_or_no (const std::string& prompt) | |
843 { | |
844 std::string prompt_string = prompt + "(yes or no) "; | |
845 | |
846 while (1) | |
847 { | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
848 std::string input_buf = interactive_input (prompt_string, true); |
5640 | 849 |
850 if (input_buf == "yes") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
851 return true; |
5640 | 852 else if (input_buf == "no") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
853 return false; |
5640 | 854 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
855 message (0, "Please answer yes or no."); |
5640 | 856 } |
857 } | |
858 | |
859 DEFUN (yes_or_no, args, , | |
860 "-*- texinfo -*-\n\ | |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
861 @deftypefn {Built-in Function} {@var{ans} =} yes_or_no (\"@var{prompt}\")\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
862 Ask the user a yes-or-no question. Return logical true if the answer is yes\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
863 or false if the answer is no. Takes one argument, @var{prompt}, which is\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
864 the string to display when asking the question. @var{prompt} should end in\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
865 a space; @code{yes-or-no} adds the string @samp{(yes or no) } to it. The\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
866 user must confirm the answer with @key{RET} and can edit it until it has\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
867 been confirmed.\n\ |
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
868 @seealso{input}\n\ |
5640 | 869 @end deftypefn") |
870 { | |
871 octave_value retval; | |
872 | |
873 int nargin = args.length (); | |
874 | |
875 if (nargin == 0 || nargin == 1) | |
876 { | |
877 std::string prompt; | |
878 | |
879 if (nargin == 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
880 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
881 prompt = args(0).string_value (); |
5640 | 882 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
883 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
884 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
885 error ("yes_or_no: PROMPT must be a character string"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
886 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
887 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
888 } |
5640 | 889 |
890 retval = octave_yes_or_no (prompt); | |
891 } | |
892 else | |
5823 | 893 print_usage (); |
5640 | 894 |
895 return retval; | |
896 } | |
897 | |
3707 | 898 octave_value |
899 do_keyboard (const octave_value_list& args) | |
900 { | |
901 octave_value retval; | |
902 | |
903 int nargin = args.length (); | |
904 | |
905 assert (nargin == 0 || nargin == 1); | |
906 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
907 unwind_protect frame; |
3707 | 908 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
909 frame.add_fcn (command_history::ignore_entries, |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
910 command_history::ignoring_entries ()); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
911 |
3707 | 912 command_history::ignore_entries (false); |
913 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
914 frame.protect_var (Vdebugging); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
915 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
916 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
917 octave_call_stack::current_frame ()); |
3707 | 918 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
919 // FIXME -- probably we just want to print one line, not the |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
920 // entire statement, which might span many lines... |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
921 // |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
922 // tree_print_code tpc (octave_stdout); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
923 // stmt.accept (tpc); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
924 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
925 Vdebugging = true; |
3707 | 926 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
927 std::string prompt = "debug> "; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
928 if (nargin > 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
929 prompt = args(0).string_value (); |
4233 | 930 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
931 if (! error_state) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7758
diff
changeset
|
932 get_debug_input (prompt); |
3707 | 933 |
934 return retval; | |
935 } | |
936 | |
1957 | 937 DEFUN (keyboard, args, , |
3372 | 938 "-*- texinfo -*-\n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
939 @deftypefn {Built-in Function} {} keyboard ()\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
940 @deftypefnx {Built-in Function} {} keyboard (\"@var{prompt}\")\n\ |
3372 | 941 This function is normally used for simple debugging. When the\n\ |
942 @code{keyboard} function is executed, Octave prints a prompt and waits\n\ | |
943 for user input. The input strings are then evaluated and the results\n\ | |
944 are printed. This makes it possible to examine the values of variables\n\ | |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
945 within a function, and to assign new values if necessary. To leave the\n\ |
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
946 prompt and return to normal execution type @samp{return} or @samp{dbcont}.\n\ |
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
947 The @code{keyboard} function does not return an exit status.\n\ |
529 | 948 \n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
949 If @code{keyboard} is invoked without arguments, a default prompt of\n\ |
3372 | 950 @samp{debug> } is used.\n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
951 @seealso{dbcont, dbquit}\n\ |
3372 | 952 @end deftypefn") |
529 | 953 { |
2086 | 954 octave_value_list retval; |
529 | 955 |
956 int nargin = args.length (); | |
957 | |
712 | 958 if (nargin == 0 || nargin == 1) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
959 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
960 unwind_protect frame; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
961 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
962 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
963 octave_call_stack::current_frame ()); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
964 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
965 // Skip the frame assigned to the keyboard function. |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
966 octave_call_stack::goto_frame_relative (0); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
967 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
968 tree_evaluator::debug_mode = true; |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
969 |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
970 tree_evaluator::current_frame = octave_call_stack::current_frame (); |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
971 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
972 do_keyboard (args); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
973 } |
529 | 974 else |
5823 | 975 print_usage (); |
529 | 976 |
977 return retval; | |
978 } | |
979 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
980 DEFUN (echo, args, , |
3332 | 981 "-*- texinfo -*-\n\ |
11547 | 982 @deftypefn {Command} {} echo options\n\ |
3332 | 983 Control whether commands are displayed as they are executed. Valid\n\ |
984 options are:\n\ | |
1588 | 985 \n\ |
3332 | 986 @table @code\n\ |
987 @item on\n\ | |
988 Enable echoing of commands as they are executed in script files.\n\ | |
989 \n\ | |
990 @item off\n\ | |
991 Disable echoing of commands as they are executed in script files.\n\ | |
1588 | 992 \n\ |
3332 | 993 @item on all\n\ |
994 Enable echoing of commands as they are executed in script files and\n\ | |
995 functions.\n\ | |
1588 | 996 \n\ |
3332 | 997 @item off all\n\ |
998 Disable echoing of commands as they are executed in script files and\n\ | |
999 functions.\n\ | |
1000 @end table\n\ | |
1001 \n\ | |
1002 @noindent\n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1003 With no arguments, @code{echo} toggles the current echo state.\n\ |
11547 | 1004 @end deftypefn") |
1588 | 1005 { |
2086 | 1006 octave_value_list retval; |
1588 | 1007 |
1755 | 1008 int argc = args.length () + 1; |
1009 | |
1968 | 1010 string_vector argv = args.make_argv ("echo"); |
1755 | 1011 |
1012 if (error_state) | |
1013 return retval; | |
1588 | 1014 |
1015 switch (argc) | |
1016 { | |
1017 case 1: | |
1018 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1019 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1020 || (Vecho_executing_commands & ECHO_FUNCTIONS)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1021 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1022 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1023 Vecho_executing_commands = ECHO_SCRIPTS; |
1588 | 1024 } |
1025 break; | |
1026 | |
1027 case 2: | |
1028 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1029 std::string arg = argv[1]; |
1755 | 1030 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1031 if (arg == "on") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1032 Vecho_executing_commands = ECHO_SCRIPTS; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1033 else if (arg == "off") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1034 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1035 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1036 print_usage (); |
1588 | 1037 } |
1038 break; | |
1039 | |
1040 case 3: | |
1041 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1042 std::string arg = argv[1]; |
1755 | 1043 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1044 if (arg == "on" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1045 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1046 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1047 Vecho_executing_commands = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1048 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1049 else if (arg == "off" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1050 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1051 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1052 print_usage (); |
1588 | 1053 } |
1054 break; | |
1055 | |
1056 default: | |
5823 | 1057 print_usage (); |
1588 | 1058 break; |
1059 } | |
1060 | |
1061 return retval; | |
1062 } | |
1063 | |
2234 | 1064 DEFUN (completion_matches, args, nargout, |
3332 | 1065 "-*- texinfo -*-\n\ |
1066 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ | |
1067 Generate possible completions given @var{hint}.\n\ | |
2299 | 1068 \n\ |
1069 This function is provided for the benefit of programs like Emacs which\n\ | |
3332 | 1070 might be controlling Octave and handling user input. The current\n\ |
1071 command number is not incremented when this function is called. This is\n\ | |
1072 a feature, not a bug.\n\ | |
3333 | 1073 @end deftypefn") |
2234 | 1074 { |
2281 | 1075 octave_value retval; |
2234 | 1076 |
1077 int nargin = args.length (); | |
1078 | |
1079 if (nargin == 1) | |
1080 { | |
3523 | 1081 std::string hint = args(0).string_value (); |
2234 | 1082 |
1083 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1084 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1085 int n = 32; |
2234 | 1086 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1087 string_vector list (n); |
2234 | 1088 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1089 int k = 0; |
2234 | 1090 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1091 for (;;) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1092 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1093 std::string cmd = generate_completion (hint, k); |
2234 | 1094 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1095 if (! cmd.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1096 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1097 if (k == n) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1098 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1099 n *= 2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1100 list.resize (n); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1101 } |
2235 | 1102 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1103 list[k++] = cmd; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1104 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1105 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1106 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1107 list.resize (k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1108 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1109 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1110 } |
2234 | 1111 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1112 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1113 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1114 if (! list.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1115 retval = list; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1116 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1117 retval = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1118 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1119 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1120 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1121 // We don't use string_vector::list_in_columns here |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1122 // because it will be easier for Emacs if the names |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1123 // appear in a single column. |
2235 | 1124 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1125 int len = list.length (); |
2234 | 1126 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1127 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1128 octave_stdout << list[i] << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1129 } |
2299 | 1130 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1131 octave_completion_matches_called = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1132 } |
2234 | 1133 } |
1134 else | |
5823 | 1135 print_usage (); |
2234 | 1136 |
1137 return retval; | |
1138 } | |
1139 | |
3189 | 1140 DEFUN (read_readline_init_file, args, , |
3448 | 1141 "-*- texinfo -*-\n\ |
1142 @deftypefn {Built-in Function} {} read_readline_init_file (@var{file})\n\ | |
7007 | 1143 Read the readline library initialization file @var{file}. If\n\ |
3448 | 1144 @var{file} is omitted, read the default initialization file (normally\n\ |
6615 | 1145 @file{~/.inputrc}).\n\ |
1146 \n\ | |
1147 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ | |
1148 for details.\n\ | |
3448 | 1149 @end deftypefn") |
3189 | 1150 { |
1151 octave_value_list retval; | |
1152 | |
1153 int nargin = args.length (); | |
1154 | |
1155 if (nargin == 0) | |
1156 command_editor::read_init_file (); | |
1157 else if (nargin == 1) | |
1158 { | |
5872 | 1159 std::string file = args(0).string_value (); |
3189 | 1160 |
1161 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1162 command_editor::read_init_file (file); |
3189 | 1163 } |
1164 else | |
5823 | 1165 print_usage (); |
3189 | 1166 |
1167 return retval; | |
1168 } | |
1169 | |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1170 DEFUN (re_read_readline_init_file, args, , |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1171 "-*- texinfo -*-\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1172 @deftypefn {Built-in Function} {} re_read_readline_init_file ()\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1173 Re-read the last readline library initialization file that was read.\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1174 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1175 for details.\n\ |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1176 @end deftypefn") |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1177 { |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1178 octave_value_list retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1179 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1180 if (args.length () == 0) |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1181 command_editor::re_read_init_file (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1182 else |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1183 print_usage (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1184 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1185 return retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1186 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1187 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1188 typedef std::map<std::string, octave_value> hook_fcn_map_type; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1189 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1190 static hook_fcn_map_type hook_fcn_map; |
3498 | 1191 |
4802 | 1192 static int |
3519 | 1193 input_event_hook (void) |
3498 | 1194 { |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1195 hook_fcn_map_type::iterator p = hook_fcn_map.begin (); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1196 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1197 while (p != hook_fcn_map.end ()) |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1198 { |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1199 std::string hook_fcn = p->first; |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1200 octave_value user_data = p->second; |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1201 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1202 hook_fcn_map_type::iterator q = p++; |
11367
b2191ebea12f
don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1203 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1204 if (is_valid_function (hook_fcn)) |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1205 { |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1206 if (user_data.is_defined ()) |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1207 feval (hook_fcn, user_data, 0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1208 else |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1209 feval (hook_fcn, octave_value_list (), 0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1210 } |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1211 else |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1212 hook_fcn_map.erase (q); |
4526 | 1213 } |
1214 | |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1215 if (hook_fcn_map.empty ()) |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
1216 command_editor::remove_event_hook (input_event_hook); |
16152
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1217 |
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1218 return 0; |
3498 | 1219 } |
1220 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1221 DEFUN (add_input_event_hook, args, , |
3498 | 1222 "-*- texinfo -*-\n\ |
12573
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1223 @deftypefn {Built-in Function} {} add_input_event_hook (@var{fcn})\n\ |
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1224 @deftypefnx {Built-in Function} {} add_input_event_hook (@var{fcn}, @var{data})\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1225 Add the named function @var{fcn} to the list of functions to call\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1226 periodically when Octave is waiting for input. The function should\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1227 have the form\n\ |
10840 | 1228 \n\ |
3498 | 1229 @example\n\ |
1230 @var{fcn} (@var{data})\n\ | |
1231 @end example\n\ | |
1232 \n\ | |
1233 If @var{data} is omitted, Octave calls the function without any\n\ | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1234 arguments.\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1235 @seealso{remove_input_event_hook}\n\ |
3498 | 1236 @end deftypefn") |
1237 { | |
1238 octave_value_list retval; | |
1239 | |
1240 int nargin = args.length (); | |
1241 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1242 if (nargin == 1 || nargin == 2) |
3498 | 1243 { |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1244 octave_value user_data; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1245 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1246 if (nargin == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1247 user_data = args(1); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1248 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1249 std::string hook_fcn = args(0).string_value (); |
3498 | 1250 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1251 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1252 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1253 if (hook_fcn_map.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1254 command_editor::add_event_hook (input_event_hook); |
3498 | 1255 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1256 hook_fcn_map[hook_fcn] = user_data; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1257 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1258 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1259 error ("add_input_event_hook: expecting string as first arg"); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1260 } |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1261 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1262 print_usage (); |
3498 | 1263 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1264 return retval; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1265 } |
3498 | 1266 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1267 DEFUN (remove_input_event_hook, args, , |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1268 "-*- texinfo -*-\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1269 @deftypefn {Built-in Function} {} remove_input_event_hook (@var{fcn})\n\ |
12573
232a90612254
Add new section on parsing to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1270 Remove the named function @var{fcn} from the list of functions to call\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1271 periodically when Octave is waiting for input.\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1272 @seealso{add_input_event_hook}\n\ |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1273 @end deftypefn") |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1274 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1275 octave_value_list retval; |
3498 | 1276 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1277 int nargin = args.length (); |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1278 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1279 if (nargin == 1) |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1280 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1281 std::string hook_fcn = args(0).string_value (); |
3498 | 1282 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1283 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1284 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1285 hook_fcn_map_type::iterator p = hook_fcn_map.find (hook_fcn); |
3498 | 1286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1287 if (p != hook_fcn_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1288 hook_fcn_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1289 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1290 error ("remove_input_event_hook: %s not found in list", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1291 hook_fcn.c_str ()); |
3498 | 1292 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1293 if (hook_fcn_map.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1294 command_editor::remove_event_hook (input_event_hook); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1295 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1296 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1297 error ("remove_input_event_hook: expecting string as first arg"); |
3498 | 1298 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1299 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1300 print_usage (); |
3498 | 1301 |
1302 return retval; | |
1303 } | |
1304 | |
5794 | 1305 DEFUN (PS1, args, nargout, |
1306 "-*- texinfo -*-\n\ | |
10840 | 1307 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ |
5794 | 1308 @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1309 @deftypefnx {Built-in Function} {} PS1 (@var{new_val}, \"local\")\n\ |
5794 | 1310 Query or set the primary prompt string. When executing interactively,\n\ |
1311 Octave displays the primary prompt when it is ready to read a command.\n\ | |
3332 | 1312 \n\ |
5794 | 1313 The default value of the primary prompt string is @code{\"\\s:\\#> \"}.\n\ |
1314 To change it, use a command like\n\ | |
3332 | 1315 \n\ |
1316 @example\n\ | |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1317 PS1 (\"\\\\u@@\\\\H> \")\n\ |
3332 | 1318 @end example\n\ |
1319 \n\ | |
1320 @noindent\n\ | |
1321 which will result in the prompt @samp{boris@@kremvax> } for the user\n\ | |
1322 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ | |
5794 | 1323 backslashes are required to enter a backslash into a double-quoted\n\ |
11413
ae0deb52af27
Correct use of xref macro to prevent Texinfo warning.
Rik <octave@nomad.inbox5.com>
parents:
11405
diff
changeset
|
1324 character string. @xref{Strings}.\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1325 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1326 You can also use ANSI escape sequences if your terminal supports them.\n\ |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11572
diff
changeset
|
1327 This can be useful for coloring the prompt. For example,\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1328 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1329 @example\n\ |
14880
9e5df4d6cefa
doc: typo on PS1 documentation example
Carnë Draug <carandraug+dev@gmail.com>
parents:
14138
diff
changeset
|
1330 PS1 (\"\\\\[\\\\033[01;31m\\\\]\\\\s:\\\\#> \\\\[\\\\033[0m\\\\]\")\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1331 @end example\n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1332 \n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
1333 @noindent\n\ |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11572
diff
changeset
|
1334 will give the default Octave prompt a red coloring.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1335 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1336 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1337 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1338 variable value is restored when exiting the function.\n\ |
6373 | 1339 @seealso{PS2, PS4}\n\ |
5794 | 1340 @end deftypefn") |
1341 { | |
1342 return SET_INTERNAL_VARIABLE (PS1); | |
1343 } | |
2181 | 1344 |
5794 | 1345 DEFUN (PS2, args, nargout, |
1346 "-*- texinfo -*-\n\ | |
10840 | 1347 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ |
5794 | 1348 @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1349 @deftypefnx {Built-in Function} {} PS2 (@var{new_val}, \"local\")\n\ |
5794 | 1350 Query or set the secondary prompt string. The secondary prompt is\n\ |
1351 printed when Octave is expecting additional input to complete a\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1352 command. For example, if you are typing a @code{for} loop that spans several\n\ |
5794 | 1353 lines, Octave will print the secondary prompt at the beginning of\n\ |
1354 each line after the first. The default value of the secondary prompt\n\ | |
1355 string is @code{\"> \"}.\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1356 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1357 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1358 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1359 variable value is restored when exiting the function.\n\ |
5794 | 1360 @seealso{PS1, PS4}\n\ |
1361 @end deftypefn") | |
1362 { | |
1363 return SET_INTERNAL_VARIABLE (PS2); | |
1364 } | |
2181 | 1365 |
5794 | 1366 DEFUN (PS4, args, nargout, |
1367 "-*- texinfo -*-\n\ | |
10840 | 1368 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ |
5794 | 1369 @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1370 @deftypefnx {Built-in Function} {} PS4 (@var{new_val}, \"local\")\n\ |
5794 | 1371 Query or set the character string used to prefix output produced\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1372 when echoing commands is enabled.\n\ |
6620 | 1373 The default value is @code{\"+ \"}.\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1374 @xref{Diary and Echo Commands}, for a description of echoing commands.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1375 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1376 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1377 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1378 variable value is restored when exiting the function.\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1379 @seealso{echo, echo_executing_commands, PS1, PS2}\n\ |
5794 | 1380 @end deftypefn") |
1381 { | |
1382 return SET_INTERNAL_VARIABLE (PS4); | |
1383 } | |
2181 | 1384 |
5794 | 1385 DEFUN (completion_append_char, args, nargout, |
1386 "-*- texinfo -*-\n\ | |
10840 | 1387 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ |
5794 | 1388 @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1389 @deftypefnx {Built-in Function} {} completion_append_char (@var{new_val}, \"local\")\n\ |
5794 | 1390 Query or set the internal character variable that is appended to\n\ |
1391 successful command-line completion attempts. The default\n\ | |
3332 | 1392 value is @code{\" \"} (a single space).\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1393 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1394 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1395 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1396 variable value is restored when exiting the function.\n\ |
5794 | 1397 @end deftypefn") |
1398 { | |
1399 return SET_INTERNAL_VARIABLE (completion_append_char); | |
1400 } | |
3019 | 1401 |
5794 | 1402 DEFUN (echo_executing_commands, args, nargout, |
1403 "-*- texinfo -*-\n\ | |
10840 | 1404 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ |
5794 | 1405 @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1406 @deftypefnx {Built-in Function} {} echo_executing_commands (@var{new_val}, \"local\")\n\ |
5794 | 1407 Query or set the internal variable that controls the echo state.\n\ |
1408 It may be the sum of the following values:\n\ | |
3332 | 1409 \n\ |
1410 @table @asis\n\ | |
1411 @item 1\n\ | |
1412 Echo commands read from script files.\n\ | |
1413 \n\ | |
1414 @item 2\n\ | |
1415 Echo commands from functions.\n\ | |
1416 \n\ | |
1417 @item 4\n\ | |
1418 Echo commands read from command line.\n\ | |
1419 @end table\n\ | |
1420 \n\ | |
1421 More than one state can be active at once. For example, a value of 3 is\n\ | |
1422 equivalent to the command @kbd{echo on all}.\n\ | |
1423 \n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1424 The value of @code{echo_executing_commands} may be set by the @kbd{echo}\n\ |
10840 | 1425 command or the command line option @option{--echo-commands}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1426 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1427 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1428 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1429 variable value is restored when exiting the function.\n\ |
5794 | 1430 @end deftypefn") |
1431 { | |
1432 return SET_INTERNAL_VARIABLE (echo_executing_commands); | |
2181 | 1433 } |
1434 | |
6257 | 1435 DEFUN (__request_drawnow__, args, , |
1436 "-*- texinfo -*-\n\ | |
10840 | 1437 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ |
6257 | 1438 @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ |
6945 | 1439 Undocumented internal function.\n\ |
6257 | 1440 @end deftypefn") |
1441 { | |
1442 octave_value retval; | |
1443 | |
1444 int nargin = args.length (); | |
1445 | |
1446 if (nargin == 0) | |
1447 Vdrawnow_requested = true; | |
1448 else if (nargin == 1) | |
1449 Vdrawnow_requested = args(0).bool_value (); | |
1450 else | |
1451 print_usage (); | |
1452 | |
1453 return retval; | |
1454 } | |
1455 | |
7294 | 1456 DEFUN (__gud_mode__, args, , |
1457 "-*- texinfo -*-\n\ | |
1458 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ | |
1459 Undocumented internal function.\n\ | |
1460 @end deftypefn") | |
1461 { | |
1462 octave_value retval; | |
1463 | |
1464 int nargin = args.length (); | |
1465 | |
1466 if (nargin == 0) | |
1467 retval = Vgud_mode; | |
1468 else if (nargin == 1) | |
1469 Vgud_mode = args(0).bool_value (); | |
1470 else | |
1471 print_usage (); | |
1472 | |
1473 return retval; | |
1474 } | |
1475 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1476 DEFUN (filemarker, args, nargout, |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1477 "-*- texinfo -*-\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12179
diff
changeset
|
1478 @deftypefn {Built-in Function} {@var{val} =} filemarker ()\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12179
diff
changeset
|
1479 @deftypefnx {Built-in Function} {} filemarker (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1480 @deftypefnx {Built-in Function} {} filemarker (@var{new_val}, \"local\")\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
1481 Query or set the character used to separate filename from the\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
1482 the subfunction names contained within the file. This can be used in\n\ |
10840 | 1483 a generic manner to interact with subfunctions. For example,\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1484 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1485 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1486 help ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1487 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1488 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1489 @noindent\n\ |
14852
53d2c3598d33
doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1490 returns the help string associated with the subfunction @code{mysubfunc}\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
1491 of the function @code{myfunc}. Another use of @code{filemarker} is when\n\ |
14852
53d2c3598d33
doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1492 debugging it allows easier placement of breakpoints within subfunctions.\n\ |
10840 | 1493 For example,\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1494 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1495 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1496 dbstop ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1497 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1498 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1499 @noindent\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1500 will set a breakpoint at the first line of the subfunction @code{mysubfunc}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1501 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1502 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1503 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1504 variable value is restored when exiting the function.\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1505 @end deftypefn") |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1506 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1507 char tmp = Vfilemarker; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1508 octave_value retval = SET_INTERNAL_VARIABLE (filemarker); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1509 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1510 // The character passed must not be a legal character for a function name |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1511 if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_')) |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1512 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1513 Vfilemarker = tmp; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1514 error ("filemarker: character can not be a valid character for a function name"); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1515 } |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1516 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1517 return retval; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1518 } |