annotate liboctave/util/cmd-hist.cc @ 21736:0504351a45e6

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