annotate libinterp/corefcn/input.cc @ 21966:112b20240c87

move docstrings in C++ files out of C strings and into comments * __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc, dlmread.cc, dot.cc, eig.cc, ellipj.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, graphics.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-oct-text.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc, oct-hist.cc, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, octave.cc, pt-arg-list.cc, pt-binop.cc, pt-eval.cc, pt-mat.cc, lex.ll, oct-parse.in.yy: Docstrings are now comments instead of C strings. * build-aux/mk-opts.pl: Emit docstrings as comments instead of C strings. * DASPK-opts.in, LSODE-opts.in: Don't quote " in docstring fragments. * builtins.h: Include builtin-defun-decls.h unconditionally. * defun.h (DEFUN, DEFUNX, DEFCONSTFUN): Simply emit declaration. (DEFALIAS): Always expand to nothing. * defun-dld.h: No special macro expansions for MAKE_BUILTINS. (DEFUN_DLD): Use FORWARD_DECLARE_FUN. (DEFUNX_DLD): Use FORWARD_DECLARE_FUNX. * defun-int.h: No special macro expansions for MAKE_BUILTINS. (FORWARD_DECLARE_FUN, FORWARD_DECLARE_FUNX): New macros. (DEFINE_FUN_INSTALLER_FUN): If compiling an Octave source file, pass "external-doc" to DEFINE_FUNX_INSTALLER_FUN. (DEFUN_INTERNAL, DEFCONSTFUN_INTERNAL, DEFUNX_INTERNAL, DEFALIAS_INTERNAL): Delete. * common.mk (move_if_change_rule): New macro. (simple_move_if_change_rule): Define using move_if_change_rule. * find-defun-files.sh (DEFUN_PATTERN): Update. Don't transform file name extension to ".df". * libinterp/mk-pkg-add, gendoc.pl: Operate directly on source files. * mkbuiltins: New argument, SRCDIR. Operate directly on source files. * mkdefs: Delete. * libinterp/module.mk (BUILT_SOURCES): Update list to contain only files included in other source files. (GENERATED_MAKE_BUILTINS_INCS, DEF_FILES): Delete. (LIBINTERP_BUILT_DISTFILES): Include $(OPT_HANDLERS) here. (LIBINTERP_BUILT_NODISTFILES): Not here. Remove $(ALL_DEF_FILES from the list. (libinterp_EXTRA_DIST): Remove mkdefs from the list. (FOUND_DEFUN_FILES): Rename from SRC_DEF_FILES. (DLDFCN_DEFUN_FILES): Rename from DLDFCN_DEF_FILES. (SRC_DEFUN_FILES): Rename from SRC_DEF_FILES. (ALL_DEFUN_FILES): Rename from ALL_DEF_FILES. (%.df: %.cc): Delete pattern rule. (libinterp/build-env-features.cc, libinterp/builtins.cc, libinterp/dldfcn/PKG_ADD): Use mv instead of move-if-change. (libinterp/builtins.cc, libinterp/builtin-defun-decls.h): Update mkbuiltins command. ($(srcdir)/libinterp/DOCSTRINGS): Update gendoc.pl command. * liboctave/module.mk (BUILT_SOURCES): Don't include liboctave-build-info.cc in the list.
author John W. Eaton <jwe@octave.org>
date Tue, 21 Jun 2016 16:07:51 -0400
parents 13e0fc0dfa0c
children 6db928d06b07
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
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
3 Copyright (C) 1993-2015 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
2939
f2feebf0eb7d [project @ 1997-05-06 16:36:34 by jwe]
jwe
parents: 2927
diff changeset
23 // Get command input interactively or from files.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
24
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21547
diff changeset
25 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
26 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
29 #include <cstdio>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
30 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
31 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
32 #include <cassert>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
33
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3498
diff changeset
34 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
35 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1705
diff changeset
36 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1705
diff changeset
37
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
38 #include "cmd-edit.h"
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
39 #include "file-ops.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4143
diff changeset
40 #include "quit.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
41 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
42
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
43 #include "debug.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
44 #include "defun.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
45 #include "dirfns.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21078
diff changeset
47 #include "errwarn.h"
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
48 #include "help.h"
16381
f33dcbd6a005 move hook_function classes to separate file
John W. Eaton <jwe@octave.org>
parents: 16378
diff changeset
49 #include "hook-fcn.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
50 #include "input.h"
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9485
diff changeset
51 #include "lex.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
52 #include "load-path.h"
16416
169f71c9d9c8 use octave_link instead of hook functions in input.cc
John W. Eaton <jwe@octave.org>
parents: 16395
diff changeset
53 #include "octave-link.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
54 #include "oct-map.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
55 #include "oct-hist.h"
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1606
diff changeset
56 #include "toplev.h"
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
57 #include "octave-link.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
58 #include "ovl.h"
16347
bf8397caeff1 allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents: 16336
diff changeset
59 #include "ov-fcn-handle.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60 #include "pager.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
61 #include "parse.h"
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3741
diff changeset
62 #include "pt.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
63 #include "pt-const.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
64 #include "pt-eval.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents: 3804
diff changeset
65 #include "pt-stmt.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
66 #include "sighandlers.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
67 #include "symtab.h"
1114
971f2289d6de [project @ 1995-02-15 04:58:06 by jwe]
jwe
parents: 1112
diff changeset
68 #include "sysdep.h"
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
69 #include "toplev.h"
3098
f4acdc9a77cc [project @ 1997-11-14 09:30:20 by jwe]
jwe
parents: 3081
diff changeset
70 #include "unwind-prot.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
71 #include "utils.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
72 #include "variables.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
73
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
74 // Primary prompt string.
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
75 static std::string VPS1;
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
76
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
77 // Secondary prompt string.
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
78 static std::string VPS2;
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
79
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
80 // String printed before echoed input (enabled by --echo-input).
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
81 std::string VPS4 = "+ ";
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
82
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
83 // Echo commands as they are executed?
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
84 //
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
85 // 1 ==> echo commands read from script files
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
86 // 2 ==> echo commands from functions
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
87 // 4 ==> echo commands read from command line
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
88 //
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
89 // more than one state can be active at once.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
90 int Vecho_executing_commands = ECHO_OFF;
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
91
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 3100
diff changeset
92 // The time we last printed a prompt.
21730
30c53770f47e use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
93 octave::sys::time Vlast_prompt_time = 0.0;
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 3100
diff changeset
94
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
95 // Character to append after successful command-line completion attempts.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
96 static char Vcompletion_append_char = ' ';
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
97
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
98 // TRUE means this is an interactive shell (either forced or not)
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
99 bool interactive = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
100
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
101 // TRUE means the user forced this shell to be interactive (-i).
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
102 // FALSE means the shell would be interactive, independent of user settings.
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
103 bool forced_interactive = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
104
3804
4073be5aefa1 [project @ 2001-02-28 08:36:04 by jwe]
jwe
parents: 3772
diff changeset
105 // TRUE after a call to completion_matches.
2299
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
106 bool octave_completion_matches_called = false;
f296bbc757a1 [project @ 1996-06-23 03:45:44 by jwe]
jwe
parents: 2287
diff changeset
107
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
108 // 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
109 // the next user prompt.
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7336
diff changeset
110 bool Vdrawnow_requested = false;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
111
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
112 // TRUE if we are in debugging mode.
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
113 bool Vdebugging = false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
114
8841
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
115 // If we are in debugging mode, this is the last command entered, so
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
116 // that we can repeat the previous command if the user just types RET.
16336
0ce49f9fb171 "\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents: 16288
diff changeset
117 static std::string last_debugging_command = "\n";
8841
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
118
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
119 // 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
120 static bool Vgud_mode = false;
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
121
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
122 // The filemarker used to separate filenames from subfunction names
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
123 char Vfilemarker = '>';
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
124
16378
b28ae106e316 use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents: 16374
diff changeset
125 static hook_function_list input_event_hook_functions;
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
126
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
127 // For octave_quit.
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
128 void
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
129 remove_input_event_hook_functions (void)
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
130 {
16378
b28ae106e316 use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents: 16374
diff changeset
131 input_event_hook_functions.clear ();
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
132 }
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
133
16209
e7ff32e7cf82 move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
134 void
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
135 set_default_prompts (void)
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
136 {
18037
708173343c50 use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
137 // Use literal "octave" instead of "\\s" to avoid setting the prompt
708173343c50 use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
138 // to "octave.exe" or "octave-gui", etc.
708173343c50 use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
139
708173343c50 use "octave" instead of "\\s" in default prompt
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
140 VPS1 = "octave:\\#> ";
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
141 VPS2 = "> ";
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
142 VPS4 = "+ ";
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
143
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
144 octave_link::set_default_prompts (VPS1, VPS2, VPS4);
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
145 }
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
146
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16524
diff changeset
147 void
16209
e7ff32e7cf82 move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
148 octave_base_reader::do_input_echo (const std::string& input_string) const
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
149 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
150 int do_echo = reading_script_file ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
151 ? (Vecho_executing_commands & ECHO_SCRIPTS)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
152 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
153
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
154 if (do_echo)
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
155 {
1403
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
156 if (forced_interactive)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
157 {
16209
e7ff32e7cf82 move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
158 if (pflag > 0)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
159 octave_stdout << octave::command_editor::decode_prompt_string (VPS1);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
160 else
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
161 octave_stdout << octave::command_editor::decode_prompt_string (VPS2);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
162 }
1403
69d15711b832 [project @ 1995-09-15 05:25:16 by jwe]
jwe
parents: 1363
diff changeset
163 else
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
164 octave_stdout << octave::command_editor::decode_prompt_string (VPS4);
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
165
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
166 if (! input_string.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
167 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
168 octave_stdout << input_string;
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
169
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
170 if (input_string[input_string.length () - 1] != '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
171 octave_stdout << "\n";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
172 }
1044
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
173 }
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
174 }
1aa6f2edd975 [project @ 1995-01-18 16:35:01 by jwe]
jwe
parents: 1034
diff changeset
175
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
176 static std::string
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
177 gnu_readline (const std::string& s, bool& eof)
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
178 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 10066
diff changeset
179 octave_quit ();
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
180
16097
2f4fa62089b3 improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
181 eof = false;
2f4fa62089b3 improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
182
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
183 std::string retval = octave::command_editor::readline (s, eof);
19595
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19379
diff changeset
184
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
185 if (! eof && retval.empty ())
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
186 retval = "\n";
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
187
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
188 return retval;
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
189 }
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
190
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
191 static inline std::string
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
192 interactive_input (const std::string& s, bool& eof)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
193 {
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
194 Vlast_prompt_time.stamp ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
195
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
196 if (Vdrawnow_requested && interactive)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
197 {
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
198 bool eval_error = false;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
199
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
200 try
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
201 {
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
202 feval ("drawnow");
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
203 }
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
204 catch (const octave_execution_exception& e)
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
205 {
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
206 eval_error = true;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
207
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
208 std::string stack_trace = e.info ();
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
209
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
210 if (! stack_trace.empty ())
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
211 std::cerr << stack_trace;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
212
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
213 if (interactive)
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
214 recover_from_exception ();
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
215 }
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
216
6367
268bfc8a2755 [project @ 2007-02-28 20:16:05 by jwe]
jwe
parents: 6317
diff changeset
217 flush_octave_stdout ();
268bfc8a2755 [project @ 2007-02-28 20:16:05 by jwe]
jwe
parents: 6317
diff changeset
218
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
219 // We set Vdrawnow_requested to false even if there is an error in
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
220 // drawnow so that the error doesn't reappear at every prompt.
6305
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
221
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
222 Vdrawnow_requested = false;
6305
48f8af442b8a [project @ 2007-02-14 22:16:53 by jwe]
jwe
parents: 6257
diff changeset
223
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
224 if (eval_error)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
225 return "\n";
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
226 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
227
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
228 return gnu_readline (s, eof);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
229 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
230
16195
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
231 std::string
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
232 octave_base_reader::octave_gets (bool& eof)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
233 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 10066
diff changeset
234 octave_quit ();
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5092
diff changeset
235
16097
2f4fa62089b3 improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
236 eof = false;
2f4fa62089b3 improve end of file handling for lexer input
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
237
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
238 std::string retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
239
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
240 // Process pre input event hook function prior to flushing output and
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
241 // printing the prompt.
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
242
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
243 if (interactive)
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
244 {
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
245 if (! Vdebugging)
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
246 octave_link::exit_debugger_event ();
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
247
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
248 octave_link::pre_input_event ();
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
249
16524
6a8e63dadfad provide octave_link::set_workspace function with default values
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
250 octave_link::set_workspace ();
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
251 }
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
252
8841
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
253 bool history_skip_auto_repeated_debugging_command = false;
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
254
16209
e7ff32e7cf82 move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
255 std::string ps = (pflag > 0) ? VPS1 : VPS2;
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
256
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
257 std::string prompt = octave::command_editor::decode_prompt_string (ps);
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
258
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
259 pipe_handler_error_count = 0;
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
260
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
261 flush_octave_stdout ();
2618
aa667ac18d12 [project @ 1997-01-23 03:16:28 by jwe]
jwe
parents: 2470
diff changeset
262
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
263 octave_pager_stream::reset ();
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
264 octave_diary_stream::reset ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
265
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
266 octave_diary << prompt;
13266
c053740eb2aa improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents: 12989
diff changeset
267
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
268 retval = interactive_input (prompt, eof);
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
269
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
270 // There is no need to update the load_path cache if there is no
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
271 // user input.
16336
0ce49f9fb171 "\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents: 16288
diff changeset
272 if (retval != "\n"
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
273 && retval.find_first_not_of (" \t\n\r") != std::string::npos)
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
274 {
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
275 load_path::update ();
8841
c74389115610 auto repeat for debugging commands
John W. Eaton <jwe@octave.org>
parents: 8749
diff changeset
276
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
277 if (Vdebugging)
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
278 last_debugging_command = retval;
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
279 else
16336
0ce49f9fb171 "\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents: 16288
diff changeset
280 last_debugging_command = "\n";
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
281 }
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
282 else if (Vdebugging)
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
283 {
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
284 retval = last_debugging_command;
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
285 history_skip_auto_repeated_debugging_command = true;
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
286 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
287
16336
0ce49f9fb171 "\n" is the new empty string (bug #38552)
John W. Eaton <jwe@octave.org>
parents: 16288
diff changeset
288 if (retval != "\n")
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
289 {
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
290 if (! history_skip_auto_repeated_debugging_command)
17215
7c06875c2dcc Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents: 17214
diff changeset
291 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
292 if (octave::command_history::add (retval))
17215
7c06875c2dcc Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents: 17214
diff changeset
293 octave_link::append_history (retval);
7c06875c2dcc Backed out changeset 3d1205d5771e
John W. Eaton <jwe@octave.org>
parents: 17214
diff changeset
294 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
295
16207
0467d68ca891 move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
296 octave_diary << retval;
3176
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
297
16207
0467d68ca891 move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
298 if (retval[retval.length () - 1] != '\n')
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
299 octave_diary << "\n";
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
300
16207
0467d68ca891 move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
301 do_input_echo (retval);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
302 }
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
303 else
3176
fccab8e7d35f [project @ 1998-05-18 20:33:31 by jwe]
jwe
parents: 3165
diff changeset
304 octave_diary << "\n";
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9396
diff changeset
305
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
306 // Process post input event hook function after the internal history
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
307 // list has been updated.
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
308
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
309 if (interactive)
16433
2c8860d563e5 fix incorrect call to octave_link::pre_input_event
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
310 octave_link::post_input_event ();
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
311
1822
3a47ca3dd227 [project @ 1996-02-01 08:06:35 by jwe]
jwe
parents: 1799
diff changeset
312 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
313 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314
17731
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
315 bool
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
316 octave_base_reader::reading_fcn_file (void) const
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
317 {
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
318 return lexer ? lexer->reading_fcn_file : false;
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
319 }
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
320
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
321 bool
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
322 octave_base_reader::reading_classdef_file (void) const
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
323 {
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
324 return lexer ? lexer->reading_classdef_file : false;
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
325 }
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
326
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
327 bool
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
328 octave_base_reader::reading_script_file (void) const
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
329 {
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
330 return lexer ? lexer->reading_script_file : false;
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
331 }
f79bf671a493 eliminate global LEXER variable
John W. Eaton <jwe@octave.org>
parents: 17323
diff changeset
332
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
333 // 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
334 // 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
335 // separate function.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
336
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
337 FILE *
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
338 get_input_from_stdin (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
339 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
340 octave::command_editor::set_input_stream (stdin);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
341 return octave::command_editor::get_input_stream ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
342 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
343
20713
2469d78a1d8b Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents: 20704
diff changeset
344 // FIXME: make this generate filenames when appropriate.
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
345
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
346 static string_vector
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
347 generate_possible_completions (const std::string& text, std::string& prefix,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
348 std::string& hint)
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
349 {
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
350 string_vector names;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
351
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
352 prefix = "";
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
353
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
354 if (looks_like_struct (text))
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1403
diff changeset
355 names = generate_struct_completions (text, prefix, hint);
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1403
diff changeset
356 else
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
357 names = make_name_list ();
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
358
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
359 // Sort and remove duplicates.
2348
a88c5cc51f62 [project @ 1996-07-25 09:54:40 by jwe]
jwe
parents: 2327
diff changeset
360
8503
8ba2ee57c594 remove qsort in favor of sort
Jaroslav Hajek <highegg@gmail.com>
parents: 8447
diff changeset
361 names.sort (true);
2348
a88c5cc51f62 [project @ 1996-07-25 09:54:40 by jwe]
jwe
parents: 2327
diff changeset
362
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
363 return names;
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
364 }
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
365
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
366 static bool
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
367 is_completing_dirfns (void)
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
368 {
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
369 static std::string dirfns_commands[] = {"cd", "ls"};
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
370 static const size_t dirfns_commands_length = 2;
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
371
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
372 bool retval = false;
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
373
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
374 std::string line = octave::command_editor::get_line_buffer ();
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
375
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
376 for (size_t i = 0; i < dirfns_commands_length; i++)
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
377 {
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
378 int index = line.find (dirfns_commands[i] + " ");
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
379
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
380 if (index == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
381 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
382 retval = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
383 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
384 }
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
385 }
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
386
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
387 return retval;
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
388 }
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
389
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
390 static std::string
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
391 generate_completion (const std::string& text, int state)
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
392 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
393 std::string retval;
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
394
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
395 static std::string prefix;
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3519
diff changeset
396 static std::string hint;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
397
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
398 static size_t hint_len = 0;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
399
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
400 static int list_index = 0;
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
401 static int name_list_len = 0;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
402 static int name_list_total_len = 0;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
403 static string_vector name_list;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
404 static string_vector file_name_list;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
405
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
406 static int matches = 0;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
408 if (state == 0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
409 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
410 list_index = 0;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
411
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
412 prefix = "";
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
413
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
414 hint = text;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
415
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
416 // No reason to display symbols while completing a
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
417 // file/directory operation.
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
418
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
419 if (is_completing_dirfns ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
420 name_list = string_vector ();
9485
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
421 else
3cee58bf4acf selectively complete filenames in some cases
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
422 name_list = generate_possible_completions (text, prefix, hint);
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
423
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20178
diff changeset
424 name_list_len = name_list.numel ();
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
425
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
426 file_name_list = octave::command_editor::generate_filename_completions (text);
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
427
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
428 name_list.append (file_name_list);
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
429
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20178
diff changeset
430 name_list_total_len = name_list.numel ();
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
431
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
432 hint_len = hint.length ();
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
433
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
434 matches = 0;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
435
2921
64dd86522a1d [project @ 1997-05-02 02:52:54 by jwe]
jwe
parents: 2900
diff changeset
436 for (int i = 0; i < name_list_len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
437 if (hint == name_list[i].substr (0, hint_len))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
438 matches++;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
439 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
440
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
441 if (name_list_total_len > 0 && matches > 0)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
442 {
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4565
diff changeset
443 while (list_index < name_list_total_len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
444 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
445 std::string name = name_list[list_index];
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
446
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
447 list_index++;
2247
108d848901b4 [project @ 1996-05-22 07:39:29 by jwe]
jwe
parents: 2235
diff changeset
448
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
449 if (hint == name.substr (0, hint_len))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
450 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
451 if (list_index <= name_list_len && ! prefix.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
452 retval = prefix + "." + name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
453 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
454 retval = name;
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
455
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
456 // FIXME: looks_like_struct is broken for now,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
457 // so it always returns false.
4179
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
458
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
459 if (matches == 1 && looks_like_struct (retval))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
460 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
461 // Don't append anything, since we don't know
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
462 // whether it should be '(' or '.'.
4179
8734ba917fea [project @ 2002-11-14 04:31:19 by jwe]
jwe
parents: 4170
diff changeset
463
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
464 octave::command_editor::set_completion_append_character ('\0');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
465 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
466 else
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
467 octave::command_editor::set_completion_append_character
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
468 (Vcompletion_append_char);
1280
b01f9577b0da [project @ 1995-04-26 17:49:19 by jwe]
jwe
parents: 1215
diff changeset
469
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
470 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
471 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
472 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
473 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
474
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
475 return retval;
1
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
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
478 static std::string
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
479 quoting_filename (const std::string &text, int, char quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
480 {
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
481 if (quote)
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
482 return text;
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
483 else
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
484 return (std::string ("'") + text);
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
485 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
486
2927
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
487 void
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
488 initialize_command_input (void)
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
489 {
8722c6284b72 [project @ 1997-05-05 03:44:04 by jwe]
jwe
parents: 2921
diff changeset
490 // 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
491 // .inputrc file.
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
492
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
493 octave::command_editor::set_name ("Octave");
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
494
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
495 // 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
496 // causes trouble for the new struct element completion code.
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
497
4272
fd406afe8a10 [project @ 2003-01-03 19:52:30 by jwe]
jwe
parents: 4253
diff changeset
498 static const char *s = "\t\n !\"\'*+-/:;<=>(){}[\\]^`~";
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
499
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
500 octave::command_editor::set_basic_word_break_characters (s);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
501
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
502 octave::command_editor::set_completer_word_break_characters (s);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3877
diff changeset
503
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
504 octave::command_editor::set_basic_quote_characters ("\"");
2944
e9c24f32f175 [project @ 1997-05-08 02:42:22 by jwe]
jwe
parents: 2939
diff changeset
505
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
506 octave::command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
507 octave::command_editor::set_completer_quote_characters ("'\"");
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
508
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
509 octave::command_editor::set_completion_function (generate_completion);
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 6945
diff changeset
510
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
511 octave::command_editor::set_quoting_function (quoting_filename);
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
512 }
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
513
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
514 static void
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
515 execute_in_debugger_handler (const std::pair<std::string, int>& arg)
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
516 {
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
517 octave_link::execute_in_debugger_event (arg.first, arg.second);
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
518 }
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
519
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
520 static void
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
521 get_debug_input (const std::string& prompt)
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
522 {
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
523 octave::unwind_protect frame;
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
524
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
525 bool silent = tree_evaluator::quiet_breakpoint_flag;
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
526 tree_evaluator::quiet_breakpoint_flag = false;
19595
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19379
diff changeset
527
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
528 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
529 std::string nm;
18595
a87bdd302b1b set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents: 18037
diff changeset
530 int curr_debug_line;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
531
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
532 bool have_file = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
533
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
534 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
535 {
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
536 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
537
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
538 if (nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
539 nm = caller->name ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
540 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
541 have_file = true;
18595
a87bdd302b1b set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents: 18037
diff changeset
542
a87bdd302b1b set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents: 18037
diff changeset
543 curr_debug_line = octave_call_stack::caller_user_code_line ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
544 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
545 else
18595
a87bdd302b1b set editor cursor on error line when debug_on_error is true (bug #41532)
John W. Eaton <jwe@octave.org>
parents: 18037
diff changeset
546 curr_debug_line = octave_call_stack::current_line ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
547
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
548 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
549
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
550 if (! nm.empty ())
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
551 {
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
552 if (Vgud_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
553 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
554 static char ctrl_z = 'Z' & 0x1f;
269
0febc87abbd4 [project @ 1994-01-05 08:17:07 by jwe]
jwe
parents: 252
diff changeset
555
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
556 buf << ctrl_z << ctrl_z << nm << ":" << curr_debug_line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
557 }
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
558 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
559 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
560 // FIXME: we should come up with a clean way to detect
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
561 // that we are stopped on the no-op command that marks the
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
562 // end of a function or script.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
563
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
564 if (! silent)
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
565 {
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
566 buf << "stopped in " << nm;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
567
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
568 if (curr_debug_line > 0)
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
569 buf << " at line " << curr_debug_line;
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
570 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
571
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
572 if (have_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
573 {
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
574 octave_link::enter_debugger_event (nm, curr_debug_line);
16395
fc491da603f6 also provide a hook for exiting debugger
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
575
16524
6a8e63dadfad provide octave_link::set_workspace function with default values
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
576 octave_link::set_workspace ();
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
577
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16433
diff changeset
578 frame.add_fcn (execute_in_debugger_handler,
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16416
diff changeset
579 std::pair<std::string, int> (nm, curr_debug_line));
16374
8b0a04cbdc9d provide hook function for dbstop events
John W. Eaton <jwe@octave.org>
parents: 16373
diff changeset
580
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
581 if (! silent)
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
582 {
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
583 std::string line_buf
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
584 = get_file_line (nm, curr_debug_line);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
585
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
586 if (! line_buf.empty ())
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
587 buf << "\n" << curr_debug_line << ": " << line_buf;
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
588 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
589 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
590 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
591 }
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3176
diff changeset
592
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18694
diff changeset
593 if (silent)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
594 octave::command_editor::erase_empty_line (true);
19595
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19379
diff changeset
595
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
596 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
597
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 if (! msg.empty ())
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
599 std::cerr << msg << std::endl;
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
600
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
601 frame.protect_var (VPS1);
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
602 VPS1 = prompt;
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
603
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
604 if (! interactive)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7758
diff changeset
605 {
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
606 frame.protect_var (interactive);
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19701
diff changeset
607 interactive = true;
12907
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
608 frame.protect_var (forced_interactive);
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
609 forced_interactive = true;
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
610 }
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
611
16187
490625211945 don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
612 octave_parser curr_parser;
16151
e309eb7940be parser tweaks
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
613
12907
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
614 while (Vdebugging)
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
615 {
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
616 try
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
617 {
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
618 reset_error_handler ();
12907
6e1b9f079e0f allow debugging when input is not coming from a tty
John W. Eaton <jwe@octave.org>
parents: 12573
diff changeset
619
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
620 curr_parser.reset ();
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9485
diff changeset
621
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
622 int retval = curr_parser.run ();
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9485
diff changeset
623
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
624 if (octave::command_editor::interrupt (false))
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
625 break;
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
626 else
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 16381
diff changeset
627 {
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
628 if (retval == 0 && curr_parser.stmt_list)
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
629 {
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
630 curr_parser.stmt_list->accept (*current_evaluator);
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9485
diff changeset
631
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
632 if (octave_completion_matches_called)
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
633 octave_completion_matches_called = false;
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
634 }
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
635
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
636 octave_quit ();
16382
389b09a914e2 allow gui to force readline to return from its idle/read loop
John W. Eaton <jwe@octave.org>
parents: 16381
diff changeset
637 }
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
638 }
20739
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
639 catch (const octave_execution_exception& e)
20639
31219c56874f don't exit debugger if an error occurs (bug #46251)
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
640 {
20739
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
641 std::string stack_trace = e.info ();
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
642
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
643 if (! stack_trace.empty ())
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
644 std::cerr << stack_trace;
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
645
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20743
diff changeset
646 // Ignore errors when in debugging mode;
20739
9e8a6d6d6de9 restore stack trace for errors that occur in debug mode
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
647 recover_from_exception ();
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9485
diff changeset
648 }
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
649 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
650 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
651
16195
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
652 const std::string octave_base_reader::in_src ("invalid");
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
653
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
654 const std::string octave_terminal_reader::in_src ("terminal");
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
655
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
656 std::string
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
657 octave_terminal_reader::get_input (bool& eof)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
658 {
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
659 octave_quit ();
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
660
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
661 eof = false;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
662
16207
0467d68ca891 move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
663 return octave_gets (eof);
16195
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
664 }
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
665
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
666 const std::string octave_file_reader::in_src ("file");
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
667
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
668 std::string
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
669 octave_file_reader::get_input (bool& eof)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
670 {
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
671 octave_quit ();
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
672
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
673 eof = false;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
674
16207
0467d68ca891 move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
675 return octave_fgets (file, eof);
16195
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
676 }
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
677
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
678 const std::string octave_eval_string_reader::in_src ("eval_string");
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
679
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
680 std::string
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
681 octave_eval_string_reader::get_input (bool& eof)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
682 {
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
683 octave_quit ();
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
684
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
685 eof = false;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
686
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
687 std::string retval;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
688
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
689 retval = eval_string;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
690
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
691 // Clear the eval string so that the next call will return
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
692 // an empty character string with EOF = true.
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
693 eval_string = "";
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
694
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
695 if (retval.empty ())
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
696 eof = true;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
697
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
698 return retval;
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
699 }
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16187
diff changeset
700
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 529
diff changeset
701 // 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
702
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
703 static octave_value_list
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
704 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
705 {
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
706 octave_value_list retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
707
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
708 int read_as_string = 0;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
709
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
710 if (args.length () == 2)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
711 read_as_string++;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
712
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20639
diff changeset
713 std::string prompt = args(0).xstring_value ("input: unrecognized argument");
4975
80842ad3f85c [project @ 2004-09-08 18:37:58 by jwe]
jwe
parents: 4802
diff changeset
714
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
715 flush_octave_stdout ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
716
13266
c053740eb2aa improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents: 12989
diff changeset
717 octave_pager_stream::reset ();
c053740eb2aa improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents: 12989
diff changeset
718 octave_diary_stream::reset ();
c053740eb2aa improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents: 12989
diff changeset
719
4565
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
720 octave_diary << prompt;
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
721
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
722 bool eof = false;
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
723
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
724 std::string input_buf = interactive_input (prompt.c_str (), eof);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
725
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
726 if (input_buf.empty ())
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
727 error ("input: reading user-input failed!");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
728
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
729 size_t len = input_buf.length ();
4565
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
730
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
731 octave_diary << input_buf;
4565
1db951a4fcd5 [project @ 2003-10-29 13:49:30 by jwe]
jwe
parents: 4526
diff changeset
732
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
733 if (input_buf[len - 1] != '\n')
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
734 octave_diary << "\n";
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3741
diff changeset
735
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
736 if (len < 1)
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
737 return read_as_string ? octave_value ("") : octave_value (Matrix ());
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
738
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
739 if (read_as_string)
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
740 {
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
741 // FIXME: fix gnu_readline and octave_gets instead!
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
742 if (input_buf.length () == 1 && input_buf[0] == '\n')
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
743 retval(0) = "";
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
744 else
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
745 retval(0) = input_buf;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
746 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
747 else
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
748 {
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
749 int parse_status = 0;
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
750
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
751 retval = eval_string (input_buf, true, parse_status, nargout);
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
752
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21852
diff changeset
753 if (! Vdebugging && retval.empty ())
20981
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
754 retval(0) = Matrix ();
c11cea70b638 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
755 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
756
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
757 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
758 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
759
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3098
diff changeset
760 DEFUN (input, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
761 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
762 @deftypefn {} {@var{ans} =} input (@var{prompt})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
763 @deftypefnx {} {@var{ans} =} input (@var{prompt}, "s")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
764 Print @var{prompt} and wait for user input.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
765
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
766 For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
767
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
768 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
769 input ("Pick a number, any number! ")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
770 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
771
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
772 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
773 prints the prompt
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
774
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
775 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
776 Pick a number, any number!
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
777 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
778
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
779 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
780 and waits for the user to enter a value. The string entered by the user
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
781 is evaluated as an expression, so it may be a literal constant, a variable
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
782 name, or any other valid Octave code.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
783
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
784 The number of return arguments, their size, and their class depend on the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
785 expression entered.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
786
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
787 If you are only interested in getting a literal string value, you can call
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
788 @code{input} with the character string @qcode{"s"} as the second argument.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
789 This tells Octave to return the string entered by the user directly, without
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
790 evaluating it first.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
791
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
792 Because there may be output waiting to be displayed by the pager, it is a
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
793 good idea to always call @code{fflush (stdout)} before calling @code{input}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
794 This will ensure that all pending output is written to the screen before
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
795 your prompt.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
796 @seealso{yes_or_no, kbhit, pause, menu, listdlg}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
797 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
798 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
799 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
800
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
801 if (nargin < 1 || nargin > 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
802 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
803
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
804 return get_user_input (args, std::max (nargout, 1));
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
805 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
806
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
807 bool
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
808 octave_yes_or_no (const std::string& prompt)
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_string = prompt + "(yes or no) ";
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 while (1)
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
813 {
16198
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
814 bool eof = false;
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
815
2c5c538be353 clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents: 16195
diff changeset
816 std::string input_buf = interactive_input (prompt_string, eof);
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
817
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
818 if (input_buf == "yes")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
819 return true;
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
820 else if (input_buf == "no")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
821 return false;
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
822 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
823 message (0, "Please answer yes or no.");
5640
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 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
826
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
827 DEFUN (yes_or_no, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
828 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
829 @deftypefn {} {@var{ans} =} yes_or_no ("@var{prompt}")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
830 Ask the user a yes-or-no question.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
831
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
832 Return logical true if the answer is yes or false if the answer is no.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
833
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
834 Takes one argument, @var{prompt}, which is the string to display when asking
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
835 the question. @var{prompt} should end in a space; @code{yes-or-no} adds the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
836 string @samp{(yes or no) } to it. The user must confirm the answer with
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
837 @key{RET} and can edit it until it has been confirmed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
838 @seealso{input}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
839 @end deftypefn */)
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
840 {
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
841 int nargin = args.length ();
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
842
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
843 if (nargin > 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
844 print_usage ();
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
845
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
846 std::string prompt;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
847
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
848 if (nargin == 1)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
849 prompt = args(0).xstring_value ("yes_or_no: PROMPT must be a string");
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
850
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21100
diff changeset
851 return ovl (octave_yes_or_no (prompt));
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
852 }
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5388
diff changeset
853
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
854 octave_value
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
855 do_keyboard (const octave_value_list& args)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
856 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
857 octave_value retval;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
858
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
859 int nargin = args.length ();
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 assert (nargin == 0 || nargin == 1);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
862
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
863 octave::unwind_protect frame;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
864
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
865 frame.add_fcn (octave::command_history::ignore_entries,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
866 octave::command_history::ignoring_entries ());
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12942
diff changeset
867
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
868 octave::command_history::ignore_entries (false);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
869
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
870 frame.protect_var (Vdebugging);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
871
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11575
diff changeset
872 frame.add_fcn (octave_call_stack::restore_frame,
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
873 octave_call_stack::current_frame ());
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
874
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
875 // FIXME: probably we just want to print one line, not the
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
876 // entire statement, which might span many lines...
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
877 //
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
878 // tree_print_code tpc (octave_stdout);
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
879 // stmt.accept (tpc);
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9483
diff changeset
880
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
881 Vdebugging = true;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
882
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
883 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
884 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
885 prompt = args(0).string_value ();
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4208
diff changeset
886
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
887 get_debug_input (prompt);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
888
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
889 return retval;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
890 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3566
diff changeset
891
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1900
diff changeset
892 DEFUN (keyboard, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
893 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
894 @deftypefn {} {} keyboard ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
895 @deftypefnx {} {} keyboard ("@var{prompt}")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
896 Stop m-file execution and enter debug mode.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
897
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
898 When the @code{keyboard} function is executed, Octave prints a prompt and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
899 waits for user input. The input strings are then evaluated and the results
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
900 are printed. This makes it possible to examine the values of variables
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
901 within a function, and to assign new values if necessary. To leave the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
902 prompt and return to normal execution type @samp{return} or @samp{dbcont}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
903 The @code{keyboard} function does not return an exit status.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
904
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
905 If @code{keyboard} is invoked without arguments, a default prompt of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
906 @samp{debug> } is used.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
907 @seealso{dbstop, dbcont, dbquit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
908 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
909 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
910 if (args.length () > 1)
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
911 print_usage ();
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
912
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
913 octave::unwind_protect frame;
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9482
diff changeset
914
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
915 frame.add_fcn (octave_call_stack::restore_frame,
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
916 octave_call_stack::current_frame ());
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9482
diff changeset
917
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
918 // Skip the frame assigned to the keyboard function.
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
919 octave_call_stack::goto_frame_relative (0);
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
920
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
921 tree_evaluator::debug_mode = true;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
922 tree_evaluator::quiet_breakpoint_flag = false;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
923
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
924 tree_evaluator::current_frame = octave_call_stack::current_frame ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
925
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
926 do_keyboard (args);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
927
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
928 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
929 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 339
diff changeset
930
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
931 DEFUN (echo, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
932 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
933 @deftypefn {} {} echo
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
934 @deftypefnx {} {} echo on
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
935 @deftypefnx {} {} echo off
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
936 @deftypefnx {} {} echo on all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
937 @deftypefnx {} {} echo off all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
938 Control whether commands are displayed as they are executed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
939
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
940 Valid options are:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
941
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
942 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
943 @item on
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
944 Enable echoing of commands as they are executed in script files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
945
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
946 @item off
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
947 Disable echoing of commands as they are executed in script files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
948
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
949 @item on all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
950 Enable echoing of commands as they are executed in script files and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
951 functions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
952
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
953 @item off all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
954 Disable echoing of commands as they are executed in script files and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
955 functions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
956 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
957
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
958 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
959 With no arguments, @code{echo} toggles the current echo state.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
960 @end deftypefn */)
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
961 {
20996
20bd3d4fabad Clean up instances of make_argv().
Rik <rik@octave.org>
parents: 20981
diff changeset
962 string_vector argv = args.make_argv ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
963
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
964 switch (args.length ())
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
965 {
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20801
diff changeset
966 case 0:
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
967 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
968 if ((Vecho_executing_commands & ECHO_SCRIPTS)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
969 || (Vecho_executing_commands & ECHO_FUNCTIONS))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
970 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
971 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
972 Vecho_executing_commands = ECHO_SCRIPTS;
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
973 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
974 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
975
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20801
diff changeset
976 case 1:
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
977 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
978 std::string arg = argv[0];
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
979
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
980 if (arg == "on")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
981 Vecho_executing_commands = ECHO_SCRIPTS;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
982 else if (arg == "off")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
983 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
984 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
985 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
986 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
987 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
988
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20801
diff changeset
989 case 2:
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
990 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
991 std::string arg = argv[0];
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
992
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
993 if (arg == "on" && argv[1] == "all")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
994 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
995 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
996 Vecho_executing_commands = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
997 }
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
998 else if (arg == "off" && argv[1] == "all")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
999 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
1000 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
1001 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1002 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1003 break;
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 default:
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1006 print_usage ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1007 break;
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1008 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1009
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1010 return ovl ();
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1011 }
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1569
diff changeset
1012
20239
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1013 /*
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1014 %!test
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1015 %! state = echo_executing_commands ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1016 %! unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1017 %! echo ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1018 %! s1 = echo_executing_commands ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1019 %! assert (s1 != state);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1020 %! echo ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1021 %! s2 = echo_executing_commands ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1022 %! assert (s2 != s1);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1023 %! unwind_protect_cleanup
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1024 %! echo_executing_commands (state);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1025 %! end_unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1026
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1027 %!test
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1028 %! state = echo_executing_commands ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1029 %! unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1030 %! echo ("off");
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1031 %! assert (echo_executing_commands () == 0);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1032 %! echo ("on");
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1033 %! assert (echo_executing_commands () != 0);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1034 %! echo ("off");
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1035 %! assert (echo_executing_commands () == 0);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1036 %! unwind_protect_cleanup
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1037 %! echo_executing_commands (state);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1038 %! end_unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1039
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1040 %!#test # FIXME: This passes, but produces a lot of onscreen output
20239
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1041 %! state = echo_executing_commands ();
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1042 %! unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1043 %! echo ("on", "all");
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1044 %! assert (echo_executing_commands () != 0);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1045 %! echo ("off", "all");
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1046 %! assert (echo_executing_commands () == 0);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1047 %! unwind_protect_cleanup
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1048 %! echo_executing_commands (state);
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1049 %! end_unwind_protect
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1050
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1051 %!error echo ([])
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1052 %!error echo (0)
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1053 %!error echo ("")
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1054 %!error echo ("Octave")
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1055 %!error echo ("off", "invalid")
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1056 %!error echo ("on", "invalid")
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1057 %!error echo ("on", "all", "all")
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1058 */
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1059
18765
692e16c9e488 build: Fix some unused parameter warnings from cset 89448a7523b2.
Rik <rik@octave.org>
parents: 18764
diff changeset
1060 DEFUN (__echostate__, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1061 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1062 @deftypefn {} {@var{state} =} __echostate__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1063 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1064 @end deftypefn */)
18764
89448a7523b2 Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18695
diff changeset
1065 {
89448a7523b2 Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18695
diff changeset
1066 return ovl (Vecho_executing_commands == ECHO_SCRIPTS);
89448a7523b2 Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18695
diff changeset
1067 }
89448a7523b2 Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18695
diff changeset
1068
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1069 DEFUN (completion_matches, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1070 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1071 @deftypefn {} {} completion_matches (@var{hint})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1072 Generate possible completions given @var{hint}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1073
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1074 This function is provided for the benefit of programs like Emacs which
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1075 might be controlling Octave and handling user input. The current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1076 command number is not incremented when this function is called. This is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1077 a feature, not a bug.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1078 @end deftypefn */)
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1079 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
1080 if (args.length () != 1)
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1081 print_usage ();
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1082
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1083 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1084
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1085 std::string hint = args(0).string_value ();
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1086
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1087 int n = 32;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1088
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1089 string_vector list (n);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1090
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1091 int k = 0;
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1092
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1093 for (;;)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1094 {
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1095 std::string cmd = generate_completion (hint, k);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1096
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1097 if (! cmd.empty ())
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1098 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1099 if (k == n)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
1100 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1101 n *= 2;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1102 list.resize (n);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
1103 }
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1104
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1105 list[k++] = cmd;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1106 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1107 else
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1108 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1109 list.resize (k);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1110 break;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1111 }
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1112 }
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1113
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1114 if (nargout > 0)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1115 {
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1116 if (! list.empty ())
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1117 retval = list;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1118 else
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1119 retval = "";
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1120 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1121 else
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1122 {
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1123 // We don't use string_vector::list_in_columns here
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1124 // because it will be easier for Emacs if the names
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1125 // appear in a single column.
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1126
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1127 int len = list.numel ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1128
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1129 for (int i = 0; i < len; i++)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1130 octave_stdout << list[i] << "\n";
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1131 }
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1132
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1133 octave_completion_matches_called = true;
2234
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1134
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1135 return retval;
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1136 }
a174011c96f2 [project @ 1996-05-17 17:51:20 by jwe]
jwe
parents: 2205
diff changeset
1137
20239
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1138 /*
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1139 %!assert (ischar (completion_matches ("")))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1140 %!assert (ischar (completion_matches ("a")))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1141 %!assert (ischar (completion_matches (" ")))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1142 %!assert (isempty (completion_matches (" ")))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1143 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches (""))))))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1144 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("a"))))))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1145 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("ab"))))))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1146 %!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("abs"))))))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1147 %!assert (! any (strcmp ("abs", deblank (cellstr (completion_matches ("absa"))))))
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1148
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1149 %!error completion_matches ()
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1150 %!error completion_matches (1, 2)
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1151 */
48284e32530b test: Add tests for 'echo' and 'completion_matches' builtins
Mike Miller <mtmiller@octave.org>
parents: 20232
diff changeset
1152
16879
cc3743a91652 Rename read_readline_init_file to readline_read_init_file.
Rik <rik@octave.org>
parents: 16816
diff changeset
1153 DEFUN (readline_read_init_file, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1154 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1155 @deftypefn {} {} readline_read_init_file (@var{file})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1156 Read the readline library initialization file @var{file}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1157
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1158 If @var{file} is omitted, read the default initialization file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1159 (normally @file{~/.inputrc}).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1160
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1161 @xref{Readline Init File, , , readline, GNU Readline Library},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1162 for details.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1163 @seealso{readline_re_read_init_file}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1164 @end deftypefn */)
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1165 {
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1166 int nargin = args.length ();
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1167
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1168 if (nargin > 1)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1169 print_usage ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1170
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1171 if (nargin == 0)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1172 octave::command_editor::read_init_file ();
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1173 else
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1174 {
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5832
diff changeset
1175 std::string file = args(0).string_value ();
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1176
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1177 octave::command_editor::read_init_file (file);
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1178 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1179
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1180 return ovl ();
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1181 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3180
diff changeset
1182
16880
1aebb613a5ac Rename re_read_readline_init_file to readline_re_read_init_file.
Rik <rik@octave.org>
parents: 16879
diff changeset
1183 DEFUN (readline_re_read_init_file, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1184 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1185 @deftypefn {} {} readline_re_read_init_file ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1186 Re-read the last readline library initialization file that was read.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1187
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1188 @xref{Readline Init File, , , readline, GNU Readline Library},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1189 for details.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1190 @seealso{readline_read_init_file}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1191 @end deftypefn */)
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1192 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1193 if (args.length () != 0)
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1194 print_usage ();
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1195
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1196 octave::command_editor::re_read_init_file ();
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1197
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1198 return ovl ();
7758
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1199 }
8e14a01ffe9f input.cc (Fre_read_readline_init_file): new function
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
1200
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
1201 static int
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
1202 internal_input_event_hook_fcn (void)
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
1203 {
16378
b28ae106e316 use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents: 16374
diff changeset
1204 input_event_hook_functions.run ();
16349
610617eb84d1 provide pre- and post-input hook functions
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
1205
16378
b28ae106e316 use class for lists of input hook functions
John W. Eaton <jwe@octave.org>
parents: 16374
diff changeset
1206 if (input_event_hook_functions.empty ())
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1207 octave::command_editor::remove_event_hook (internal_input_event_hook_fcn);
16152
c48847a781d5 * input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents: 16151
diff changeset
1208
c48847a781d5 * input.cc (input_event_hook): Return 0.
John W. Eaton <jwe@octave.org>
parents: 16151
diff changeset
1209 return 0;
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1210 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1211
9215
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1212 DEFUN (add_input_event_hook, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1213 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1214 @deftypefn {} {@var{id} =} add_input_event_hook (@var{fcn})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1215 @deftypefnx {} {@var{id} =} add_input_event_hook (@var{fcn}, @var{data})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1216 Add the named function or function handle @var{fcn} to the list of functions
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1217 to call periodically when Octave is waiting for input.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1218
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1219 The function should have the form
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1220
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1221 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1222 @var{fcn} (@var{data})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1223 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1224
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1225 If @var{data} is omitted, Octave calls the function without any arguments.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1226
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1227 The returned identifier may be used to remove the function handle from the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1228 list of input hook functions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1229 @seealso{remove_input_event_hook}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1230 @end deftypefn */)
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1231 {
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1232 int nargin = args.length ();
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1233
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1234 if (nargin < 1 || nargin > 2)
9215
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1235 print_usage ();
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1236
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1237 octave_value user_data;
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1238
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1239 if (nargin == 2)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1240 user_data = args(1);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1241
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1242 hook_function hook_fcn (args(0), user_data);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1243
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1244 if (input_event_hook_functions.empty ())
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1245 octave::command_editor::add_event_hook (internal_input_event_hook_fcn);
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1246
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1247 input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1248
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21100
diff changeset
1249 return ovl (hook_fcn.id ());
9215
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1250 }
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1251
9215
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1252 DEFUN (remove_input_event_hook, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1253 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1254 @deftypefn {} {} remove_input_event_hook (@var{name})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1255 @deftypefnx {} {} remove_input_event_hook (@var{fcn_id})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1256 Remove the named function or function handle with the given identifier
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1257 from the list of functions to call periodically when Octave is waiting
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1258 for input.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1259 @seealso{add_input_event_hook}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1260 @end deftypefn */)
9215
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1261 {
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1262 int nargin = args.length ();
1500d0197484 allow multiple input event hook functions to be installed simultaneously
John W. Eaton <jwe@octave.org>
parents: 9134
diff changeset
1263
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1264 if (nargin < 1 || nargin > 2)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1265 print_usage ();
16347
bf8397caeff1 allow add_input_event_hook to accept function handles
John W. Eaton <jwe@octave.org>
parents: 16336
diff changeset
1266
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1267 std::string hook_fcn_id = args(0).string_value ("remove_input_event_hook: argument not valid as a hook function name or id");
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1268
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1269 bool warn = (nargin < 2);
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1270
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1271 hook_function_list::iterator p
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1272 = input_event_hook_functions.find (hook_fcn_id);
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1273
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1274 if (p != input_event_hook_functions.end ())
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1275 input_event_hook_functions.erase (p);
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1276 else if (warn)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1277 warning ("remove_input_event_hook: %s not found in list",
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1278 hook_fcn_id.c_str ());
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1279
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1280 if (input_event_hook_functions.empty ())
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
1281 octave::command_editor::remove_event_hook (internal_input_event_hook_fcn);
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1282
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1283 return ovl ();
3498
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1284 }
e391aeef2b3c [project @ 2000-01-31 03:17:14 by jwe]
jwe
parents: 3484
diff changeset
1285
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1286 DEFUN (PS1, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1287 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1288 @deftypefn {} {@var{val} =} PS1 ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1289 @deftypefnx {} {@var{old_val} =} PS1 (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1290 @deftypefnx {} {} PS1 (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1291 Query or set the primary prompt string.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1292
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1293 When executing interactively, Octave displays the primary prompt when it is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1294 ready to read a command.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1295
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1296 The default value of the primary prompt string is @qcode{"octave:\#> "}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1297 To change it, use a command like
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1298
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1299 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1300 PS1 ("\\u@@\\H> ")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1301 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1302
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1303 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1304 which will result in the prompt @samp{boris@@kremvax> } for the user
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1305 @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1306 backslashes are required to enter a backslash into a double-quoted
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1307 character string. @xref{Strings}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1308
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1309 You can also use ANSI escape sequences if your terminal supports them.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1310 This can be useful for coloring the prompt. For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1311
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1312 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1313 PS1 ('\[\033[01;31m\]\s:\#> \[\033[0m\]')
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1314 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1315
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1316 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1317 will give the default Octave prompt a red coloring.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1318
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1319 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1320 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1321 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1322 @seealso{PS2, PS4}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1323 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1324 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1325 return SET_INTERNAL_VARIABLE (PS1);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1326 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1327
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1328 DEFUN (PS2, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1329 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1330 @deftypefn {} {@var{val} =} PS2 ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1331 @deftypefnx {} {@var{old_val} =} PS2 (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1332 @deftypefnx {} {} PS2 (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1333 Query or set the secondary prompt string.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1334
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1335 The secondary prompt is printed when Octave is expecting additional input to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1336 complete a command. For example, if you are typing a @code{for} loop that
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1337 spans several lines, Octave will print the secondary prompt at the beginning
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1338 of each line after the first. The default value of the secondary prompt
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1339 string is @qcode{"> "}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1340
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1341 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1342 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1343 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1344 @seealso{PS1, PS4}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1345 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1346 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1347 return SET_INTERNAL_VARIABLE (PS2);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1348 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1349
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1350 DEFUN (PS4, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1351 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1352 @deftypefn {} {@var{val} =} PS4 ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1353 @deftypefnx {} {@var{old_val} =} PS4 (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1354 @deftypefnx {} {} PS4 (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1355 Query or set the character string used to prefix output produced
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1356 when echoing commands is enabled.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1357
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1358 The default value is @qcode{"+ "}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1359 @xref{Diary and Echo Commands}, for a description of echoing commands.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1360
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1361 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1362 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1363 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1364 @seealso{echo, echo_executing_commands, PS1, PS2}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1365 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1366 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1367 return SET_INTERNAL_VARIABLE (PS4);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1368 }
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1369
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1370 DEFUN (completion_append_char, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1371 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1372 @deftypefn {} {@var{val} =} completion_append_char ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1373 @deftypefnx {} {@var{old_val} =} completion_append_char (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1374 @deftypefnx {} {} completion_append_char (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1375 Query or set the internal character variable that is appended to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1376 successful command-line completion attempts.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1377
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1378 The default value is @qcode{" "} (a single space).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1379
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1380 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1381 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1382 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1383 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1384 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1385 return SET_INTERNAL_VARIABLE (completion_append_char);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1386 }
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3016
diff changeset
1387
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1388 DEFUN (echo_executing_commands, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1389 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1390 @deftypefn {} {@var{val} =} echo_executing_commands ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1391 @deftypefnx {} {@var{old_val} =} echo_executing_commands (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1392 @deftypefnx {} {} echo_executing_commands (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1393 Query or set the internal variable that controls the echo state.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1394
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1395 It may be the sum of the following values:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1396
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1397 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1398 @item 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1399 Echo commands read from script files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1400
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1401 @item 2
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1402 Echo commands from functions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1403
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1404 @item 4
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1405 Echo commands read from command line.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1406 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1407
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1408 More than one state can be active at once. For example, a value of 3 is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1409 equivalent to the command @kbd{echo on all}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1410
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1411 The value of @code{echo_executing_commands} may be set by the @kbd{echo}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1412 command or the command line option @option{--echo-commands}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1413
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1414 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1415 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1416 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1417 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1418 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
1419 return SET_INTERNAL_VARIABLE (echo_executing_commands);
2181
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1420 }
138b3c98dc85 [project @ 1996-05-13 18:02:31 by jwe]
jwe
parents: 2114
diff changeset
1421
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1422 DEFUN (__request_drawnow__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1423 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1424 @deftypefn {} {} __request_drawnow__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1425 @deftypefnx {} {} __request_drawnow__ (@var{flag})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1426 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1427 @end deftypefn */)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1428 {
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1429 int nargin = args.length ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1430
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1431 if (nargin > 1)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1432 print_usage ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1433
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1434 if (nargin == 0)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1435 Vdrawnow_requested = true;
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1436 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1437 Vdrawnow_requested = args(0).bool_value ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1438
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1439 return ovl ();
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1440 }
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6206
diff changeset
1441
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1442 DEFUN (__gud_mode__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1443 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1444 @deftypefn {} {} __gud_mode__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1445 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1446 @end deftypefn */)
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1447 {
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1448 int nargin = args.length ();
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1449
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1450 if (nargin > 1)
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1451 print_usage ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1452
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1453 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1454
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1455 if (nargin == 0)
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1456 retval = ovl (Vgud_mode);
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20756
diff changeset
1457 else
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1458 Vgud_mode = args(0).bool_value ();
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1459
21006
ea779f11deae strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents: 20996
diff changeset
1460 return retval;
7294
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1461 }
fb902b3b2a5d [project @ 2007-12-11 18:55:46 by jwe]
jwe
parents: 7097
diff changeset
1462
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1463 DEFUN (filemarker, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1464 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1465 @deftypefn {} {@var{val} =} filemarker ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1466 @deftypefnx {} {@var{old_val} =} filemarker (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1467 @deftypefnx {} {} filemarker (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1468 Query or set the character used to separate the filename from the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1469 subfunction names contained within the file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1470
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1471 By default this is the character @samp{>}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1472 This can be used in a generic manner to interact with subfunctions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1473 For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1474
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1475 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1476 help (["myfunc", filemarker, "mysubfunc"])
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1477 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1478
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1479 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1480 returns the help string associated with the subfunction @code{mysubfunc}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1481 located in the file @file{myfunc.m}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1482
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1483 @code{filemarker} is also useful during debugging for placing breakpoints
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1484 within subfunctions or nested functions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1485 For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1486
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1487 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1488 dbstop (["myfunc", filemarker, "mysubfunc"])
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1489 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1490
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1491 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1492 will set a breakpoint at the first line of the subfunction @code{mysubfunc}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1493
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1494 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1495 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1496 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21920
diff changeset
1497 @end deftypefn */)
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1498 {
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1499 char tmp = Vfilemarker;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1500 octave_value retval = SET_INTERNAL_VARIABLE (filemarker);
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1501
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1502 // The character passed must not be a legal character for a function name
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20239
diff changeset
1503 if (::isalnum (Vfilemarker) || Vfilemarker == '_')
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1504 {
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1505 Vfilemarker = tmp;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1506 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
1507 }
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1508
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1509 return retval;
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1510 }