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