GNU Octave
4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
cmd-hist.h
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1996-2018 John W. Eaton
4
5
This file is part of Octave.
6
7
Octave is free software: you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<https://www.gnu.org/licenses/>.
20
21
*/
22
23
#if ! defined (octave_cmd_hist_h)
24
#define octave_cmd_hist_h 1
25
26
#include "octave-config.h"
27
28
#include <string>
29
30
#include "
str-vec.h
"
31
32
namespace
octave
33
{
34
class
35
OCTAVE_API
36
command_history
37
{
38
protected
:
39
40
command_history
(
void
)
41
:
initialized
(
false
), ignoring_additions (
false
), history_control (0),
42
lines_in_file (0), lines_this_session (0), xfile (), xsize (-1) { }
43
44
public
:
45
46
// No copying!
47
48
command_history
(
const
command_history
&) =
delete
;
49
50
command_history
& operator = (
const
command_history
&) =
delete
;
51
52
virtual
~
command_history
(
void
) =
default
;
53
54
static
void
initialize
(
bool
,
const
std::string
&,
int
,
const
std::string
&);
55
56
static
bool
is_initialized (
void
);
57
58
static
void
set_file (
const
std::string
&);
59
60
static
std::string
file
(
void
);
61
62
static
void
process_histcontrol (
const
std::string
&);
63
64
static
std::string
histcontrol (
void
);
65
66
static
void
set_size (
int
);
67
68
static
int
size (
void
);
69
70
static
void
ignore_entries (
bool
=
true
);
71
72
static
bool
ignoring_entries (
void
);
73
74
static
bool
add (
const
std::string
&);
75
76
static
void
remove
(int);
77
78
static
void
clear (
void
);
79
80
static
int
where (
void
);
81
82
static
int
length
(
void
);
83
84
static
int
max_input_history (
void
);
85
86
static
int
base (
void
);
87
88
static
int
current_number (
void
);
89
90
static
void
stifle (
int
);
91
92
static
int
unstifle (
void
);
93
94
static
int
is_stifled (
void
);
95
96
static
void
set_mark (
int
n);
97
98
// Gag. This declaration has to match the Function typedef in
99
// readline.h.
100
101
static
int
goto_mark (
void
);
102
103
static
void
read (
bool
=
true
);
104
105
static
void
read (
const
std::string
&,
bool
=
true
);
106
107
static
void
read_range (
int
= -1,
int
= -1,
bool
=
true
);
108
109
static
void
read_range (
const
std::string
&,
int
= -1,
int
= -1,
110
bool
=
true
);
111
112
static
void
write (
const
std::string
& =
""
);
113
114
static
void
append
(
const
std::string
& =
""
);
115
116
static
void
truncate_file (
const
std::string
& =
""
,
int
= -1);
117
118
static
string_vector
list
(
int
= -1,
bool
=
false
);
119
120
static
std::string
get_entry (
int
);
121
122
static
void
replace_entry (
int
,
const
std::string
&);
123
124
static
void
clean_up_and_save (
const
std::string
& =
""
,
int
= -1);
125
126
private
:
127
128
static
bool
instance_ok (
void
);
129
130
static
void
make_command_history (
void
);
131
132
// The real thing.
133
static
command_history
*
instance
;
134
135
static
void
cleanup_instance
(
void
) {
delete
instance; instance =
nullptr
; }
136
137
protected
:
138
139
// To use something other than the GNU history library, derive a new
140
// class from command_history, overload these functions as
141
// necessary, and make instance point to the new class.
142
143
virtual
void
do_set_file (
const
std::string
&);
144
145
virtual
std::string
do_file (
void
);
146
147
virtual
void
do_process_histcontrol (
const
std::string
&);
148
149
virtual
std::string
do_histcontrol
(
void
)
const
{
return
""
; }
150
151
virtual
void
do_initialize (
bool
,
const
std::string
&,
int
,
152
const
std::string
&);
153
154
virtual
bool
do_is_initialized (
void
)
const
;
155
156
virtual
void
do_set_size (
int
);
157
158
virtual
int
do_size (
void
)
const
;
159
160
virtual
void
do_ignore_entries (
bool
);
161
162
virtual
bool
do_ignoring_entries (
void
)
const
;
163
164
virtual
bool
do_add (
const
std::string
&);
165
166
virtual
void
do_remove (
int
);
167
168
virtual
void
do_clear (
void
);
169
170
virtual
int
do_where (
void
)
const
;
171
172
virtual
int
do_length (
void
)
const
;
173
174
virtual
int
do_max_input_history (
void
)
const
;
175
176
virtual
int
do_base (
void
)
const
;
177
178
virtual
int
do_current_number (
void
)
const
;
179
180
virtual
void
do_stifle (
int
);
181
182
virtual
int
do_unstifle (
void
);
183
184
virtual
int
do_is_stifled (
void
)
const
;
185
186
virtual
void
do_set_mark (
int
);
187
188
virtual
int
do_goto_mark (
void
);
189
190
virtual
void
do_read (
const
std::string
&,
bool
);
191
192
virtual
void
do_read_range (
const
std::string
&,
int
,
int
,
bool
);
193
194
virtual
void
do_write (
const
std::string
&)
const
;
195
196
virtual
void
do_append (
const
std::string
&);
197
198
virtual
void
do_truncate_file (
const
std::string
&,
int
)
const
;
199
200
virtual
string_vector
do_list (
int
,
bool
)
const
;
201
202
virtual
std::string
do_get_entry (
int
)
const
;
203
204
virtual
void
do_replace_entry (
int
,
const
std::string
&);
205
206
virtual
void
do_clean_up_and_save (
const
std::string
&,
int
);
207
208
void
error
(
int
,
const
std::string
& msg =
""
)
const
;
209
210
void
error
(
const
std::string
&)
const
;
211
212
// TRUE means we have initialized the history filename and number of
213
// lines to save.
214
bool
initialized
;
215
216
// TRUE means we are ignoring new additions.
217
bool
ignoring_additions
;
218
219
// Bitmask for history control options. See oct-rl-hist.h.
220
int
history_control
;
221
222
// The number of history lines we read from the history file.
223
int
lines_in_file
;
224
225
// The number of history lines we've saved so far.
226
int
lines_this_session
;
227
228
// The default history file.
229
std::string
xfile
;
230
231
// The number of lines of history to save.
232
int
xsize
;
233
};
234
}
235
236
#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
237
238
OCTAVE_DEPRECATED (4.2,
"use 'octave::command_history' instead"
)
239
typedef
octave
::command_history command_history;
240
241
#endif
242
243
#endif
octave::command_history::cleanup_instance
static void cleanup_instance(void)
Definition:
cmd-hist.h:135
octave::command_history::initialized
bool initialized
Definition:
cmd-hist.h:214
octave
Definition:
aepbalance.cc:44
file
For example cd octave end example noindent changes the current working directory to file
Definition:
dirfns.cc:124
list
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition:
oct-hist.cc:734
octave::command_history::command_history
command_history(void)
Definition:
cmd-hist.h:40
error
void error(const char *fmt,...)
Definition:
error.cc:578
str-vec.h
octave::command_history::instance
static command_history * instance
Definition:
cmd-hist.h:133
octave::command_history::xsize
int xsize
Definition:
cmd-hist.h:232
initialize
static void initialize(void)
Definition:
mkoctfile.in.cc:129
octave::command_history::do_histcontrol
virtual std::string do_histcontrol(void) const
Definition:
cmd-hist.h:149
octave::command_history::lines_this_session
int lines_this_session
Definition:
cmd-hist.h:226
false
is false
Definition:
cellfun.cc:400
append
bool append
Definition:
load-save.cc:1618
octave::jit_convention::length
Definition:
jit-typeinfo.h:130
initialized
static bool initialized
Definition:
defaults.cc:48
octave::command_history::xfile
std::string xfile
Definition:
cmd-hist.h:229
octave::command_history::lines_in_file
int lines_in_file
Definition:
cmd-hist.h:223
string
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition:
utils.cc:888
octave::command_history::ignoring_additions
bool ignoring_additions
Definition:
cmd-hist.h:217
octave::command_history
Definition:
cmd-hist.h:34
string_vector
Definition:
str-vec.h:34
octave::command_history::history_control
int history_control
Definition:
cmd-hist.h:220
liboctave
util
cmd-hist.h
Generated on Sat Sep 1 2018 14:01:46 for GNU Octave by
1.8.14