annotate liboctave/util/cmd-hist.cc @ 23812:057a894914df

Use C++11 string fcns back() and pop_back() to simplify code. * error.cc (maybe_extract_message): Use "back()" rather than "[length () -1]". * input.cc (base_reader::octave_gets): Use "back()" rather than "[length () -1]". * ls-hdf5.cc (read_hdf5_data)): Use "clear()" rather than "resize (0)" to erase string. * ls-mat-ascii.cc (get_lines_and_columns): Reformat comment. * ls-oct-binary.cc (read_binary_data): Use "clear()" rather than "resize (0)" to erase string. * oct-stream.cc (delimited_stream::getline): Declare and initialize only one variable per line as per Octave coding convention. * oct-stream.cc (textscan_format_list::read_first_row): Use back() and pop_back() to potentially remove last character from string. * strfns.cc (Fstrvcat): Use "empty()" rather than "length() > 0". * sysdep.cc (w32_set_octav_home): Use back() and push_back() to potentially add dir separator to string. * gzip.cc (uchar_array): Space out code for readability. * file-ops.cc (tilde_expand): Call string_vector constructor with size n rather than resize. * file-ops.cc (concat): Use "back()" rather than "[length () -1]". * file-stat.cc (update_internal): Use "back()" rather than "[length () -1]". Use pop_back() rather than resize() to remove last character. * oct-env.cc (do_chdir): Use pop_back() rather than resize() to remove last character. * cmd-edit.cc (do_generate_filename_completions): Reformat comment. * cmd-hist.cc (): Use back() and pop_back() to potentially remove "\n" from end of string. * data-conv.cc (strip_spaces): Initialize string with null character rather than space. * kpse.cc (kpse_tilde_expand): Use "back()" rather than "[length () -1]". * kpse.cc (kpse_expand_kpse_dot, kpse_brace_expand, kpse_path_expand): Use pop_back() to potentially remove last character. * kpse.cc (kpse_brace_expand_element, kpse_element_dir): Use pop_back() to remove last character. * lo-utils.cc (octave_fgetl): Use "back()" rather than "[length () -1]". Use pop_back() rather than resize() to remove last character.
author Rik <rik@octave.org>
date Sun, 30 Jul 2017 09:21:58 -0700
parents 336f89b6208b
children 194eb4bd202b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
1 /*
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1996-2017 John W. Eaton
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
4
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
6
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
8 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
10 (at your option) any later version.
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
15 GNU General Public License for more details.
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
16
28aefb5a7dec [project @ 1996-01-29 05:05:57 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: 6913
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: 6913
diff changeset
19 <http://www.gnu.org/licenses/>.
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
20
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
21 */
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
25 #endif
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
26
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
27 #include <cstring>
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
28
21851
e2deba5ca08c use fstream to create history file
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
29 #include <fstream>
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3503
diff changeset
30 #include <iostream>
17996
260b44c0ed69 improve messages when reading or writing history fails (bug #40443)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
31 #include <sstream>
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
32 #include <string>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
33
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
34 #include "cmd-edit.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
35 #include "cmd-hist.h"
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
36 #include "file-ops.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
37 #include "lo-error.h"
14071
8aa5da1b7ce3 also include singleton-cleanup.h when not using readline
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
38 #include "singleton-cleanup.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
39 #include "str-vec.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
40
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
41 #if defined (USE_READLINE)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
42 #include <cstdlib>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
43
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents: 3504
diff changeset
44 #include "oct-rl-hist.h"
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
45
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
46 #include "file-stat.h"
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
47 #endif
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
48
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
49 namespace octave
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
50 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
51 command_history *command_history::instance = nullptr;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
52
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
53 #if defined (USE_READLINE)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
54
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
55 class
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
56 gnu_history : public command_history
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
57 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
58 public:
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
59
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
60 gnu_history (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
61 : command_history (), mark (0) { }
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
62
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
63 ~gnu_history (void) = default;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
64
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
65 void do_process_histcontrol (const std::string&);
15397
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
66
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
67 std::string do_histcontrol (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
68
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
69 bool do_add (const std::string&);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
70
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
71 void do_remove (int);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
72
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
73 void do_clear (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
74
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
75 int do_where (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
76
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
77 int do_length (void) const;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
78
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
79 int do_max_input_history (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
80
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
81 int do_base (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
82
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
83 int do_current_number (void) const;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
84
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
85 void do_stifle (int);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
86
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
87 int do_unstifle (void);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
88
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
89 int do_is_stifled (void) const;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
90
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
91 void do_set_mark (int);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
92
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
93 int do_goto_mark (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
94
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
95 void do_read (const std::string&, bool);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
96
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
97 void do_read_range (const std::string&, int, int, bool);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
98
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
99 void do_write (const std::string&) const;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
100
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
101 void do_append (const std::string&);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
102
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
103 void do_truncate_file (const std::string&, int) const;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
104
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
105 string_vector do_list (int, bool) const;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
106
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
107 std::string do_get_entry (int) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
108
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
109 void do_replace_entry (int, const std::string&);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
110
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
111 void do_clean_up_and_save (const std::string&, int);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
112
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
113 private:
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
114
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
115 int mark;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
116 };
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
117
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
118 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
119 gnu_history::do_process_histcontrol (const std::string& control_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
120 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
121 history_control = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
122
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
123 size_t len = control_arg.length ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
124 size_t beg = 0;
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
125
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
126 while (beg < len)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
127 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
128 if (control_arg[beg] == ':')
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
129 beg++;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
130 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
131 {
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23696
diff changeset
132 size_t end = control_arg.find (':', beg);
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
133
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
134 if (end == std::string::npos)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
135 end = len;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
136
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
137 std::string tmp = control_arg.substr (beg, end-beg);
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
138
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
139 if (tmp == "erasedups")
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
140 history_control |= HC_ERASEDUPS;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
141 else if (tmp == "ignoreboth")
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
142 history_control |= (HC_IGNDUPS | HC_IGNSPACE);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
143 else if (tmp == "ignoredups")
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
144 history_control |= HC_IGNDUPS;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
145 else if (tmp == "ignorespace")
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
146 history_control |= HC_IGNSPACE;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
147 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
148 (*current_liboctave_warning_with_id_handler)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
149 ("Octave:history-control",
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
150 "unknown histcontrol directive %s", tmp.c_str ());
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
151
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
152 if (end != std::string::npos)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
153 beg = end + 1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
154 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
155 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
156 }
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
157
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
158 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
159 gnu_history::do_histcontrol (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
160 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
161 // FIXME: instead of reconstructing this value, should we just save
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
162 // the string we were given when constructing the command_history object?
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
163
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
164 std::string retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
165
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
166 if (history_control & HC_IGNSPACE)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
167 retval.append ("ignorespace");
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
168
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
169 if (history_control & HC_IGNDUPS)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
170 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
171 if (retval.length () > 0)
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23696
diff changeset
172 retval += ':';
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
173
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
174 retval.append ("ignoredups");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
175 }
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
176
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
177 if (history_control & HC_ERASEDUPS)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
178 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
179 if (retval.length () > 0)
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23696
diff changeset
180 retval += ':';
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
181
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
182 retval.append ("erasedups");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
183 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
184
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
185 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
186 }
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
187
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
188 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
189 gnu_history::do_add (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
190 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
191 if (! do_ignoring_entries ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
192 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
193 if (s.empty ()
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
194 || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n')))
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
195 return false;
2512
fda09c1e787e [project @ 1996-11-14 08:39:41 by jwe]
jwe
parents: 2470
diff changeset
196
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
197 // Strip newline before adding to list
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
198 std::string stmp = s;
23812
057a894914df Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents: 23807
diff changeset
199 if (stmp.back () == '\n')
057a894914df Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents: 23807
diff changeset
200 stmp.pop_back ();
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
201
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
202 int added = ::octave_add_history (stmp.c_str (), history_control);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
203 lines_this_session += added;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
204 return (added > 0) ? true : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
205 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
206 return false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
207 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
208
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
209 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
210 gnu_history::do_remove (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
211 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
212 ::octave_remove_history (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
213 }
15397
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
214
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
215 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
216 gnu_history::do_clear (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
217 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
218 ::octave_clear_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
219 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
220
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
221 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
222 gnu_history::do_where (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
223 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
224 return ::octave_where_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
225 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
226
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
227 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
228 gnu_history::do_length (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
229 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
230 return ::octave_history_length ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
231 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
232
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
233 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
234 gnu_history::do_max_input_history (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
235 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
236 return ::octave_max_input_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
237 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
238
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
239 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
240 gnu_history::do_base (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
241 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
242 return ::octave_history_base ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
243 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
244
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
245 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
246 gnu_history::do_current_number (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
247 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
248 return (xsize > 0) ? do_base () + do_where () : -1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
249 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
250
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
251 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
252 gnu_history::do_stifle (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
253 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
254 ::octave_stifle_history (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
255 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
256
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
257 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
258 gnu_history::do_unstifle (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
259 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
260 return ::octave_unstifle_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
261 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
262
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
263 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
264 gnu_history::do_is_stifled (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
265 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
266 return ::octave_history_is_stifled ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
267 }
2658
dd71eb0bb414 [project @ 1997-02-03 04:49:57 by jwe]
jwe
parents: 2512
diff changeset
268
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
269 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
270 gnu_history::do_set_mark (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
271 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
272 mark = n;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
273 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
274
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
275 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
276 gnu_history::do_goto_mark (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
277 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
278 if (mark)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
279 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
280 char *line = ::octave_history_goto_mark (mark);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
281
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
282 if (line)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
283 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
284 command_editor::insert_text (line);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
285
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
286 command_editor::clear_undo_list ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
287 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
288 }
4802
b3f20980be32 [project @ 2004-02-25 05:14:19 by jwe]
jwe
parents: 4051
diff changeset
289
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
290 mark = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
291
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
292 // FIXME: for operate_and_get_next.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
293 command_editor::remove_startup_hook (command_history::goto_mark);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
294
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
295 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
296 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
297
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
298 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
299 gnu_history::do_read (const std::string& f, bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
300 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
301 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
302 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
303 int status = ::octave_read_history (f.c_str ());
17996
260b44c0ed69 improve messages when reading or writing history fails (bug #40443)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
304
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
305 if (status != 0 && must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
306 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
307 std::string msg = "reading file '" + f + "'";
2658
dd71eb0bb414 [project @ 1997-02-03 04:49:57 by jwe]
jwe
parents: 2512
diff changeset
308
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
309 error (status, msg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
310 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
311 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
312 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
313 lines_in_file = do_where ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
314
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
315 ::octave_using_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
316 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
317 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
318 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
319 error ("gnu_history::read: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
320 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
321
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
322 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
323 gnu_history::do_read_range (const std::string& f, int from, int to,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
324 bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
325 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
326 if (from < 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
327 from = lines_in_file;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
328
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
329 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
330 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
331 int status = ::octave_read_history_range (f.c_str (), from, to);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
332
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
333 if (status != 0 && must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
334 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
335 std::ostringstream buf;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
336 buf << "reading lines " << from << " to " << to
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
337 << " from file '" << f << "'";
17996
260b44c0ed69 improve messages when reading or writing history fails (bug #40443)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
338
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
339 error (status, buf.str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
340 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
341 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
342 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
343 lines_in_file = do_where ();
2658
dd71eb0bb414 [project @ 1997-02-03 04:49:57 by jwe]
jwe
parents: 2512
diff changeset
344
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
345 ::octave_using_history ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
346 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
347 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
348 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
349 error ("gnu_history::read_range: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
350 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
351
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
352 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
353 gnu_history::do_write (const std::string& f_arg) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
354 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
355 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
356 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
357 std::string f = f_arg;
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
358
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
359 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
360 f = xfile;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
361
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
362 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
363 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
364 int status = ::octave_write_history (f.c_str ());
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
365
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
366 if (status != 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
367 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
368 std::string msg = "writing file '" + f + "'";
17996
260b44c0ed69 improve messages when reading or writing history fails (bug #40443)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
369
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
370 error (status, msg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
371 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
372 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
373 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
374 error ("gnu_history::write: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
375 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
376 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
377
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
378 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
379 gnu_history::do_append (const std::string& f_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
380 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
381 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
382 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
383 if (lines_this_session)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
384 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
385 if (lines_this_session < do_where ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
386 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
387 // Create file if it doesn't already exist.
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
388
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
389 std::string f = f_arg;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
390
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
391 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
392 f = xfile;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
393
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
394 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
395 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
396 sys::file_stat fs (f);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
397
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
398 if (! fs)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
399 {
21851
e2deba5ca08c use fstream to create history file
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
400 std::fstream tmp (f, std::ios::out);
e2deba5ca08c use fstream to create history file
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
401 tmp.close ();
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
402 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
403
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
404 int status
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
405 = ::octave_append_history (lines_this_session, f.c_str ());
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
406
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
407 if (status != 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
408 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
409 std::string msg = "appending to file '" + f_arg + "'";
17996
260b44c0ed69 improve messages when reading or writing history fails (bug #40443)
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
410
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
411 error (status, msg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
412 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
413 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
414 lines_in_file += lines_this_session;
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
415
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
416 lines_this_session = 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
417 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
418 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
419 error ("gnu_history::append: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
420 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
421 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
422 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
423 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
424
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
425 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
426 gnu_history::do_truncate_file (const std::string& f_arg, int n) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
427 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
428 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
429 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
430 std::string f = f_arg;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
431
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
432 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
433 f = xfile;
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
434
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
435 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
436 ::octave_history_truncate_file (f.c_str (), n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
437 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
438 error ("gnu_history::truncate_file: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
439 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
440 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
441
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
442 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
443 gnu_history::do_list (int limit, bool number_lines) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
444 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
445 string_vector retval;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
446
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
447 if (limit)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
448 retval = ::octave_history_list (limit, number_lines);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
449
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
450 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
451 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
452
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
453 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
454 gnu_history::do_get_entry (int n) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
455 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
456 std::string retval;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
457
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
458 char *line = ::octave_history_get (do_base () + n);
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
459
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
460 if (line)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
461 retval = line;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
462
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
463 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
464 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
465
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
466 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
467 gnu_history::do_replace_entry (int which, const std::string& line)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
468 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
469 ::octave_replace_history_entry (which, line.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
470 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
471
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
472 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
473 gnu_history::do_clean_up_and_save (const std::string& f_arg, int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
474 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
475 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
476 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
477 std::string f = f_arg;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
478
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
479 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
480 f = xfile;
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
481
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
482 if (! f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
483 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
484 if (n < 0)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
485 n = xsize;
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
486
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
487 stifle (n);
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
488
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
489 do_write (f.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
490 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
491 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
492 error ("gnu_history::clean_up_and_save: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
493 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
494 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
495
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
496 #endif
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
497
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
498 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
499 command_history::instance_ok (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
500 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
501 bool retval = true;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
502
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
503 if (! instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
504 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
505 make_command_history ();
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 12330
diff changeset
506
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
507 if (instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
508 singleton_cleanup_list::add (cleanup_instance);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
509 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
510
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
511 if (! instance)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
512 (*current_liboctave_error_handler)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
513 ("unable to create command history object!");
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
514
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
515 return retval;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
516 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
517
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
518 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
519 command_history::make_command_history (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
520 {
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
521 #if defined (USE_READLINE)
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
522 instance = new gnu_history ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
523 #else
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
524 instance = new command_history ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
525 #endif
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
526 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
527
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
528 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
529 command_history::initialize (bool read_history_file,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
530 const std::string& f_arg, int sz,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
531 const std::string & control_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
532 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
533 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
534 instance->do_initialize (read_history_file, f_arg, sz, control_arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
535 }
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
536
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
537 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
538 command_history::is_initialized (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
539 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
540 // We just want to check the status of an existing instance, not
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
541 // create one.
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
542 return instance && instance->do_is_initialized ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
543 }
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
544
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
545 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
546 command_history::set_file (const std::string& f_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
547 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
548 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
549 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
550 std::string f = sys::file_ops::tilde_expand (f_arg);
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5775
diff changeset
551
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
552 instance->do_set_file (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
553 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
554 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
555
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
556 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
557 command_history::file (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
558 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
559 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
560 ? instance->do_file () : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
561 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
562
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
563 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
564 command_history::process_histcontrol (const std::string& control_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
565 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
566 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
567 instance->do_process_histcontrol (control_arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
568 }
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11368
diff changeset
569
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
570 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
571 command_history::histcontrol (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
572 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
573 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
574 ? instance->do_histcontrol () : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
575 }
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 11368
diff changeset
576
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
577 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
578 command_history::set_size (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
579 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
580 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
581 instance->do_set_size (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
582 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
583
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
584 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
585 command_history::size (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
586 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
587 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
588 ? instance->do_size () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
589 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
590
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
591 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
592 command_history::ignore_entries (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
593 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
594 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
595 instance->do_ignore_entries (flag);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
596 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
597
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
598 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
599 command_history::ignoring_entries (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
600 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
601 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
602 ? instance->do_ignoring_entries () : false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
603 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
604
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
605 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
606 command_history::add (const std::string& s)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
607 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
608 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
609 return instance->do_add (s);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
610 return false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
611 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
612
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
613 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
614 command_history::remove (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
615 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
616 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
617 instance->do_remove (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
618 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
619
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
620 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
621 command_history::clear (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
622 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
623 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
624 instance->do_clear ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
625 }
15397
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
626
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
627 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
628 command_history::where (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
629 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
630 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
631 ? instance->do_where () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
632 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
633
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
634 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
635 command_history::length (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
636 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
637 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
638 ? instance->do_length () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
639 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
640
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
641 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
642 command_history::max_input_history (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
643 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
644 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
645 ? instance->do_max_input_history () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
646 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
647
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
648 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
649 command_history::base (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
650 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
651 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
652 ? instance->do_base () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
653 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
654
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
655 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
656 command_history::current_number (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
657 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
658 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
659 ? instance->do_current_number () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
660 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
661
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
662 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
663 command_history::stifle (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
664 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
665 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
666 instance->do_stifle (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
667 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
668
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
669 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
670 command_history::unstifle (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
671 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
672 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
673 ? instance->do_unstifle () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
674 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
675
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
676 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
677 command_history::is_stifled (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
678 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
679 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
680 ? instance->do_is_stifled () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
681 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
682
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
683 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
684 command_history::set_mark (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
685 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
686 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
687 instance->do_set_mark (n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
688 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
689
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
690 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
691 command_history::goto_mark (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
692 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
693 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
694 ? instance->do_goto_mark () : 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
695 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
696
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
697 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
698 command_history::read (bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
699 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
700 read (file (), must_exist);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
701 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
702
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
703 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
704 command_history::read (const std::string& f, bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
705 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
706 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
707 instance->do_read (f, must_exist);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
708 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
709
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
710 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
711 command_history::read_range (int from, int to, bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
712 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
713 read_range (file (), from, to, must_exist);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
714 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
715
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
716 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
717 command_history::read_range (const std::string& f, int from, int to,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
718 bool must_exist)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
719 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
720 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
721 instance->do_read_range (f, from, to, must_exist);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
722 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
723
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
724 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
725 command_history::write (const std::string& f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
726 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
727 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
728 instance->do_write (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
729 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
730
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
731 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
732 command_history::append (const std::string& f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
733 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
734 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
735 instance->do_append (f);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
736 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
737
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
738 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
739 command_history::truncate_file (const std::string& f, int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
740 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
741 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
742 instance->do_truncate_file (f, n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
743 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
744
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
745 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
746 command_history::list (int limit, bool number_lines)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
747 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
748 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
749 ? instance->do_list (limit, number_lines) : string_vector ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
750 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
751
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
752 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
753 command_history::get_entry (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
754 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
755 return (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
756 ? instance->do_get_entry (n) : "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
757 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
758
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
759 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
760 command_history::replace_entry (int which, const std::string& line)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
761 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
762 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
763 instance->do_replace_entry (which, line);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
764 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
765
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
766 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
767 command_history::clean_up_and_save (const std::string& f, int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
768 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
769 if (instance_ok ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
770 instance->do_clean_up_and_save (f, n);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
771 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
772
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
773 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
774 command_history::do_process_histcontrol (const std::string&)
22395
c5b9c202e637 * cmd-hist.cc (command_history::do_process_histcontrol):
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
775 { }
12330
60b6b175f88a require readline to provide working history control
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
776
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
777 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
778 command_history::do_initialize (bool read_history_file,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
779 const std::string& f_arg, int sz,
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
780 const std::string & control_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
781 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
782 command_history::set_file (f_arg);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
783 command_history::set_size (sz);
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
784 command_history::process_histcontrol (control_arg);
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
785
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
786 if (read_history_file)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
787 command_history::read (false);
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
788
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
789 initialized = true;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
790 }
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
791
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
792 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
793 command_history::do_is_initialized (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
794 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
795 return initialized;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
796 }
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 10463
diff changeset
797
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
798 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
799 command_history::do_set_file (const std::string& f)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
800 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
801 xfile = f;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
802 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
803
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
804 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
805 command_history::do_file (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
806 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
807 return xfile;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
808 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
809
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
810 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
811 command_history::do_set_size (int n)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
812 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
813 xsize = n;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
814 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
815
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
816 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
817 command_history::do_size (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
818 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
819 return xsize;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
820 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
821
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
822 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
823 command_history::do_ignore_entries (bool flag)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
824 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
825 ignoring_additions = flag;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
826 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
827
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
828 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
829 command_history::do_ignoring_entries (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
830 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
831 return ignoring_additions;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
832 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
833
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
834 bool
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
835 command_history::do_add (const std::string&)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
836 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
837 return false;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
838 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
839
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
840 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
841 command_history::do_remove (int)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
842 { }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
843
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
844 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
845 command_history::do_clear (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
846 { }
15397
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
847
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
848 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
849 command_history::do_where (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
850 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
851 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
852 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
853
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
854 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
855 command_history::do_length (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
856 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
857 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
858 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
859
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
860 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
861 command_history::do_max_input_history (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
862 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
863 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
864 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
865
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
866 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
867 command_history::do_base (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
868 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
869 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
870 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
871
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
872 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
873 command_history::do_current_number (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
874 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
875 return (xsize > 0) ? do_base () + do_where () : -1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
876 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
877
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
878 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
879 command_history::do_stifle (int)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
880 { }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
881
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
882 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
883 command_history::do_unstifle (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
884 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
885 return -1;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
886 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
887
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
888 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
889 command_history::do_is_stifled (void) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
890 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
891 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
892 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
893
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
894 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
895 command_history::do_set_mark (int)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
896 { }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
897
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
898 int
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
899 command_history::do_goto_mark (void)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
900 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
901 return 0;
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
902 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
903
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
904 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
905 command_history::do_read (const std::string& f, bool)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
906 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
907 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
908 error ("command_history::read: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
909 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
910
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
911 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
912 command_history::do_read_range (const std::string& f, int, int, bool)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
913 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
914 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
915 error ("command_history::read_range: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
916 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
917
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
918 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
919 command_history::do_write (const std::string& f_arg) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
920 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
921 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
922 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
923 std::string f = f_arg;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
924
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
925 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
926 f = xfile;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
927
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
928 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
929 error ("command_history::write: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
930 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
931 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
932
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
933 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
934 command_history::do_append (const std::string& f_arg)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
935 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
936 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
937 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
938 if (lines_this_session)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
939 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
940 if (lines_this_session < do_where ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
941 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
942 // Create file if it doesn't already exist.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
943
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
944 std::string f = f_arg;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
945
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
946 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
947 f = xfile;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
948
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
949 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
950 error ("command_history::append: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
951 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
952 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
953 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
954 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
955
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
956 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
957 command_history::do_truncate_file (const std::string& f_arg, int) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
958 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
959 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
960 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
961 std::string f = f_arg;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
962
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
963 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
964 f = xfile;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
965
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
966 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
967 error ("command_history::truncate_file: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
968 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
969 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
970
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
971 string_vector
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
972 command_history::do_list (int, bool) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
973 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
974 return string_vector ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
975 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
976
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
977 std::string
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
978 command_history::do_get_entry (int) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
979 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
980 return "";
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
981 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
982
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
983 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
984 command_history::do_replace_entry (int, const std::string&)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
985 { }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
986
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
987 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
988 command_history::do_clean_up_and_save (const std::string& f_arg, int)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
989 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
990 if (initialized)
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
991 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
992 std::string f = f_arg;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
993
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
994 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
995 f = xfile;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
996
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
997 if (f.empty ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
998 error ("command_history::clean_up_and_save: missing filename");
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
999 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1000 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
1001
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1002 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1003 command_history::error (int err_num, const std::string& msg) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1004 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1005 if (msg.empty ())
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1006 (*current_liboctave_error_handler) ("%s", std::strerror (err_num));
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1007 else
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1008 (*current_liboctave_error_handler) ("%s: %s", msg.c_str (),
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1009 std::strerror (err_num));
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1010 }
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1011
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1012 void
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1013 command_history::error (const std::string& s) const
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1014 {
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1015 (*current_liboctave_error_handler) ("%s", s.c_str ());
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1016 }
1797
28aefb5a7dec [project @ 1996-01-29 05:05:57 by jwe]
jwe
parents:
diff changeset
1017 }