annotate libinterp/interpfcn/input.cc @ 16373:c97e82b2b5b9

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