annotate src/input.cc @ 7948:af10baa63915 ss-3-1-50

3.1.50 snapshot
author John W. Eaton <jwe@octave.org>
date Fri, 18 Jul 2008 17:42:48 -0400
parents f46e73bcb85b
children 0ef13e15319b
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
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 2002, 2003, 2004, 2005, 2006, 2007 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 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
9 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
10 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
11 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 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
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 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
16 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 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
19 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
20 <http://www.gnu.org/licenses/>.
1
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 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
2939
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2927
diff changeset
24 // Get command input interactively or from files.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 217
diff changeset
26 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1125
diff changeset
27 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
30 #include <cstdio>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
31 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
32 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
33 #include <cassert>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
34
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3498
diff changeset
35 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
36 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1705
diff changeset
37 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1705
diff changeset
38
1350
5f63d83dd694 [project @ 1995-09-05 07:37:59 by jwe]
jwe
parents: 1349
diff changeset
39 #ifdef HAVE_UNISTD_H
2442
f667d7ec08b9 [project @ 1996-10-30 18:46:22 by jwe]
jwe
parents: 2431
diff changeset
40 #ifdef HAVE_SYS_TYPES_H
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
41 #include <sys/types.h>
2442
f667d7ec08b9 [project @ 1996-10-30 18:46:22 by jwe]
jwe
parents: 2431
diff changeset
42 #endif
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
43 #include <unistd.h>
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
44 #endif
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
45
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
46 #include "cmd-edit.h"
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
47 #include "file-ops.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4143
diff changeset
48 #include "quit.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
49 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
50
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
51 #include "defun.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
52 #include "dirfns.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 #include "error.h"
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
54 #include "gripes.h"
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
55 #include "help.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 #include "input.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
57 #include "load-path.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
58 #include "oct-map.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
59 #include "oct-hist.h"
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1606
diff changeset
60 #include "toplev.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
61 #include "oct-obj.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
62 #include "pager.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
63 #include "parse.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
64 #include "pathlen.h"
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3741
diff changeset
65 #include "pt.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
66 #include "pt-const.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents: 3804
diff changeset
67 #include "pt-stmt.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
68 #include "sighandlers.h"
1114
971f2289d6de [project @ 1995-02-15 04:58:06 by jwe]
jwe
parents: 1112
diff changeset
69 #include "sysdep.h"
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
70 #include "toplev.h"
3098
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
71 #include "unwind-prot.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
72 #include "utils.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
73 #include "variables.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
74
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
75 // Primary prompt string.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
76 static std::string VPS1 = "\\s:\\#> ";
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
77
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
78 // Secondary prompt string.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
79 static std::string VPS2 = "> ";
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
80
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
81 // 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
82 std::string VPS4 = "+ ";
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
83
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
84 // Echo commands as they are executed?
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
85 //
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
86 // 1 ==> echo commands read from script files
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
87 // 2 ==> echo commands from functions
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
88 // 4 ==> echo commands read from command line
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
89 //
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
90 // 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
91 int Vecho_executing_commands = ECHO_OFF;
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
92
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 3100
diff changeset
93 // The time we last printed a prompt.
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
94 octave_time Vlast_prompt_time = 0.0;
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 3100
diff changeset
95
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
96 // 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
97 static char Vcompletion_append_char = ' ';
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
98
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
99 // Global pointer for eval().
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
100 std::string current_eval_string;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
101
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
102 // TRUE means get input from current_eval_string.
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
103 bool get_input_from_eval_string = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
104
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
105 // TRUE means we haven't been asked for the input from
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
106 // current_eval_string yet.
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
107 bool input_from_eval_string_pending = false;
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
108
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5142
diff changeset
109 // TRUE means that input is coming from a file that was named on
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5142
diff changeset
110 // the command line.
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5142
diff changeset
111 bool input_from_command_line_file = false;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5142
diff changeset
112
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
113 // TRUE means we're parsing a function file.
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
114 bool reading_fcn_file = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
115
338
82d30a23c979 [project @ 1994-02-07 07:09:33 by jwe]
jwe
parents: 287
diff changeset
116 // Simple name of function file we are reading.
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
117 std::string curr_fcn_file_name;
1606
2d0541468991 [project @ 1995-11-02 12:57:17 by jwe]
jwe
parents: 1604
diff changeset
118
2d0541468991 [project @ 1995-11-02 12:57:17 by jwe]
jwe
parents: 1604
diff changeset
119 // Full name of file we are reading.
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
120 std::string curr_fcn_file_full_name;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
121
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
122 // TRUE means we're parsing a script file.
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
123 bool reading_script_file = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 // If we are reading from an M-file, this is it.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
126 FILE *ff_instream = 0;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
128 // TRUE means this is an interactive shell.
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
129 bool interactive = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
130
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
131 // 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
132 bool forced_interactive = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
133
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
134 // Should we issue a prompt?
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
135 int promptflag = 1;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
136
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
137 // The current line of input, from wherever.
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
138 std::string current_input_line;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
139
3804
4073be5aefa1 [project @ 2001-02-28 08:36:04 by jwe]
jwe
parents: 3772
diff changeset
140 // TRUE after a call to completion_matches.
2299
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
141 bool octave_completion_matches_called = false;
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
142
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
143 // 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
144 // the next user prompt.
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7336
diff changeset
145 bool Vdrawnow_requested = false;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
146
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
147 // TRUE if we are in debugging mode.
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
148 bool Vdebugging = false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
149
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
150 // The current line that we are debugging
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
151 int Vdebugging_current_line = -1;
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
152
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
153 // 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
154 static bool Vgud_mode = false;
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
155
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
156 // 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
157 char Vfilemarker = '>';
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
158
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
159 static void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
160 do_input_echo (const std::string& input_string)
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
161 {
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
162 int do_echo = reading_script_file ?
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2181
diff changeset
163 (Vecho_executing_commands & ECHO_SCRIPTS)
2618
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
164 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
165
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
166 if (do_echo)
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
167 {
1403
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
168 if (forced_interactive)
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
169 {
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
170 if (promptflag > 0)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
171 octave_stdout << command_editor::decode_prompt_string (VPS1);
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
172 else
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
173 octave_stdout << command_editor::decode_prompt_string (VPS2);
1403
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
174 }
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
175 else
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
176 octave_stdout << command_editor::decode_prompt_string (VPS4);
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
177
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
178 if (! input_string.empty ())
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
179 {
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
180 octave_stdout << input_string;
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
181
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
182 if (input_string[input_string.length () - 1] != '\n')
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
183 octave_stdout << "\n";
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
184 }
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
185 }
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
186 }
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
187
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
188 std::string
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
189 gnu_readline (const std::string& s, bool force_readline)
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
190 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
191 OCTAVE_QUIT;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
192
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
193 std::string retval;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
194
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
195 if (line_editing || force_readline)
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
196 {
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
197 bool eof;
1898
750e5d190404 [project @ 1996-02-09 17:39:48 by jwe]
jwe
parents: 1884
diff changeset
198
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
199 retval = command_editor::readline (s, eof);
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
200
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3215
diff changeset
201 if (! eof && retval.empty ())
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
202 retval = "\n";
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
203 }
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
204 else
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
205 {
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
206 if (! s.empty () && (interactive || forced_interactive))
2618
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
207 {
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
208 FILE *stream = command_editor::get_output_stream ();
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
209
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
210 fprintf (stream, s.c_str ());
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
211 fflush (stream);
2618
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
212 }
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
213
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
214 FILE *curr_stream = command_editor::get_input_stream ();
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
215
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
216 if (reading_fcn_file || reading_script_file)
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
217 curr_stream = ff_instream;
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
218
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
219 retval = octave_fgets (curr_stream);
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
220 }
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
221
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
222 return retval;
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
223 }
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
224
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
225 static inline std::string
7459
d3fe4d466bc2 don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
226 interactive_input (const std::string& s, bool force_readline = false)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
227 {
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
228 Vlast_prompt_time.stamp ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
229
7459
d3fe4d466bc2 don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
230 if (Vdrawnow_requested && (interactive || forced_interactive))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
231 {
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
232 feval ("drawnow");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
233
6367
268bfc8a2755 [project @ 2007-02-28 20:16:05 by jwe]
jwe
parents: 6317
diff changeset
234 flush_octave_stdout ();
268bfc8a2755 [project @ 2007-02-28 20:16:05 by jwe]
jwe
parents: 6317
diff changeset
235
6305
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
236 // 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
237 // 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
238
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
239 Vdrawnow_requested = false;
6305
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
240
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
241 if (error_state)
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
242 return "\n";
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
243 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
244
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
245 return gnu_readline (s, force_readline);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
246 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
247
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
248 static std::string
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
249 octave_gets (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
250 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
251 OCTAVE_QUIT;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
252
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
253 std::string retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
254
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
255 if ((interactive || forced_interactive)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
256 && (! (reading_fcn_file
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
257 || reading_script_file
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
258 || input_from_startup_file
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
259 || input_from_command_line_file)))
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
260 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
261 std::string ps = (promptflag > 0) ? VPS1 : VPS2;
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
262
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
263 std::string prompt = command_editor::decode_prompt_string (ps);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
264
2618
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
265 pipe_handler_error_count = 0;
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
266
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
267 flush_octave_stdout ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
269 octave_diary << prompt;
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
270
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
271 retval = interactive_input (prompt);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
272
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
273 // There is no need to update the load_path cache if there is no
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
274 // user input.
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7294
diff changeset
275 if (! retval.empty () && retval.find_first_not_of (" \t\n\r") != NPOS)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
276 load_path::update ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
277 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
278 else
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
279 retval = gnu_readline ("");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
280
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
281 current_input_line = retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
282
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
283 if (! current_input_line.empty ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
284 {
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5142
diff changeset
285 if (! (input_from_startup_file || input_from_command_line_file))
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
286 command_history::add (current_input_line);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
287
3176
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
288 if (! (reading_fcn_file || reading_script_file))
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
289 {
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
290 octave_diary << current_input_line;
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
291
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
292 if (current_input_line[current_input_line.length () - 1] != '\n')
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
293 octave_diary << "\n";
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
294 }
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
295
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
296 do_input_echo (current_input_line);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
297 }
3176
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
298 else if (! (reading_fcn_file || reading_script_file))
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
299 octave_diary << "\n";
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
300
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
301 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
302 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
303
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
304 // Read a line from the input stream.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
305
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
306 static std::string
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
307 get_user_input (void)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
308 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
309 OCTAVE_QUIT;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
310
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
311 std::string retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
312
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
313 if (get_input_from_eval_string)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 {
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
315 if (input_from_eval_string_pending)
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
316 {
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
317 input_from_eval_string_pending = false;
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
318
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
319 retval = current_eval_string;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
320
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
321 size_t len = retval.length ();
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
322
6206
cb8c62c78b42 [project @ 2006-12-06 20:10:02 by jwe]
jwe
parents: 5872
diff changeset
323 if (len > 0 && retval[len-1] != '\n')
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
324 retval.append ("\n");
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3805
diff changeset
325 }
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
326 }
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
327 else
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
328 retval = octave_gets ();
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
329
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
330 current_input_line = retval;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
331
2114
a84f9c1fe38b [project @ 1996-05-03 18:50:11 by jwe]
jwe
parents: 2095
diff changeset
332 if (! get_input_from_eval_string)
a84f9c1fe38b [project @ 1996-05-03 18:50:11 by jwe]
jwe
parents: 2095
diff changeset
333 input_line_number++;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
334
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
335 return retval;
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
336 }
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
337
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
338 int
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
339 octave_read (char *buf, unsigned max_size)
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
340 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
341 // FIXME -- is this a safe way to buffer the input?
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
342
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
343 static const char * const eol = "\n";
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
344 static std::string input_buf;
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
345 static const char *pos = 0;
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
346 static size_t chars_left = 0;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
347
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
348 int status = 0;
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
349 if (chars_left == 0)
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
350 {
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
351 pos = 0;
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
352
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
353 input_buf = get_user_input ();
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
354
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
355 chars_left = input_buf.length ();
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
356
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
357 pos = input_buf.c_str ();
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
358 }
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
359
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
360 if (chars_left > 0)
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
361 {
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
362 size_t len = max_size > chars_left ? chars_left : max_size;
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
363 assert (len > 0);
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
364
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
365 memcpy (buf, pos, len);
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
366
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
367 chars_left -= len;
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
368 pos += len;
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
369
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
370 // Make sure input ends with a new line character.
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
371 if (chars_left == 0 && buf[len-1] != '\n')
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
372 {
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
373 if (len < max_size)
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
374 {
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
375 // There is enough room to plug the newline character in
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
376 // the buffer.
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
377 buf[len++] = '\n';
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
378 }
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
379 else
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
380 {
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
381 // There isn't enough room to plug the newline character
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
382 // in the buffer so make sure it is returned on the next
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
383 // octave_read call.
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
384 pos = eol;
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
385 chars_left = 1;
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
386 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
387 }
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
388
4046
7787c144d5d9 [project @ 2002-08-15 18:17:41 by jwe]
jwe
parents: 3968
diff changeset
389 status = len;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
390
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
391 }
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
392 else if (chars_left == 0)
2862
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2856
diff changeset
393 {
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2856
diff changeset
394 status = 0;
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2856
diff changeset
395 }
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
396 else
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
397 status = -1;
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
398
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
399 return status;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
400 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
401
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
402 // Fix things up so that input can come from file `name', printing a
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
403 // warning if the file doesn't exist.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
404
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
405 FILE *
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
406 get_input_from_file (const std::string& name, int warn)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407 {
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
408 FILE *instream = 0;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
409
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
410 if (name.length () > 0)
7728
13820b9f5fd9 more consistent handling of CR/CRLF/LF line endings in lexer and parser
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
411 instream = fopen (name.c_str (), "rb");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
412
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
413 if (! instream && warn)
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
414 warning ("%s: no such file or directory", name.c_str ());
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415
338
82d30a23c979 [project @ 1994-02-07 07:09:33 by jwe]
jwe
parents: 287
diff changeset
416 if (reading_fcn_file || reading_script_file)
339
94f0f219a946 [project @ 1994-02-07 07:26:24 by jwe]
jwe
parents: 338
diff changeset
417 ff_instream = instream;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
418 else
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
419 command_editor::set_input_stream (instream);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
420
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
421 return instream;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
422 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
423
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
424 // 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
425 // 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
426 // separate function.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
427
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 FILE *
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429 get_input_from_stdin (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430 {
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
431 command_editor::set_input_stream (stdin);
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
432 return command_editor::get_input_stream ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
433 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
434
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
435 // FIXME -- make this generate file names when appropriate.
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
436
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
437 static string_vector
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
438 generate_possible_completions (const std::string& text, std::string& prefix,
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
439 std::string& hint)
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
440 {
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
441 string_vector names;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
442
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
443 prefix = "";
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
444
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
445 if (looks_like_struct (text))
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1403
diff changeset
446 names = generate_struct_completions (text, prefix, hint);
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1403
diff changeset
447 else
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
448 names = make_name_list ();
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
449
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
450 // Sort and remove duplicates.
2348
a88c5cc51f62 [project @ 1996-07-25 09:54:40 by jwe]
jwe
parents: 2327
diff changeset
451
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
452 names.qsort (true);
2348
a88c5cc51f62 [project @ 1996-07-25 09:54:40 by jwe]
jwe
parents: 2327
diff changeset
453
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
454 return names;
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
455 }
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
456
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
457 static std::string
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
458 generate_completion (const std::string& text, int state)
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
459 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
460 std::string retval;
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
461
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
462 static std::string prefix;
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
463 static std::string hint;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
464
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
465 static size_t hint_len = 0;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
466
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
467 static int list_index = 0;
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
468 static int name_list_len = 0;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
469 static int name_list_total_len = 0;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
470 static string_vector name_list;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
471 static string_vector file_name_list;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
472
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
473 static int matches = 0;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
474
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
475 if (state == 0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
476 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
477 list_index = 0;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
478
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
479 prefix = "";
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
480
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
481 hint = text;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
482
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
483 name_list = generate_possible_completions (text, prefix, hint);
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
484
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
485 name_list_len = name_list.length ();
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
486
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
487 file_name_list = command_editor::generate_filename_completions (text);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
488
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
489 name_list.append (file_name_list);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
490
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
491 name_list_total_len = name_list.length ();
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
492
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
493 hint_len = hint.length ();
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
494
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
495 matches = 0;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
496
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
497 for (int i = 0; i < name_list_len; i++)
3565
4290f11c8d3b [project @ 2000-02-03 08:32:41 by jwe]
jwe
parents: 3536
diff changeset
498 if (hint == name_list[i].substr (0, hint_len))
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
499 matches++;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
500 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
501
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
502 if (name_list_total_len > 0 && matches > 0)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
503 {
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
504 while (list_index < name_list_total_len)
244
d66cc97f77a9 [project @ 1993-12-03 01:30:19 by jwe]
jwe
parents: 240
diff changeset
505 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
506 std::string name = name_list[list_index];
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
507
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
508 list_index++;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
509
3565
4290f11c8d3b [project @ 2000-02-03 08:32:41 by jwe]
jwe
parents: 3536
diff changeset
510 if (hint == name.substr (0, hint_len))
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
511 {
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
512 if (list_index <= name_list_len && ! prefix.empty ())
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
513 retval = prefix + "." + name;
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
514 else
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
515 retval = name;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
516
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
517 // FIXME -- looks_like_struct is broken for now,
4179
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
518 // so it always returns false.
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
519
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
520 if (matches == 1 && looks_like_struct (retval))
4179
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
521 {
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
522 // Don't append anything, since we don't know
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
523 // whether it should be '(' or '.'.
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
524
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
525 command_editor::set_completion_append_character ('\0');
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
526 }
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
527 else
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
528 command_editor::set_completion_append_character
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
529 (Vcompletion_append_char);
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
530
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
531 break;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
532 }
244
d66cc97f77a9 [project @ 1993-12-03 01:30:19 by jwe]
jwe
parents: 240
diff changeset
533 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
534 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
535
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
536 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
537 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
538
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
539 static std::string
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
540 quoting_filename (const std::string &text, int, char quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
541 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
542 if (quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
543 return text;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
544 else
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
545 return (std::string ("'") + text);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
546 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
547
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
548 void
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
549 initialize_command_input (void)
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
550 {
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
551 // 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
552 // .inputrc file.
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
553
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
554 command_editor::set_name ("Octave");
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
555
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
556 // 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
557 // causes trouble for the new struct element completion code.
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
558
4272
fd406afe8a10 [project @ 2003-01-03 19:52:30 by jwe]
jwe
parents: 4253
diff changeset
559 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~";
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
560
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
561 command_editor::set_basic_word_break_characters (s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
562
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
563 command_editor::set_completer_word_break_characters (s);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
564
3004
9a54159563de [project @ 1997-05-23 05:00:49 by jwe]
jwe
parents: 2944
diff changeset
565 command_editor::set_basic_quote_characters ("\"");
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
566
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
567 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{");
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
568 command_editor::set_completer_quote_characters ("'\"");
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
569
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
570 command_editor::set_completion_function (generate_completion);
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
571
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
572 command_editor::set_quoting_function (quoting_filename);
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
573 }
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
574
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
575 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
576 get_debug_input (const std::string& prompt)
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
577 {
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
578 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
579 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
580
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
581 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
582 {
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
583 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
584
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
585 if (nm.empty ())
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
586 nm = caller->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
587
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
588 Vdebugging_current_line = octave_call_stack::current_line ();
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
589 }
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
590 else
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
591 Vdebugging_current_line = -1;
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
592
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
593 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
594
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
595 if (! nm.empty ())
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
596 {
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
597 if (Vgud_mode)
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
598 {
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
599 static char ctrl_z = 'Z' & 0x1f;
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
600
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
601 buf << ctrl_z << ctrl_z << nm << ":" << Vdebugging_current_line;
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
602 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
603 else
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
604 {
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
605 buf << "stopped in " << nm;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
606
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
607 if (Vdebugging_current_line > 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
608 buf << " at line " << Vdebugging_current_line;
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
609 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
610 }
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
611
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
612 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
613
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
614 if (! msg.empty ())
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
615 message (Vgud_mode ? 0 : "keyboard", msg.c_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
616
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
617 unwind_protect::begin_frame ("get_debug_input");
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
618
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
619 unwind_protect_str (VPS1);
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
620 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
621
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
622 while (Vdebugging)
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
623 {
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
624 reset_error_handler ();
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
625
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
626 reset_parser ();
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
627
7903
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
628 // Save current value of global_command.
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
629 unwind_protect_ptr (global_command);
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
630
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
631 // This is the same as yyparse in parse.y.
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
632 int retval = octave_parse ();
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
633
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
634 if (retval == 0 && global_command)
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
635 {
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
636 global_command->eval ();
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
637
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
638 // FIXME -- To avoid a memory leak, global_command should be
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
639 // deleted, I think. But doing that here causes trouble if
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
640 // an error occurs while executing a debugging command
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
641 // (dbstep, for example). It's not clear to me why that
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
642 // happens.
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
643 //
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
644 // delete global_command;
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
645 //
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
646 // global_command = 0;
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
647
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
648 if (octave_completion_matches_called)
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
649 octave_completion_matches_called = false;
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
650 }
7903
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
651
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
652 // Restore previous value of global_command.
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
653 unwind_protect::run ();
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
654
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
655 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
656 }
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
657
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
658 unwind_protect::run_frame ("get_debug_input");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
659 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
660
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
661 // 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
662
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
663 static octave_value_list
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
664 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
665 {
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
666 octave_value_list retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
667
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
668 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
669
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
670 int read_as_string = 0;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
671
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 661
diff changeset
672 if (nargin == 2)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
673 read_as_string++;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
674
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
675 std::string prompt = args(0).string_value ();
4975
80842ad3f85c [project @ 2004-09-08 18:37:58 by jwe]
jwe
parents: 4802
diff changeset
676
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
677 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
678 {
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
679 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
680 return retval;
4975
80842ad3f85c [project @ 2004-09-08 18:37:58 by jwe]
jwe
parents: 4802
diff changeset
681 }
80842ad3f85c [project @ 2004-09-08 18:37:58 by jwe]
jwe
parents: 4802
diff changeset
682
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
683 flush_octave_stdout ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
684
4565
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
685 octave_diary << prompt;
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
686
7459
d3fe4d466bc2 don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
687 std::string input_buf = interactive_input (prompt.c_str (), true);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
688
7459
d3fe4d466bc2 don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
689 if (! (error_state || input_buf.empty ()))
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
690 {
1799
1881b2a7d1e2 [project @ 1996-01-29 05:10:48 by jwe]
jwe
parents: 1761
diff changeset
691 if (! input_from_startup_file)
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
692 command_history::add (input_buf);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
693
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
694 size_t len = input_buf.length ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
695
4565
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
696 octave_diary << input_buf;
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
697
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
698 if (input_buf[len - 1] != '\n')
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
699 octave_diary << "\n";
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
700
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
701 if (len < 1)
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
702 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
703
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3741
diff changeset
704 if (read_as_string)
963
28f5711477b3 [project @ 1994-12-09 18:59:03 by jwe]
jwe
parents: 836
diff changeset
705 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
706 // FIXME -- fix gnu_readline and octave_gets instead!
3081
8c779ed7979b [project @ 1997-08-25 15:51:20 by jwe]
jwe
parents: 3019
diff changeset
707 if (input_buf.length () == 1 && input_buf[0] == '\n')
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
708 retval(0) = "";
3081
8c779ed7979b [project @ 1997-08-25 15:51:20 by jwe]
jwe
parents: 3019
diff changeset
709 else
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
710 retval(0) = input_buf;
963
28f5711477b3 [project @ 1994-12-09 18:59:03 by jwe]
jwe
parents: 836
diff changeset
711 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
712 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
713 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
714 int parse_status = 0;
2900
5ed088015839 [project @ 1997-04-30 03:26:56 by jwe]
jwe
parents: 2896
diff changeset
715
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
716 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
717
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
718 if (! Vdebugging && retval.length () == 0)
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
719 retval(0) = Matrix ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
720 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
721 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
722 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
723 error ("input: reading user-input failed!");
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
724
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
725 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
726 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
727
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
728 DEFUN (input, args, nargout,
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
729 "-*- texinfo -*-\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
730 @deftypefn {Built-in Function} {} input (@var{prompt})\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
731 @deftypefnx {Built-in Function} {} input (@var{prompt}, \"s\")\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
732 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
733 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
734 @example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
735 input (\"Pick a number, any number! \")\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
736 @end example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
737 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
738 @noindent\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
739 prints the prompt\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
740 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
741 @example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
742 Pick a number, any number!\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
743 @end example\n\
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
744 \n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
745 @noindent\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
746 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
747 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
748 variable name, or any other valid expression.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
749 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
750 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
751 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
752 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
753 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
754 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
755 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
756 directly, without evaluating it first.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
757 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
758 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
759 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
760 @code{input}. This will ensure that all pending output is written to\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
761 the screen before your prompt. @xref{Input and Output}.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
762 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
763 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
764 octave_value_list retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
765
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
766 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
767
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 661
diff changeset
768 if (nargin == 1 || nargin == 2)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
769 retval = get_user_input (args, nargout);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
770 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
771 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
772
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
773 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
774 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
775
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
776 bool
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
777 octave_yes_or_no (const std::string& prompt)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
778 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
779 std::string prompt_string = prompt + "(yes or no) ";
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
780
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
781 while (1)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
782 {
7459
d3fe4d466bc2 don't inhibit drawnow in debug mode
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
783 std::string input_buf = interactive_input (prompt_string, true);
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
784
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
785 if (input_buf == "yes")
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
786 return true;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
787 else if (input_buf == "no")
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
788 return false;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
789 else
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
790 message (0, "Please answer yes or no.");
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
791 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
792 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
793
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
794 DEFUN (yes_or_no, args, ,
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
795 "-*- texinfo -*-\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
796 @deftypefn {Built-in Function} {} yes_or_no (@var{prompt})\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
797 Ask the user a yes-or-no question. Return 1 if the answer is yes.\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
798 Takes one argument, which is the string to display to ask the\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
799 question. It should end in a space; @samp{yes-or-no-p} adds\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
800 @samp{(yes or no) } to it. The user must confirm the answer with\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
801 RET and can edit it until it has been confirmed.\n\
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
802 @end deftypefn")
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
803 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
804 octave_value retval;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
805
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
806 int nargin = args.length ();
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
807
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
808 if (nargin == 0 || nargin == 1)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
809 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
810 std::string prompt;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
811
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
812 if (nargin == 1)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
813 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
814 prompt = args(0).string_value ();
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
815
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
816 if (error_state)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
817 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
818 error ("yes_or_no: expecting argument to be character string");
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
819 return retval;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
820 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
821 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
822
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
823 retval = octave_yes_or_no (prompt);
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
824 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
825 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
826 print_usage ();
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
827
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
828 return retval;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
829 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
830
3098
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
831 static void
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
832 restore_command_history (void *)
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
833 {
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
834 command_history::ignore_entries (! Vsaving_history);
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
835 }
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
836
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
837 static size_t saved_frame = 0;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
838
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
839 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
840 restore_frame (void *)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
841 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
842 octave_call_stack::goto_frame (saved_frame);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
843 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
844
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
845 octave_value
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
846 do_keyboard (const octave_value_list& args)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
847 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
848 octave_value retval;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
849
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
850 int nargin = args.length ();
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
851
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
852 assert (nargin == 0 || nargin == 1);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
853
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
854 unwind_protect::begin_frame ("do_keyboard");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
855
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
856 // FIXME -- we shouldn't need both the
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
857 // command_history object and the
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
858 // Vsaving_history variable...
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
859 command_history::ignore_entries (false);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
860
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
861 unwind_protect::add (restore_command_history, 0);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
862
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
863 unwind_protect_bool (Vsaving_history);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
864 unwind_protect_bool (Vdebugging);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
865
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
866 saved_frame = octave_call_stack::current_frame ();
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
867 unwind_protect::add (restore_frame);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
868 unwind_protect_size_t (saved_frame);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
869
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
870 Vsaving_history = true;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
871 Vdebugging = true;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
872
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
873 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
874 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
875 prompt = args(0).string_value ();
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4208
diff changeset
876
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
877 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
878 get_debug_input (prompt);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
879
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
880 unwind_protect::run_frame ("do_keyboard");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
881
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
882 return retval;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
883 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
884
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1900
diff changeset
885 DEFUN (keyboard, args, ,
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
886 "-*- texinfo -*-\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
887 @deftypefn {Built-in Function} {} keyboard (@var{prompt})\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
888 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
889 @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
890 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
891 are printed. This makes it possible to examine the values of variables\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
892 within a function, and to assign new values to variables. No value is\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
893 returned from the @code{keyboard} function, and it continues to prompt\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
894 for input until the user types @samp{quit}, or @samp{exit}.\n\
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
895 \n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
896 If @code{keyboard} is invoked without any arguments, a default prompt of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
897 @samp{debug> } is used.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
898 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
899 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
900 octave_value_list retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
901
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
902 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
903
712
36ba0576bd1b [project @ 1994-09-19 14:18:15 by jwe]
jwe
parents: 661
diff changeset
904 if (nargin == 0 || nargin == 1)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
905 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
906 saved_frame = octave_call_stack::current_frame ();
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
907 unwind_protect::add (restore_frame);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
908 unwind_protect_size_t (saved_frame);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
909
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
910 // Skip the frame assigned to the keyboard function.
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
911 octave_call_stack::goto_frame (1);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
912
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
913 do_keyboard (args);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
914
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
915 unwind_protect::run ();
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
916 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
917 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
918 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
919
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
920 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
921 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
922
4208
e96f52432059 [project @ 2002-12-03 19:48:57 by jwe]
jwe
parents: 4179
diff changeset
923 DEFCMD (echo, args, ,
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
924 "-*- texinfo -*-\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
925 @deffn {Command} echo options\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
926 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
927 options are:\n\
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
928 \n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
929 @table @code\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
930 @item on\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
931 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
932 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
933 @item off\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
934 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
935 \n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
936 @item on all\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
937 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
938 functions.\n\
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
939 \n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
940 @item off all\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
941 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
942 functions.\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
943 @end table\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
944 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
945 @noindent\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
946 If invoked without any arguments, @code{echo} toggles the current echo\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
947 state.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
948 @end deffn")
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
949 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
950 octave_value_list retval;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
951
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
952 int argc = args.length () + 1;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
953
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1957
diff changeset
954 string_vector argv = args.make_argv ("echo");
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
955
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
956 if (error_state)
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
957 return retval;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
958
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
959 switch (argc)
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
960 {
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
961 case 1:
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
962 {
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2181
diff changeset
963 if ((Vecho_executing_commands & ECHO_SCRIPTS)
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2181
diff changeset
964 || (Vecho_executing_commands & ECHO_FUNCTIONS))
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
965 Vecho_executing_commands = ECHO_OFF;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
966 else
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
967 Vecho_executing_commands = ECHO_SCRIPTS;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
968 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
969 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
970
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
971 case 2:
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
972 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
973 std::string arg = argv[1];
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
974
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
975 if (arg == "on")
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
976 Vecho_executing_commands = ECHO_SCRIPTS;
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
977 else if (arg == "off")
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
978 Vecho_executing_commands = ECHO_OFF;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
979 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
980 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
981 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
982 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
983
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
984 case 3:
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
985 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
986 std::string arg = argv[1];
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
987
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
988 if (arg == "on" && argv[2] == "all")
2800
9aeba8e006a4 [project @ 1997-03-09 09:50:20 by jwe]
jwe
parents: 2618
diff changeset
989 {
9aeba8e006a4 [project @ 1997-03-09 09:50:20 by jwe]
jwe
parents: 2618
diff changeset
990 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
991 Vecho_executing_commands = tmp;
2800
9aeba8e006a4 [project @ 1997-03-09 09:50:20 by jwe]
jwe
parents: 2618
diff changeset
992 }
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
993 else if (arg == "off" && argv[2] == "all")
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
994 Vecho_executing_commands = ECHO_OFF;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
995 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
996 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
997 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
998 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
999
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1000 default:
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1001 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1002 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1003 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1004
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1005 return retval;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1006 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1007
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1008 DEFUN (completion_matches, args, nargout,
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1009 "-*- texinfo -*-\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1010 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1011 Generate possible completions given @var{hint}.\n\
2299
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
1012 \n\
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
1013 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
1014 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
1015 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
1016 a feature, not a bug.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
1017 @end deftypefn")
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1018 {
2281
7d11fd3aaaa1 [project @ 1996-05-24 19:58:59 by jwe]
jwe
parents: 2275
diff changeset
1019 octave_value retval;
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1020
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1021 int nargin = args.length ();
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1022
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1023 if (nargin == 1)
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1024 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
1025 std::string hint = args(0).string_value ();
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1026
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1027 if (! error_state)
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1028 {
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1029 int n = 32;
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1030
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1031 string_vector list (n);
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1032
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1033 int k = 0;
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1034
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1035 for (;;)
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1036 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
1037 std::string cmd = generate_completion (hint, k);
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1038
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1039 if (! cmd.empty ())
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1040 {
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1041 if (k == n)
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1042 {
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1043 n *= 2;
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1044 list.resize (n);
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1045 }
2235
896966940135 [project @ 1996-05-17 18:09:01 by jwe]
jwe
parents: 2234
diff changeset
1046
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
1047 list[k++] = cmd;
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1048 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1049 else
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1050 {
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1051 list.resize (k);
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1052 break;
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1053 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1054 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1055
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1056 if (nargout > 0)
2281
7d11fd3aaaa1 [project @ 1996-05-24 19:58:59 by jwe]
jwe
parents: 2275
diff changeset
1057 {
7d11fd3aaaa1 [project @ 1996-05-24 19:58:59 by jwe]
jwe
parents: 2275
diff changeset
1058 if (! list.empty ())
7d11fd3aaaa1 [project @ 1996-05-24 19:58:59 by jwe]
jwe
parents: 2275
diff changeset
1059 retval = list;
2282
e50d337478a5 [project @ 1996-05-24 20:11:14 by jwe]
jwe
parents: 2281
diff changeset
1060 else
e50d337478a5 [project @ 1996-05-24 20:11:14 by jwe]
jwe
parents: 2281
diff changeset
1061 retval = "";
2281
7d11fd3aaaa1 [project @ 1996-05-24 19:58:59 by jwe]
jwe
parents: 2275
diff changeset
1062 }
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1063 else
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1064 {
2235
896966940135 [project @ 1996-05-17 18:09:01 by jwe]
jwe
parents: 2234
diff changeset
1065 // We don't use string_vector::list_in_columns here
896966940135 [project @ 1996-05-17 18:09:01 by jwe]
jwe
parents: 2234
diff changeset
1066 // because it will be easier for Emacs if the names
896966940135 [project @ 1996-05-17 18:09:01 by jwe]
jwe
parents: 2234
diff changeset
1067 // appear in a single column.
896966940135 [project @ 1996-05-17 18:09:01 by jwe]
jwe
parents: 2234
diff changeset
1068
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1069 int len = list.length ();
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1070
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1071 for (int i = 0; i < len; i++)
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1072 octave_stdout << list[i] << "\n";
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1073 }
2299
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
1074
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
1075 octave_completion_matches_called = true;
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1076 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1077 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1078 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1079 print_usage ();
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1080
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1081 return retval;
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1082 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1083
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1084 DEFUN (read_readline_init_file, args, ,
3448
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3373
diff changeset
1085 "-*- texinfo -*-\n\
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3373
diff changeset
1086 @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
1087 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
1088 @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
1089 @file{~/.inputrc}).\n\
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6489
diff changeset
1090 \n\
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6489
diff changeset
1091 @xref{Readline Init File, , , readline, GNU Readline Library},\n\
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6489
diff changeset
1092 for details.\n\
3448
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3373
diff changeset
1093 @end deftypefn")
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1094 {
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1095 octave_value_list retval;
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1096
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1097 int nargin = args.length ();
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1098
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1099 if (nargin == 0)
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1100 command_editor::read_init_file ();
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1101 else if (nargin == 1)
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1102 {
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5832
diff changeset
1103 std::string file = args(0).string_value ();
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1104
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1105 if (! error_state)
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1106 command_editor::read_init_file (file);
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1107 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1108 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1109 print_usage ();
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1110
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1111 return retval;
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1112 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1113
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1114 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
1115 "-*- texinfo -*-\n\
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1116 @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
1117 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
1118 @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
1119 for details.\n\
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1120 @end deftypefn")
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1121 {
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1122 octave_value_list retval;
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1123
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1124 if (args.length () == 0)
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1125 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
1126 else
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1127 print_usage ();
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1128
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1129 return retval;
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1130 }
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1131
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
1132 static std::string hook_fcn;
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1133 static octave_value user_data;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1134
4802
b3f20980be32 [project @ 2004-02-25 05:14:19 by jwe]
jwe
parents: 4604
diff changeset
1135 static int
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3503
diff changeset
1136 input_event_hook (void)
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1137 {
4526
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1138 if (is_valid_function (hook_fcn))
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1139 {
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1140 if (user_data.is_defined ())
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1141 feval (hook_fcn, user_data, 0);
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1142 else
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1143 feval (hook_fcn, octave_value_list (), 0);
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1144 }
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1145 else
4526
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1146 {
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1147 hook_fcn = std::string ();
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1148 user_data = octave_value ();
8952973c6837 [project @ 2003-10-02 18:33:58 by jwe]
jwe
parents: 4272
diff changeset
1149
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 6620
diff changeset
1150 command_editor::remove_event_hook (input_event_hook);
4802
b3f20980be32 [project @ 2004-02-25 05:14:19 by jwe]
jwe
parents: 4604
diff changeset
1151 }
b3f20980be32 [project @ 2004-02-25 05:14:19 by jwe]
jwe
parents: 4604
diff changeset
1152
b3f20980be32 [project @ 2004-02-25 05:14:19 by jwe]
jwe
parents: 4604
diff changeset
1153 return 0;
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1154 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1155
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1156 DEFUN (input_event_hook, args, ,
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1157 "-*- texinfo -*-\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1158 @deftypefn {Built-in Function} {[@var{ofcn}, @var{odata}] =} input_event_hook (@var{fcn}, @var{data})\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1159 Given the name of a function as a string and any Octave value object,\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1160 install @var{fcn} as a function to call periodically, when Octave is\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1161 waiting for input. The function should have the form\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1162 @example\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1163 @var{fcn} (@var{data})\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1164 @end example\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1165 \n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1166 If @var{data} is omitted, Octave calls the function without any\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1167 arguments. If both @var{fcn} and @var{data} are omitted, Octave\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1168 clears the hook. In all cases, the name of the previous hook function\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1169 and the user data are returned.\n\
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1170 @end deftypefn")
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1171 {
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1172 octave_value_list retval;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1173
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1174 int nargin = args.length ();
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1175
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1176 if (nargin > 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1177 print_usage ();
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1178 else
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1179 {
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1180 octave_value tmp_user_data;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1181
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
1182 std::string tmp_hook_fcn;
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1183
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1184 if (nargin > 1)
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1185 tmp_user_data = args(1);
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1186
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1187 if (nargin > 0)
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1188 {
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1189 tmp_hook_fcn = args(0).string_value ();
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1190
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1191 if (error_state)
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1192 {
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1193 error ("input_event_hook: expecting string as first arg");
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1194 return retval;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1195 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1196
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 6620
diff changeset
1197 command_editor::add_event_hook (input_event_hook);
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1198 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1199
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1200 if (nargin == 0)
6913
f779c83d6ccf [project @ 2007-09-18 18:58:12 by jwe]
jwe
parents: 6620
diff changeset
1201 command_editor::remove_event_hook (input_event_hook);
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1202
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1203 retval(1) = user_data;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1204 retval(0) = hook_fcn;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1205
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1206 hook_fcn = tmp_hook_fcn;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1207 user_data = tmp_user_data;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1208 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1209
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1210 return retval;
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1211 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1212
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1213 DEFUN (PS1, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1214 "-*- texinfo -*-\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1215 @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1216 @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1217 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
1218 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
1219 \n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1220 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
1221 To change it, use a command like\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1222 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1223 @example\n\
7097
e8c94e473c68 [project @ 2007-11-02 17:24:23 by jwe]
jwe
parents: 7017
diff changeset
1224 octave:13> PS1 (\"\\\\u@@\\\\H> \")\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1225 @end example\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1226 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1227 @noindent\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1228 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
1229 @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
1230 backslashes are required to enter a backslash into a double-quoted\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1231 character string.\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1232 @xref{Strings}.\n\
6373
b3c37bc17c5f [project @ 2007-03-01 15:49:03 by jwe]
jwe
parents: 6367
diff changeset
1233 @seealso{PS2, PS4}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1234 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1235 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1236 return SET_INTERNAL_VARIABLE (PS1);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1237 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1238
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1239 DEFUN (PS2, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1240 "-*- texinfo -*-\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1241 @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1242 @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1243 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
1244 printed when Octave is expecting additional input to complete a\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1245 command. For example, if you are typing a for loop that spans several\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1246 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
1247 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
1248 string is @code{\"> \"}.\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1249 @seealso{PS1, PS4}\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1250 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1251 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1252 return SET_INTERNAL_VARIABLE (PS2);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1253 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1254
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1255 DEFUN (PS4, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1256 "-*- texinfo -*-\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1257 @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1258 @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1259 Query or set the character string used to prefix output produced\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1260 when echoing commands when @code{echo_executing_commands} is enabled.\n\
6620
bf4bdc21dc8d [project @ 2007-05-14 17:35:46 by jwe]
jwe
parents: 6615
diff changeset
1261 The default value is @code{\"+ \"}.\n\
bf4bdc21dc8d [project @ 2007-05-14 17:35:46 by jwe]
jwe
parents: 6615
diff changeset
1262 @xref{Invoking Octave from the Command Line}, for a description of\n\
bf4bdc21dc8d [project @ 2007-05-14 17:35:46 by jwe]
jwe
parents: 6615
diff changeset
1263 @code{--echo-commands}.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1264 @seealso{echo_executing_commands, PS1, PS2}\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1265 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1266 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1267 return SET_INTERNAL_VARIABLE (PS4);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1268 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1269
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1270 DEFUN (completion_append_char, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1271 "-*- texinfo -*-\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1272 @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1273 @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1274 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
1275 successful command-line completion attempts. The default\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1276 value is @code{\" \"} (a single space).\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1277 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1278 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1279 return SET_INTERNAL_VARIABLE (completion_append_char);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1280 }
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
1281
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1282 DEFUN (echo_executing_commands, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1283 "-*- texinfo -*-\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1284 @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1285 @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1286 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
1287 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
1288 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1289 @table @asis\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1290 @item 1\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1291 Echo commands read from script files.\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1292 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1293 @item 2\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1294 Echo commands from functions.\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1295 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1296 @item 4\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1297 Echo commands read from command line.\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1298 @end table\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1299 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1300 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
1301 equivalent to the command @kbd{echo on all}.\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1302 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1303 The value of @code{echo_executing_commands} is set by the @kbd{echo}\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3258
diff changeset
1304 command and the command line option @code{--echo-input}.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1305 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1306 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1307 return SET_INTERNAL_VARIABLE (echo_executing_commands);
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1308 }
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1309
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1310 DEFUN (__request_drawnow__, args, ,
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1311 "-*- texinfo -*-\n\
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1312 @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1313 @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
1314 Undocumented internal function.\n\
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1315 @end deftypefn")
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1316 {
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1317 octave_value retval;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1318
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1319 int nargin = args.length ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1320
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1321 if (nargin == 0)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1322 Vdrawnow_requested = true;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1323 else if (nargin == 1)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1324 Vdrawnow_requested = args(0).bool_value ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1325 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1326 print_usage ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1327
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1328 return retval;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1329 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1330
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1331 DEFUN (__gud_mode__, args, ,
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1332 "-*- texinfo -*-\n\
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1333 @deftypefn {Built-in Function} {} __gud_mode__ ()\n\
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1334 Undocumented internal function.\n\
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1335 @end deftypefn")
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1336 {
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1337 octave_value retval;
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1338
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1339 int nargin = args.length ();
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1340
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1341 if (nargin == 0)
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1342 retval = Vgud_mode;
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1343 else if (nargin == 1)
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1344 Vgud_mode = args(0).bool_value ();
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1345 else
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1346 print_usage ();
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1347
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1348 return retval;
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1349 }
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1350
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1351 DEFUN (filemarker, args, nargout,
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1352 "-*- texinfo -*-\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1353 @deftypefn {Built-in Function} {} filemarker ()\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1354 Returns or sets the character used to separate filename from the\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1355 the subfunction names contained within the file. This can be used in\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1356 a generic manner to interact with subfunctions. For example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1357 \n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1358 @example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1359 help ([\"myfunc\", filemarker, \"mysubfunc\"])\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1360 @end example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1361 \n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1362 @noindent\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1363 returns the help string associated with the sub-function @code{mysubfunc}\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1364 of the function @code{myfunc}. Another use of @code{filemarker} is when\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1365 debugging it allows easier placement of breakpoints within sub-functions.\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1366 For example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1367 \n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1368 @example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1369 dbstop ([\"myfunc\", filemarker, \"mysubfunc\"])\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1370 @end example\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1371 \n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1372 @noindent\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1373 will set a breakpoint at the first line of the subfunction @code{mysubfunc}.\n\
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1374 @end deftypefn")
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1375 {
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1376 char tmp = Vfilemarker;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1377 octave_value retval = SET_INTERNAL_VARIABLE (filemarker);
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1378
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1379 // 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
1380 if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_'))
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1381 {
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1382 Vfilemarker = tmp;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1383 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
1384 }
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1385
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1386 return retval;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1387 }
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1388
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1389 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1390 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1391 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1392 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1393 */