Mercurial > octave-nkf
annotate libinterp/corefcn/input.cc @ 19629:be7ac98fab43 gui-release
strip trailing whitespace from most source files
* NEWS, etc/NEWS.3, libgui/graphics/Backend.h,
libgui/graphics/ButtonControl.h, libgui/graphics/EditControl.cc,
libgui/graphics/Object.h, libgui/graphics/QtHandlesUtils.cc,
libgui/graphics/ToolBarButton.h, libgui/graphics/__init_qt__.cc,
libgui/graphics/gl-select.cc,
libgui/qterminal/libqterminal/unix/TerminalView.cpp,
libgui/qterminal/libqterminal/unix/TerminalView.h,
libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp,
libgui/src/m-editor/file-editor-tab.cc,
libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/file-editor.h,
libgui/src/m-editor/octave-qscintilla.cc,
libgui/src/settings-dialog.cc, libgui/src/shortcut-manager.cc,
libgui/src/workspace-view.cc, libinterp/corefcn/graphics.cc,
libinterp/corefcn/input.cc, libinterp/parse-tree/pt-unop.cc,
liboctave/array/dSparse.h, scripts/pkg/pkg.m,
scripts/polynomial/polyeig.m, test/io.tst: Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 09:43:29 -0500 |
parents | c1ce43276b86 |
children | 0e1f5a750d00 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
3 Copyright (C) 1993-2013 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" |
16381
f33dcbd6a005
move hook_function classes to separate file
John W. Eaton <jwe@octave.org>
parents:
16378
diff
changeset
|
52 #include "hook-fcn.h" |
1 | 53 #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
|
54 #include "lex.h" |
5832 | 55 #include "load-path.h" |
16416
169f71c9d9c8
use octave_link instead of hook functions in input.cc
John W. Eaton <jwe@octave.org>
parents:
16395
diff
changeset
|
56 #include "octave-link.h" |
1352 | 57 #include "oct-map.h" |
1742 | 58 #include "oct-hist.h" |
1670 | 59 #include "toplev.h" |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
60 #include "octave-link.h" |
1755 | 61 #include "oct-obj.h" |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
62 #include "ov-fcn-handle.h" |
1 | 63 #include "pager.h" |
529 | 64 #include "parse.h" |
1352 | 65 #include "pathlen.h" |
3772 | 66 #include "pt.h" |
1755 | 67 #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
|
68 #include "pt-eval.h" |
3805 | 69 #include "pt-stmt.h" |
1352 | 70 #include "sighandlers.h" |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
71 #include "symtab.h" |
1114 | 72 #include "sysdep.h" |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
73 #include "toplev.h" |
3098 | 74 #include "unwind-prot.h" |
1352 | 75 #include "utils.h" |
76 #include "variables.h" | |
529 | 77 |
2181 | 78 // Primary prompt string. |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
79 static std::string VPS1; |
2181 | 80 |
81 // Secondary prompt string. | |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
82 static std::string VPS2; |
2181 | 83 |
84 // String printed before echoed input (enabled by --echo-input). | |
5794 | 85 std::string VPS4 = "+ "; |
2181 | 86 |
3019 | 87 // Echo commands as they are executed? |
88 // | |
89 // 1 ==> echo commands read from script files | |
90 // 2 ==> echo commands from functions | |
91 // 4 ==> echo commands read from command line | |
92 // | |
93 // more than one state can be active at once. | |
5794 | 94 int Vecho_executing_commands = ECHO_OFF; |
3019 | 95 |
3165 | 96 // The time we last printed a prompt. |
5832 | 97 octave_time Vlast_prompt_time = 0.0; |
3165 | 98 |
2181 | 99 // Character to append after successful command-line completion attempts. |
5794 | 100 static char Vcompletion_append_char = ' '; |
2181 | 101 |
3019 | 102 // TRUE means this is an interactive shell. |
103 bool interactive = false; | |
1 | 104 |
3019 | 105 // TRUE means the user forced this shell to be interactive (-i). |
106 bool forced_interactive = false; | |
1 | 107 |
3804 | 108 // TRUE after a call to completion_matches. |
2299 | 109 bool octave_completion_matches_called = false; |
110 | |
6257 | 111 // TRUE if the plotting system has requested a call to drawnow at |
112 // the next user prompt. | |
7409 | 113 bool Vdrawnow_requested = false; |
6257 | 114 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
115 // TRUE if we are in debugging mode. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
116 bool Vdebugging = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
117 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
118 // 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
|
119 // that we can repeat the previous command if the user just types RET. |
16336
0ce49f9fb171
"\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents:
16288
diff
changeset
|
120 static std::string last_debugging_command = "\n"; |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
121 |
7294 | 122 // TRUE if we are running in the Emacs GUD mode. |
123 static bool Vgud_mode = false; | |
124 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
125 // 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
|
126 char Vfilemarker = '>'; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
127 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
128 static hook_function_list input_event_hook_functions; |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
129 |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
130 // For octave_quit. |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
131 void |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
132 remove_input_event_hook_functions (void) |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
133 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
134 input_event_hook_functions.clear (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
135 } |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
136 |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
137 void |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
138 set_default_prompts (void) |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
139 { |
18037
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
140 // Use literal "octave" instead of "\\s" to avoid setting the prompt |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
141 // to "octave.exe" or "octave-gui", etc. |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
142 |
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
143 VPS1 = "octave:\\#> "; |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
144 VPS2 = "> "; |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
145 VPS4 = "+ "; |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
146 |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
147 octave_link::set_default_prompts (VPS1, VPS2, VPS4); |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
148 } |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
149 |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16524
diff
changeset
|
150 void |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
151 octave_base_reader::do_input_echo (const std::string& input_string) const |
1044 | 152 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
153 int do_echo = reading_script_file () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 ? (Vecho_executing_commands & ECHO_SCRIPTS) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; |
1588 | 156 |
157 if (do_echo) | |
1044 | 158 { |
1403 | 159 if (forced_interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
160 { |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
161 if (pflag > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
162 octave_stdout << command_editor::decode_prompt_string (VPS1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
163 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
164 octave_stdout << command_editor::decode_prompt_string (VPS2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
165 } |
1403 | 166 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
167 octave_stdout << command_editor::decode_prompt_string (VPS4); |
1044 | 168 |
1755 | 169 if (! input_string.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
170 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
171 octave_stdout << input_string; |
1755 | 172 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
173 if (input_string[input_string.length () - 1] != '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
174 octave_stdout << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
175 } |
1044 | 176 } |
177 } | |
178 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
179 static std::string |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
180 gnu_readline (const std::string& s, bool& eof) |
1822 | 181 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
182 octave_quit (); |
5142 | 183 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
184 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
185 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
186 std::string retval = command_editor::readline (s, eof); |
19629
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19413
diff
changeset
|
187 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
188 if (! eof && retval.empty ()) |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
189 retval = "\n"; |
1822 | 190 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
191 if (command_editor::interrupt (false)) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
192 retval = ""; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
193 |
1822 | 194 return retval; |
195 } | |
581 | 196 |
6257 | 197 static inline std::string |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
198 interactive_input (const std::string& s, bool& eof) |
6257 | 199 { |
200 Vlast_prompt_time.stamp (); | |
201 | |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
202 if (Vdrawnow_requested && (interactive || forced_interactive)) |
6257 | 203 { |
204 feval ("drawnow"); | |
205 | |
6367 | 206 flush_octave_stdout (); |
207 | |
6305 | 208 // We set Vdrawnow_requested to false even if there is an error |
209 // in drawnow so that the error doesn't reappear at every prompt. | |
210 | |
6257 | 211 Vdrawnow_requested = false; |
6305 | 212 |
213 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
214 return "\n"; |
6257 | 215 } |
216 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
217 return gnu_readline (s, eof); |
6257 | 218 } |
219 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
220 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
221 octave_base_reader::octave_gets (bool& eof) |
1 | 222 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
223 octave_quit (); |
5142 | 224 |
16097
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
225 eof = false; |
2f4fa62089b3
improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
226 |
3523 | 227 std::string retval; |
1 | 228 |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
229 // Process pre input event hook function prior to flushing output and |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
230 // printing the prompt. |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
231 |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
232 if (interactive || forced_interactive) |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
233 { |
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
234 if (! Vdebugging) |
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
235 octave_link::exit_debugger_event (); |
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
236 |
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
237 octave_link::pre_input_event (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
238 |
16524
6a8e63dadfad
provide octave_link::set_workspace function with default values
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
239 octave_link::set_workspace (); |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
240 } |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
241 |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
242 bool history_skip_auto_repeated_debugging_command = false; |
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
243 |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
244 std::string ps = (pflag > 0) ? VPS1 : VPS2; |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
245 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
246 std::string prompt = command_editor::decode_prompt_string (ps); |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
247 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
248 pipe_handler_error_count = 0; |
1755 | 249 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
250 flush_octave_stdout (); |
2618 | 251 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
252 octave_pager_stream::reset (); |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
253 octave_diary_stream::reset (); |
1 | 254 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
255 octave_diary << prompt; |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
256 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
257 retval = interactive_input (prompt, eof); |
581 | 258 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
259 // There is no need to update the load_path cache if there is no |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
260 // user input. |
16336
0ce49f9fb171
"\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents:
16288
diff
changeset
|
261 if (retval != "\n" |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
262 && retval.find_first_not_of (" \t\n\r") != std::string::npos) |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
263 { |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
264 load_path::update (); |
8841
c74389115610
auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents:
8749
diff
changeset
|
265 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
266 if (Vdebugging) |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
267 last_debugging_command = retval; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
268 else |
16336
0ce49f9fb171
"\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents:
16288
diff
changeset
|
269 last_debugging_command = "\n"; |
1 | 270 } |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
271 else if (Vdebugging) |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
272 { |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
273 retval = last_debugging_command; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
274 history_skip_auto_repeated_debugging_command = true; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
275 } |
1 | 276 |
16336
0ce49f9fb171
"\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents:
16288
diff
changeset
|
277 if (retval != "\n") |
1 | 278 { |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
279 if (! history_skip_auto_repeated_debugging_command) |
17215
7c06875c2dcc
Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents:
17214
diff
changeset
|
280 { |
17219
33ce8c381f2c
make history widget respect history_control settings (bug #39728)
Torsten <ttl@justmail.de>
parents:
17215
diff
changeset
|
281 if (command_history::add (retval)) |
17215
7c06875c2dcc
Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents:
17214
diff
changeset
|
282 octave_link::append_history (retval); |
7c06875c2dcc
Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents:
17214
diff
changeset
|
283 } |
1 | 284 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
285 octave_diary << retval; |
3176 | 286 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
287 if (retval[retval.length () - 1] != '\n') |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
288 octave_diary << "\n"; |
581 | 289 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
290 do_input_echo (retval); |
1 | 291 } |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
292 else |
3176 | 293 octave_diary << "\n"; |
9476 | 294 |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
295 // Process post input event hook function after the internal history |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
296 // list has been updated. |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
297 |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
298 if (interactive || forced_interactive) |
16433
2c8860d563e5
fix incorrect call to octave_link::pre_input_event
John W. Eaton <jwe@octave.org>
parents:
16431
diff
changeset
|
299 octave_link::post_input_event (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
300 |
1822 | 301 return retval; |
1 | 302 } |
303 | |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
304 bool |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
305 octave_base_reader::reading_fcn_file (void) const |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
306 { |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
307 return lexer ? lexer->reading_fcn_file : false; |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
308 } |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
309 |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
310 bool |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
311 octave_base_reader::reading_classdef_file (void) const |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
312 { |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
313 return lexer ? lexer->reading_classdef_file : false; |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
314 } |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
315 |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
316 bool |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
317 octave_base_reader::reading_script_file (void) const |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
318 { |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
319 return lexer ? lexer->reading_script_file : false; |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
320 } |
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
321 |
581 | 322 // Fix things up so that input can come from the standard input. This |
323 // may need to become much more complicated, which is why it's in a | |
324 // separate function. | |
325 | |
1 | 326 FILE * |
327 get_input_from_stdin (void) | |
328 { | |
2927 | 329 command_editor::set_input_stream (stdin); |
330 return command_editor::get_input_stream (); | |
1 | 331 } |
332 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
333 // FIXME: make this generate file names when appropriate. |
2921 | 334 |
2247 | 335 static string_vector |
3523 | 336 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
|
337 std::string& hint) |
1280 | 338 { |
2247 | 339 string_vector names; |
1280 | 340 |
2921 | 341 prefix = ""; |
1280 | 342 |
4604 | 343 if (looks_like_struct (text)) |
1430 | 344 names = generate_struct_completions (text, prefix, hint); |
345 else | |
2247 | 346 names = make_name_list (); |
1280 | 347 |
2944 | 348 // Sort and remove duplicates. |
2348 | 349 |
8503
8ba2ee57c594
remove qsort in favor of sort
Jaroslav Hajek <highegg@gmail.com>
parents:
8447
diff
changeset
|
350 names.sort (true); |
2348 | 351 |
1280 | 352 return names; |
353 } | |
354 | |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
355 static bool |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
356 is_completing_dirfns (void) |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
357 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
358 static std::string dirfns_commands[] = {"cd", "ls"}; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
359 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
|
360 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
361 bool retval = false; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
362 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
363 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
|
364 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
365 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
|
366 { |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
367 int index = line.find (dirfns_commands[i] + " "); |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
368 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
369 if (index == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
370 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
371 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
372 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
373 } |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
374 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
375 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
376 return retval; |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
377 } |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
378 |
3536 | 379 static std::string |
3523 | 380 generate_completion (const std::string& text, int state) |
1280 | 381 { |
3523 | 382 std::string retval; |
2944 | 383 |
3523 | 384 static std::string prefix; |
385 static std::string hint; | |
1280 | 386 |
2921 | 387 static size_t hint_len = 0; |
1280 | 388 |
1 | 389 static int list_index = 0; |
2921 | 390 static int name_list_len = 0; |
4604 | 391 static int name_list_total_len = 0; |
2247 | 392 static string_vector name_list; |
4604 | 393 static string_vector file_name_list; |
1 | 394 |
1280 | 395 static int matches = 0; |
1 | 396 |
397 if (state == 0) | |
398 { | |
399 list_index = 0; | |
400 | |
2921 | 401 prefix = ""; |
1280 | 402 |
2921 | 403 hint = text; |
1280 | 404 |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
405 // 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
|
406 // file/directory operation. |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
407 |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
408 if (is_completing_dirfns ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
409 name_list = string_vector (); |
9485
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
410 else |
3cee58bf4acf
selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
411 name_list = generate_possible_completions (text, prefix, hint); |
1280 | 412 |
2921 | 413 name_list_len = name_list.length (); |
414 | |
4604 | 415 file_name_list = command_editor::generate_filename_completions (text); |
416 | |
417 name_list.append (file_name_list); | |
418 | |
419 name_list_total_len = name_list.length (); | |
420 | |
2921 | 421 hint_len = hint.length (); |
1280 | 422 |
423 matches = 0; | |
2247 | 424 |
2921 | 425 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
|
426 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
|
427 matches++; |
1 | 428 } |
429 | |
4604 | 430 if (name_list_total_len > 0 && matches > 0) |
1 | 431 { |
4604 | 432 while (list_index < name_list_total_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
433 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
434 std::string name = name_list[list_index]; |
2247 | 435 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
436 list_index++; |
2247 | 437 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
438 if (hint == name.substr (0, hint_len)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
439 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
440 if (list_index <= name_list_len && ! prefix.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
441 retval = prefix + "." + name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
442 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
443 retval = name; |
1280 | 444 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
445 // FIXME: looks_like_struct is broken for now, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
446 // so it always returns false. |
4179 | 447 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
448 if (matches == 1 && looks_like_struct (retval)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
449 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
450 // 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
|
451 // whether it should be '(' or '.'. |
4179 | 452 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
453 command_editor::set_completion_append_character ('\0'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
454 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
455 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
456 command_editor::set_completion_append_character |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
457 (Vcompletion_append_char); |
1280 | 458 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
459 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
460 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
461 } |
1 | 462 } |
463 | |
2944 | 464 return retval; |
1 | 465 } |
466 | |
6979 | 467 static std::string |
468 quoting_filename (const std::string &text, int, char quote) | |
469 { | |
470 if (quote) | |
471 return text; | |
472 else | |
473 return (std::string ("'") + text); | |
474 } | |
475 | |
2927 | 476 void |
477 initialize_command_input (void) | |
478 { | |
479 // If we are using readline, this allows conditional parsing of the | |
480 // .inputrc file. | |
269 | 481 |
2927 | 482 command_editor::set_name ("Octave"); |
1358 | 483 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
484 // FIXME: this needs to include a comma too, but that |
3933 | 485 // causes trouble for the new struct element completion code. |
486 | |
4272 | 487 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~"; |
3933 | 488 |
489 command_editor::set_basic_word_break_characters (s); | |
490 | |
491 command_editor::set_completer_word_break_characters (s); | |
492 | |
3004 | 493 command_editor::set_basic_quote_characters ("\""); |
2944 | 494 |
6979 | 495 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{"); |
496 command_editor::set_completer_quote_characters ("'\""); | |
497 | |
2944 | 498 command_editor::set_completion_function (generate_completion); |
6979 | 499 |
500 command_editor::set_quoting_function (quoting_filename); | |
269 | 501 } |
502 | |
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
|
503 static void |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
504 execute_in_debugger_handler (const std::pair<std::string, int>& arg) |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
505 { |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
506 octave_link::execute_in_debugger_event (arg.first, arg.second); |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
507 } |
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
508 |
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
509 static void |
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
|
510 get_debug_input (const std::string& prompt) |
269 | 511 { |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
512 unwind_protect frame; |
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
513 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
514 bool silent = tree_evaluator::quiet_breakpoint_flag; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
515 tree_evaluator::quiet_breakpoint_flag = false; |
19629
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19413
diff
changeset
|
516 |
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
|
517 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
|
518 std::string nm; |
18629
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
519 int curr_debug_line; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
520 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
521 bool have_file = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
522 |
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
|
523 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
|
524 { |
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
|
525 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
|
526 |
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
|
527 if (nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
528 nm = caller->name (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
529 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
530 have_file = true; |
18629
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
531 |
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
532 curr_debug_line = octave_call_stack::caller_user_code_line (); |
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
|
533 } |
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
|
534 else |
18629
a87bdd302b1b
set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents:
18037
diff
changeset
|
535 curr_debug_line = octave_call_stack::current_line (); |
3180 | 536 |
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
|
537 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
|
538 |
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
|
539 if (! nm.empty ()) |
3180 | 540 { |
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
|
541 if (Vgud_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
542 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
543 static char ctrl_z = 'Z' & 0x1f; |
269 | 544 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
545 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
|
546 } |
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
|
547 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
548 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
549 // FIXME: we should come up with a clean way to detect |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
550 // 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
|
551 // 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
|
552 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
553 if (! silent) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
554 { |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
555 buf << "stopped in " << nm; |
1 | 556 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
557 if (curr_debug_line > 0) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
558 buf << " at line " << curr_debug_line; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
559 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
560 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
561 if (have_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
562 { |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
563 octave_link::enter_debugger_event (nm, curr_debug_line); |
16395
fc491da603f6
also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
564 |
16524
6a8e63dadfad
provide octave_link::set_workspace function with default values
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
565 octave_link::set_workspace (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16438
diff
changeset
|
566 |
16438
a971d8bdaadc
use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents:
16433
diff
changeset
|
567 frame.add_fcn (execute_in_debugger_handler, |
16419
16bfbf9136d3
avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents:
16416
diff
changeset
|
568 std::pair<std::string, int> (nm, curr_debug_line)); |
16374
8b0a04cbdc9d
provide hook function for dbstop events
John W. Eaton <jwe@octave.org>
parents:
16373
diff
changeset
|
569 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
570 if (! silent) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
571 { |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
572 std::string line_buf |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
573 = 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
|
574 |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
575 if (! line_buf.empty ()) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
576 buf << "\n" << curr_debug_line << ": " << line_buf; |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
577 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
578 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
579 } |
3180 | 580 } |
581 | |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
582 if (silent) |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
583 command_editor::erase_empty_line (true); |
19629
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19413
diff
changeset
|
584 |
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
|
585 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
|
586 |
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
|
587 if (! msg.empty ()) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
588 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
|
589 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
590 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
|
591 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
|
592 |
17731
f79bf671a493
eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents:
17323
diff
changeset
|
593 if (! (interactive || forced_interactive)) |
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 { |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
595 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
|
596 forced_interactive = true; |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
597 } |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
598 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
599 octave_parser curr_parser; |
16151 | 600 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
601 while (Vdebugging) |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
602 { |
16127
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
603 unwind_protect middle_frame; |
f7eb13f14320
avoid using unwind_protect::run
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
604 |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
605 reset_error_handler (); |
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
606 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
607 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
|
608 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
609 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
|
610 |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
611 if (command_editor::interrupt (false)) |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
612 break; |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
613 else |
12907
6e1b9f079e0f
allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents:
12573
diff
changeset
|
614 { |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
615 if (retval == 0 && curr_parser.stmt_list) |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
616 { |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
617 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
|
618 |
16382
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
619 if (octave_completion_matches_called) |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
620 octave_completion_matches_called = false; |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
621 } |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
622 |
389b09a914e2
allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents:
16381
diff
changeset
|
623 octave_quit (); |
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
|
624 } |
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
|
625 } |
529 | 626 } |
627 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
628 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
|
629 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
630 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
|
631 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
632 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
633 octave_terminal_reader::get_input (bool& eof) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
634 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
635 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
636 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
637 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
638 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
639 return octave_gets (eof); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
640 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
641 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
642 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
|
643 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
644 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
645 octave_file_reader::get_input (bool& eof) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
646 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
647 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
648 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
649 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
650 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
651 return octave_fgets (file, eof); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
652 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
653 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
654 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
|
655 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
656 std::string |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
657 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
|
658 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
659 octave_quit (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
660 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
661 eof = false; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
662 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
663 std::string retval; |
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 retval = eval_string; |
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 // 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
|
668 // an empty character string with EOF = true. |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
669 eval_string = ""; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
670 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
671 if (retval.empty ()) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
672 eof = true; |
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 return retval; |
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 |
581 | 677 // If the user simply hits return, this will produce an empty matrix. |
678 | |
2086 | 679 static octave_value_list |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
680 get_user_input (const octave_value_list& args, int nargout) |
529 | 681 { |
3100 | 682 octave_value_list retval; |
529 | 683 |
684 int nargin = args.length (); | |
685 | |
686 int read_as_string = 0; | |
687 | |
712 | 688 if (nargin == 2) |
529 | 689 read_as_string++; |
690 | |
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
|
691 std::string prompt = args(0).string_value (); |
4975 | 692 |
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
|
693 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
|
694 { |
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
|
695 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
|
696 return retval; |
4975 | 697 } |
698 | |
2095 | 699 flush_octave_stdout (); |
529 | 700 |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
12989
diff
changeset
|
701 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
|
702 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
|
703 |
4565 | 704 octave_diary << prompt; |
705 | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
706 bool eof = false; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
707 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
708 std::string input_buf = interactive_input (prompt.c_str (), eof); |
529 | 709 |
7459
d3fe4d466bc2
don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
710 if (! (error_state || input_buf.empty ())) |
529 | 711 { |
2927 | 712 size_t len = input_buf.length (); |
529 | 713 |
4565 | 714 octave_diary << input_buf; |
715 | |
716 if (input_buf[len - 1] != '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
717 octave_diary << "\n"; |
4565 | 718 |
529 | 719 if (len < 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
720 return read_as_string ? octave_value ("") : octave_value (Matrix ()); |
3772 | 721 |
722 if (read_as_string) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
723 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
724 // FIXME: fix gnu_readline and octave_gets instead! |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
725 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
|
726 retval(0) = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
727 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
728 retval(0) = input_buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
729 } |
529 | 730 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
731 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
732 int parse_status = 0; |
2900 | 733 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
734 retval = eval_string (input_buf, true, parse_status, nargout); |
3100 | 735 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
736 if (! Vdebugging && retval.length () == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
737 retval(0) = Matrix (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
738 } |
529 | 739 } |
740 else | |
741 error ("input: reading user-input failed!"); | |
742 | |
743 return retval; | |
744 } | |
745 | |
3100 | 746 DEFUN (input, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
747 "-*- texinfo -*-\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
748 @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
|
749 @deftypefnx {Built-in Function} {@var{ans} =} input (@var{prompt}, \"s\")\n\ |
18708
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
750 Print @var{prompt} and wait for user input.\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
751 \n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
752 For example,\n\ |
3372 | 753 \n\ |
754 @example\n\ | |
755 input (\"Pick a number, any number! \")\n\ | |
756 @end example\n\ | |
757 \n\ | |
758 @noindent\n\ | |
759 prints the prompt\n\ | |
760 \n\ | |
761 @example\n\ | |
762 Pick a number, any number!\n\ | |
763 @end example\n\ | |
529 | 764 \n\ |
3372 | 765 @noindent\n\ |
766 and waits for the user to enter a value. The string entered by the user\n\ | |
767 is evaluated as an expression, so it may be a literal constant, a\n\ | |
768 variable name, or any other valid expression.\n\ | |
769 \n\ | |
770 Currently, @code{input} only returns one value, regardless of the number\n\ | |
771 of values produced by the evaluation of the expression.\n\ | |
772 \n\ | |
773 If you are only interested in getting a literal string value, you can\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
774 call @code{input} with the character string @qcode{\"s\"} as the second\n\ |
3372 | 775 argument. This tells Octave to return the string entered by the user\n\ |
776 directly, without evaluating it first.\n\ | |
777 \n\ | |
778 Because there may be output waiting to be displayed by the pager, it is\n\ | |
779 a good idea to always call @code{fflush (stdout)} before calling\n\ | |
780 @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
|
781 the screen before your prompt.\n\ |
18708
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
782 @seealso{yes_or_no, kbhit, pause, menu, listdlg}\n\ |
3372 | 783 @end deftypefn") |
529 | 784 { |
2086 | 785 octave_value_list retval; |
529 | 786 |
787 int nargin = args.length (); | |
788 | |
712 | 789 if (nargin == 1 || nargin == 2) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
790 retval = get_user_input (args, nargout); |
529 | 791 else |
5823 | 792 print_usage (); |
529 | 793 |
794 return retval; | |
795 } | |
796 | |
5640 | 797 bool |
798 octave_yes_or_no (const std::string& prompt) | |
799 { | |
800 std::string prompt_string = prompt + "(yes or no) "; | |
801 | |
802 while (1) | |
803 { | |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
804 bool eof = false; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
805 |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
806 std::string input_buf = interactive_input (prompt_string, eof); |
5640 | 807 |
808 if (input_buf == "yes") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
809 return true; |
5640 | 810 else if (input_buf == "no") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
811 return false; |
5640 | 812 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
813 message (0, "Please answer yes or no."); |
5640 | 814 } |
815 } | |
816 | |
817 DEFUN (yes_or_no, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
818 "-*- texinfo -*-\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
819 @deftypefn {Built-in Function} {@var{ans} =} yes_or_no (\"@var{prompt}\")\n\ |
18708
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
820 Ask the user a yes-or-no question.\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
821 \n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
822 Return logical true if the answer is yes or false if the answer is no.\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
823 Takes one argument, @var{prompt}, which is the string to display when asking\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
824 the question. @var{prompt} should end in a space; @code{yes-or-no} adds the\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
825 string @samp{(yes or no) } to it. The user must confirm the answer with\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
826 @key{RET} and can edit it until it has been confirmed.\n\ |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
827 @seealso{input}\n\ |
5640 | 828 @end deftypefn") |
829 { | |
830 octave_value retval; | |
831 | |
832 int nargin = args.length (); | |
833 | |
834 if (nargin == 0 || nargin == 1) | |
835 { | |
836 std::string prompt; | |
837 | |
838 if (nargin == 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
839 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
840 prompt = args(0).string_value (); |
5640 | 841 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
842 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
843 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
844 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
|
845 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
846 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
847 } |
5640 | 848 |
849 retval = octave_yes_or_no (prompt); | |
850 } | |
851 else | |
5823 | 852 print_usage (); |
5640 | 853 |
854 return retval; | |
855 } | |
856 | |
3707 | 857 octave_value |
858 do_keyboard (const octave_value_list& args) | |
859 { | |
860 octave_value retval; | |
861 | |
862 int nargin = args.length (); | |
863 | |
864 assert (nargin == 0 || nargin == 1); | |
865 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
866 unwind_protect frame; |
3707 | 867 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
868 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
|
869 command_history::ignoring_entries ()); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12942
diff
changeset
|
870 |
3707 | 871 command_history::ignore_entries (false); |
872 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
873 frame.protect_var (Vdebugging); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
874 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
875 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
876 octave_call_stack::current_frame ()); |
3707 | 877 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
878 // FIXME: probably we just want to print one line, not the |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
879 // 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
|
880 // |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
881 // 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
|
882 // stmt.accept (tpc); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
883 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
884 Vdebugging = true; |
3707 | 885 |
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
|
886 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
|
887 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
|
888 prompt = args(0).string_value (); |
4233 | 889 |
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
|
890 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
|
891 get_debug_input (prompt); |
3707 | 892 |
893 return retval; | |
894 } | |
895 | |
1957 | 896 DEFUN (keyboard, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
897 "-*- texinfo -*-\n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
898 @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
|
899 @deftypefnx {Built-in Function} {} keyboard (\"@var{prompt}\")\n\ |
3372 | 900 This function is normally used for simple debugging. When the\n\ |
901 @code{keyboard} function is executed, Octave prints a prompt and waits\n\ | |
902 for user input. The input strings are then evaluated and the results\n\ | |
903 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
|
904 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
|
905 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
|
906 The @code{keyboard} function does not return an exit status.\n\ |
529 | 907 \n\ |
9300
fddb9f9f724b
Correct documentation for keyboard function
Rik <rdrider0-list@yahoo.com>
parents:
9260
diff
changeset
|
908 If @code{keyboard} is invoked without arguments, a default prompt of\n\ |
3372 | 909 @samp{debug> } is used.\n\ |
18708
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18037
diff
changeset
|
910 @seealso{dbstop, dbcont, dbquit}\n\ |
3372 | 911 @end deftypefn") |
529 | 912 { |
2086 | 913 octave_value_list retval; |
529 | 914 |
915 int nargin = args.length (); | |
916 | |
712 | 917 if (nargin == 0 || nargin == 1) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
918 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
919 unwind_protect frame; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
920 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
921 frame.add_fcn (octave_call_stack::restore_frame, |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
922 octave_call_stack::current_frame ()); |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
923 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9482
diff
changeset
|
924 // 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
|
925 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
|
926 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
927 tree_evaluator::debug_mode = true; |
19413
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18728
diff
changeset
|
928 tree_evaluator::quiet_breakpoint_flag = false; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
929 |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
930 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
|
931 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
932 do_keyboard (args); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7734
diff
changeset
|
933 } |
529 | 934 else |
5823 | 935 print_usage (); |
529 | 936 |
937 return retval; | |
938 } | |
939 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
940 DEFUN (echo, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
941 "-*- texinfo -*-\n\ |
11547 | 942 @deftypefn {Command} {} echo options\n\ |
3332 | 943 Control whether commands are displayed as they are executed. Valid\n\ |
944 options are:\n\ | |
1588 | 945 \n\ |
3332 | 946 @table @code\n\ |
947 @item on\n\ | |
948 Enable echoing of commands as they are executed in script files.\n\ | |
949 \n\ | |
950 @item off\n\ | |
951 Disable echoing of commands as they are executed in script files.\n\ | |
1588 | 952 \n\ |
3332 | 953 @item on all\n\ |
954 Enable echoing of commands as they are executed in script files and\n\ | |
955 functions.\n\ | |
1588 | 956 \n\ |
3332 | 957 @item off all\n\ |
958 Disable echoing of commands as they are executed in script files and\n\ | |
959 functions.\n\ | |
960 @end table\n\ | |
961 \n\ | |
962 @noindent\n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
963 With no arguments, @code{echo} toggles the current echo state.\n\ |
11547 | 964 @end deftypefn") |
1588 | 965 { |
2086 | 966 octave_value_list retval; |
1588 | 967 |
1755 | 968 int argc = args.length () + 1; |
969 | |
1968 | 970 string_vector argv = args.make_argv ("echo"); |
1755 | 971 |
972 if (error_state) | |
973 return retval; | |
1588 | 974 |
975 switch (argc) | |
976 { | |
977 case 1: | |
978 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
979 if ((Vecho_executing_commands & ECHO_SCRIPTS) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
980 || (Vecho_executing_commands & ECHO_FUNCTIONS)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
981 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
982 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
983 Vecho_executing_commands = ECHO_SCRIPTS; |
1588 | 984 } |
985 break; | |
986 | |
987 case 2: | |
988 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
989 std::string arg = argv[1]; |
1755 | 990 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
991 if (arg == "on") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
992 Vecho_executing_commands = ECHO_SCRIPTS; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
993 else if (arg == "off") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
994 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
995 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
996 print_usage (); |
1588 | 997 } |
998 break; | |
999 | |
1000 case 3: | |
1001 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1002 std::string arg = argv[1]; |
1755 | 1003 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1004 if (arg == "on" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1005 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1006 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1007 Vecho_executing_commands = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1008 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1009 else if (arg == "off" && argv[2] == "all") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1010 Vecho_executing_commands = ECHO_OFF; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1011 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1012 print_usage (); |
1588 | 1013 } |
1014 break; | |
1015 | |
1016 default: | |
5823 | 1017 print_usage (); |
1588 | 1018 break; |
1019 } | |
1020 | |
1021 return retval; | |
1022 } | |
1023 | |
2234 | 1024 DEFUN (completion_matches, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1025 "-*- texinfo -*-\n\ |
3332 | 1026 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ |
1027 Generate possible completions given @var{hint}.\n\ | |
2299 | 1028 \n\ |
1029 This function is provided for the benefit of programs like Emacs which\n\ | |
3332 | 1030 might be controlling Octave and handling user input. The current\n\ |
1031 command number is not incremented when this function is called. This is\n\ | |
1032 a feature, not a bug.\n\ | |
3333 | 1033 @end deftypefn") |
2234 | 1034 { |
2281 | 1035 octave_value retval; |
2234 | 1036 |
1037 int nargin = args.length (); | |
1038 | |
1039 if (nargin == 1) | |
1040 { | |
3523 | 1041 std::string hint = args(0).string_value (); |
2234 | 1042 |
1043 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1044 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1045 int n = 32; |
2234 | 1046 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1047 string_vector list (n); |
2234 | 1048 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1049 int k = 0; |
2234 | 1050 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1051 for (;;) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1052 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1053 std::string cmd = generate_completion (hint, k); |
2234 | 1054 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1055 if (! cmd.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1056 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1057 if (k == n) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1058 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1059 n *= 2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1060 list.resize (n); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1061 } |
2235 | 1062 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1063 list[k++] = cmd; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1064 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1065 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1066 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1067 list.resize (k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1068 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1069 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1070 } |
2234 | 1071 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1072 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1073 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1074 if (! list.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1075 retval = list; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1076 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1077 retval = ""; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1078 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1079 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1080 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1081 // 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
|
1082 // 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
|
1083 // appear in a single column. |
2235 | 1084 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1085 int len = list.length (); |
2234 | 1086 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1087 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1088 octave_stdout << list[i] << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1089 } |
2299 | 1090 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1091 octave_completion_matches_called = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1092 } |
2234 | 1093 } |
1094 else | |
5823 | 1095 print_usage (); |
2234 | 1096 |
1097 return retval; | |
1098 } | |
1099 | |
16879
cc3743a91652
Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1100 DEFUN (readline_read_init_file, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1101 "-*- texinfo -*-\n\ |
16879
cc3743a91652
Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1102 @deftypefn {Built-in Function} {} readline_read_init_file (@var{file})\n\ |
7007 | 1103 Read the readline library initialization file @var{file}. If\n\ |
3448 | 1104 @var{file} is omitted, read the default initialization file (normally\n\ |
6615 | 1105 @file{~/.inputrc}).\n\ |
1106 \n\ | |
1107 @xref{Readline Init File, , , readline, GNU Readline Library},\n\ | |
1108 for details.\n\ | |
16880
1aebb613a5ac
Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents:
16879
diff
changeset
|
1109 @seealso{readline_re_read_init_file}\n\ |
3448 | 1110 @end deftypefn") |
3189 | 1111 { |
1112 octave_value_list retval; | |
1113 | |
1114 int nargin = args.length (); | |
1115 | |
1116 if (nargin == 0) | |
1117 command_editor::read_init_file (); | |
1118 else if (nargin == 1) | |
1119 { | |
5872 | 1120 std::string file = args(0).string_value (); |
3189 | 1121 |
1122 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1123 command_editor::read_init_file (file); |
3189 | 1124 } |
1125 else | |
5823 | 1126 print_usage (); |
3189 | 1127 |
1128 return retval; | |
1129 } | |
1130 | |
16880
1aebb613a5ac
Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents:
16879
diff
changeset
|
1131 DEFUN (readline_re_read_init_file, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1132 "-*- texinfo -*-\n\ |
16880
1aebb613a5ac
Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents:
16879
diff
changeset
|
1133 @deftypefn {Built-in Function} {} readline_re_read_init_file ()\n\ |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1134 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
|
1135 @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
|
1136 for details.\n\ |
16879
cc3743a91652
Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
1137 @seealso{readline_read_init_file}\n\ |
7758
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1138 @end deftypefn") |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1139 { |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1140 octave_value_list retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1141 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1142 if (args.length () == 0) |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1143 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
|
1144 else |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1145 print_usage (); |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1146 |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1147 return retval; |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1148 } |
8e14a01ffe9f
input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1149 |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1150 static int |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1151 internal_input_event_hook_fcn (void) |
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1152 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1153 input_event_hook_functions.run (); |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1154 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1155 if (input_event_hook_functions.empty ()) |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1156 command_editor::remove_event_hook (internal_input_event_hook_fcn); |
16152
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1157 |
c48847a781d5
* input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
1158 return 0; |
3498 | 1159 } |
1160 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1161 DEFUN (add_input_event_hook, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1162 "-*- texinfo -*-\n\ |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1163 @deftypefn {Built-in Function} {@var{id} =} add_input_event_hook (@var{fcn})\n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1164 @deftypefnx {Built-in Function} {@var{id} =} add_input_event_hook (@var{fcn}, @var{data})\n\ |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16534
diff
changeset
|
1165 Add the named function or function handle @var{fcn} to the list of functions\n\ |
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16534
diff
changeset
|
1166 to call periodically when Octave is waiting for input. The function should\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1167 have the form\n\ |
10840 | 1168 \n\ |
3498 | 1169 @example\n\ |
1170 @var{fcn} (@var{data})\n\ | |
1171 @end example\n\ | |
1172 \n\ | |
1173 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
|
1174 arguments.\n\ |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1175 \n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1176 The returned identifier may be used to remove the function handle from\n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1177 the list of input hook functions.\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1178 @seealso{remove_input_event_hook}\n\ |
3498 | 1179 @end deftypefn") |
1180 { | |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1181 octave_value retval; |
3498 | 1182 |
1183 int nargin = args.length (); | |
1184 | |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1185 if (nargin == 1 || nargin == 2) |
3498 | 1186 { |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1187 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
|
1188 |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1189 if (nargin == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1190 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
|
1191 |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1192 hook_function hook_fcn (args(0), user_data); |
3498 | 1193 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1194 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1195 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1196 if (input_event_hook_functions.empty ()) |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1197 command_editor::add_event_hook (internal_input_event_hook_fcn); |
3498 | 1198 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1199 input_event_hook_functions.insert (hook_fcn.id (), hook_fcn); |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1200 |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1201 retval = hook_fcn.id (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1202 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1203 else |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1204 error ("add_input_event_hook: expecting function handle or character string as first argument"); |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1205 } |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1206 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1207 print_usage (); |
3498 | 1208 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1209 return retval; |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1210 } |
3498 | 1211 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1212 DEFUN (remove_input_event_hook, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1213 "-*- texinfo -*-\n\ |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16534
diff
changeset
|
1214 @deftypefn {Built-in Function} {} remove_input_event_hook (@var{name})\n\ |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1215 @deftypefnx {Built-in Function} {} remove_input_event_hook (@var{fcn_id})\n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1216 Remove the named function or function handle with the given identifier\n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1217 from the list of functions to call periodically when Octave is waiting\n\ |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1218 for input.\n\ |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1219 @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
|
1220 @end deftypefn") |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1221 { |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1222 octave_value_list retval; |
3498 | 1223 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1224 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
|
1225 |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1226 if (nargin == 1 || nargin == 2) |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1227 { |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1228 std::string hook_fcn_id = args(0).string_value (); |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1229 |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1230 bool warn = (nargin < 2); |
3498 | 1231 |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1232 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1233 { |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1234 hook_function_list::iterator p |
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1235 = input_event_hook_functions.find (hook_fcn_id); |
3498 | 1236 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1237 if (p != input_event_hook_functions.end ()) |
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1238 input_event_hook_functions.erase (p); |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1239 else if (warn) |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1240 warning ("remove_input_event_hook: %s not found in list", |
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1241 hook_fcn_id.c_str ()); |
3498 | 1242 |
16378
b28ae106e316
use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents:
16374
diff
changeset
|
1243 if (input_event_hook_functions.empty ()) |
16349
610617eb84d1
provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
1244 command_editor::remove_event_hook (internal_input_event_hook_fcn); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1245 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1246 else |
16347
bf8397caeff1
allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents:
16336
diff
changeset
|
1247 error ("remove_input_event_hook: argument not valid as a hook function name or id"); |
3498 | 1248 } |
9215
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1249 else |
1500d0197484
allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents:
9134
diff
changeset
|
1250 print_usage (); |
3498 | 1251 |
1252 return retval; | |
1253 } | |
1254 | |
5794 | 1255 DEFUN (PS1, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1256 "-*- texinfo -*-\n\ |
10840 | 1257 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ |
5794 | 1258 @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
|
1259 @deftypefnx {Built-in Function} {} PS1 (@var{new_val}, \"local\")\n\ |
5794 | 1260 Query or set the primary prompt string. When executing interactively,\n\ |
1261 Octave displays the primary prompt when it is ready to read a command.\n\ | |
3332 | 1262 \n\ |
18037
708173343c50
use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
1263 The default value of the primary prompt string is @qcode{\"octave:\\#> \"}.\n\ |
5794 | 1264 To change it, use a command like\n\ |
3332 | 1265 \n\ |
1266 @example\n\ | |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1267 PS1 (\"\\\\u@@\\\\H> \")\n\ |
3332 | 1268 @end example\n\ |
1269 \n\ | |
1270 @noindent\n\ | |
1271 which will result in the prompt @samp{boris@@kremvax> } for the user\n\ | |
1272 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ | |
5794 | 1273 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
|
1274 character string. @xref{Strings}.\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1275 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1276 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
|
1277 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
|
1278 \n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1279 @example\n\ |
14880
9e5df4d6cefa
doc: typo on PS1 documentation example
Carnë Draug <carandraug+dev@gmail.com>
parents:
14138
diff
changeset
|
1280 PS1 (\"\\\\[\\\\033[01;31m\\\\]\\\\s:\\\\#> \\\\[\\\\033[0m\\\\]\")\n\ |
11405
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1281 @end example\n\ |
51b6193e90bb
Documentation fixes
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11367
diff
changeset
|
1282 \n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11547
diff
changeset
|
1283 @noindent\n\ |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11572
diff
changeset
|
1284 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
|
1285 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1286 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1287 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1288 The original variable value is restored when exiting the function.\n\ |
6373 | 1289 @seealso{PS2, PS4}\n\ |
5794 | 1290 @end deftypefn") |
1291 { | |
1292 return SET_INTERNAL_VARIABLE (PS1); | |
1293 } | |
2181 | 1294 |
5794 | 1295 DEFUN (PS2, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1296 "-*- texinfo -*-\n\ |
10840 | 1297 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ |
5794 | 1298 @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
|
1299 @deftypefnx {Built-in Function} {} PS2 (@var{new_val}, \"local\")\n\ |
5794 | 1300 Query or set the secondary prompt string. The secondary prompt is\n\ |
1301 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
|
1302 command. For example, if you are typing a @code{for} loop that spans several\n\ |
5794 | 1303 lines, Octave will print the secondary prompt at the beginning of\n\ |
1304 each line after the first. The default value of the secondary prompt\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1305 string is @qcode{\"> \"}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1306 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1307 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1308 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1309 The original variable value is restored when exiting the function.\n\ |
5794 | 1310 @seealso{PS1, PS4}\n\ |
1311 @end deftypefn") | |
1312 { | |
1313 return SET_INTERNAL_VARIABLE (PS2); | |
1314 } | |
2181 | 1315 |
5794 | 1316 DEFUN (PS4, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1317 "-*- texinfo -*-\n\ |
10840 | 1318 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ |
5794 | 1319 @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
|
1320 @deftypefnx {Built-in Function} {} PS4 (@var{new_val}, \"local\")\n\ |
5794 | 1321 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
|
1322 when echoing commands is enabled.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1323 The default value is @qcode{\"+ \"}.\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1324 @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
|
1325 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1326 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1327 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1328 The original 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
|
1329 @seealso{echo, echo_executing_commands, PS1, PS2}\n\ |
5794 | 1330 @end deftypefn") |
1331 { | |
1332 return SET_INTERNAL_VARIABLE (PS4); | |
1333 } | |
2181 | 1334 |
5794 | 1335 DEFUN (completion_append_char, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1336 "-*- texinfo -*-\n\ |
10840 | 1337 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ |
5794 | 1338 @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
|
1339 @deftypefnx {Built-in Function} {} completion_append_char (@var{new_val}, \"local\")\n\ |
5794 | 1340 Query or set the internal character variable that is appended to\n\ |
1341 successful command-line completion attempts. The default\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1342 value is @qcode{\" \"} (a single space).\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13266
diff
changeset
|
1343 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1344 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1345 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1346 The original variable value is restored when exiting the function.\n\ |
5794 | 1347 @end deftypefn") |
1348 { | |
1349 return SET_INTERNAL_VARIABLE (completion_append_char); | |
1350 } | |
3019 | 1351 |
5794 | 1352 DEFUN (echo_executing_commands, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1353 "-*- texinfo -*-\n\ |
10840 | 1354 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ |
5794 | 1355 @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
|
1356 @deftypefnx {Built-in Function} {} echo_executing_commands (@var{new_val}, \"local\")\n\ |
5794 | 1357 Query or set the internal variable that controls the echo state.\n\ |
1358 It may be the sum of the following values:\n\ | |
3332 | 1359 \n\ |
1360 @table @asis\n\ | |
1361 @item 1\n\ | |
1362 Echo commands read from script files.\n\ | |
1363 \n\ | |
1364 @item 2\n\ | |
1365 Echo commands from functions.\n\ | |
1366 \n\ | |
1367 @item 4\n\ | |
1368 Echo commands read from command line.\n\ | |
1369 @end table\n\ | |
1370 \n\ | |
1371 More than one state can be active at once. For example, a value of 3 is\n\ | |
1372 equivalent to the command @kbd{echo on all}.\n\ | |
1373 \n\ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1374 The value of @code{echo_executing_commands} may be set by the @kbd{echo}\n\ |
10840 | 1375 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
|
1376 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1377 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1378 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1379 The original variable value is restored when exiting the function.\n\ |
5794 | 1380 @end deftypefn") |
1381 { | |
1382 return SET_INTERNAL_VARIABLE (echo_executing_commands); | |
2181 | 1383 } |
1384 | |
6257 | 1385 DEFUN (__request_drawnow__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1386 "-*- texinfo -*-\n\ |
10840 | 1387 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ |
6257 | 1388 @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ |
6945 | 1389 Undocumented internal function.\n\ |
6257 | 1390 @end deftypefn") |
1391 { | |
1392 octave_value retval; | |
1393 | |
1394 int nargin = args.length (); | |
1395 | |
1396 if (nargin == 0) | |
1397 Vdrawnow_requested = true; | |
1398 else if (nargin == 1) | |
1399 Vdrawnow_requested = args(0).bool_value (); | |
1400 else | |
1401 print_usage (); | |
1402 | |
1403 return retval; | |
1404 } | |
1405 | |
7294 | 1406 DEFUN (__gud_mode__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1407 "-*- texinfo -*-\n\ |
7294 | 1408 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ |
1409 Undocumented internal function.\n\ | |
1410 @end deftypefn") | |
1411 { | |
1412 octave_value retval; | |
1413 | |
1414 int nargin = args.length (); | |
1415 | |
1416 if (nargin == 0) | |
1417 retval = Vgud_mode; | |
1418 else if (nargin == 1) | |
1419 Vgud_mode = args(0).bool_value (); | |
1420 else | |
1421 print_usage (); | |
1422 | |
1423 return retval; | |
1424 } | |
1425 | |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1426 DEFUN (filemarker, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1427 "-*- texinfo -*-\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12179
diff
changeset
|
1428 @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
|
1429 @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
|
1430 @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
|
1431 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
|
1432 the subfunction names contained within the file. This can be used in\n\ |
10840 | 1433 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
|
1434 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1435 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1436 help ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1437 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1438 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1439 @noindent\n\ |
14852
53d2c3598d33
doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1440 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
|
1441 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
|
1442 debugging it allows easier placement of breakpoints within subfunctions.\n\ |
10840 | 1443 For example,\n\ |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1444 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1445 @example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1446 dbstop ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1447 @end example\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1448 \n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1449 @noindent\n\ |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1450 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
|
1451 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1452 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1453 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
1454 The original 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
|
1455 @end deftypefn") |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1456 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1457 char tmp = Vfilemarker; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1458 octave_value retval = SET_INTERNAL_VARIABLE (filemarker); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1459 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1460 // 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
|
1461 if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_')) |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1462 { |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1463 Vfilemarker = tmp; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1464 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
|
1465 } |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1466 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1467 return retval; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1468 } |