Mercurial > hg > octave-nkf
annotate liboctave/cmd-hist.h @ 10805:8c858a1a2079
simplify Matrix::extract
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 20 Jul 2010 12:56:05 +0200 |
parents | cbc402e64d83 |
children | 944b7e20fc5a |
rev | line source |
---|---|
1797 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2004, 2005, 2006, 2007 John W. Eaton |
1797 | 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 the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1797 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1797 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_cmd_hist_h) | |
24 #define octave_cmd_hist_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include "str-vec.h" | |
29 | |
30 class | |
6108 | 31 OCTAVE_API |
1797 | 32 command_history |
33 { | |
2926 | 34 protected: |
35 | |
36 command_history (void) | |
37 : ignoring_additions (false), lines_in_file (0), | |
38 lines_this_session (0), xfile (), xsize (-1) { } | |
39 | |
1797 | 40 public: |
41 | |
2926 | 42 virtual ~command_history (void) { } |
43 | |
3504 | 44 static void set_file (const std::string&); |
1797 | 45 |
3504 | 46 static std::string file (void); |
1797 | 47 |
2926 | 48 static void set_size (int); |
1797 | 49 |
2926 | 50 static int size (void); |
51 | |
52 static void ignore_entries (bool = true); | |
1797 | 53 |
2926 | 54 static bool ignoring_entries (void); |
1797 | 55 |
3504 | 56 static void add (const std::string&); |
1797 | 57 |
2926 | 58 static void remove (int); |
59 | |
60 static int where (void); | |
1797 | 61 |
2926 | 62 static int length (void); |
1797 | 63 |
2926 | 64 static int max_input_history (void); |
1797 | 65 |
2926 | 66 static int base (void); |
1797 | 67 |
2926 | 68 static int current_number (void); |
1797 | 69 |
2926 | 70 static void stifle (int); |
1797 | 71 |
2926 | 72 static int unstifle (void); |
1797 | 73 |
2926 | 74 static int is_stifled (void); |
1797 | 75 |
2926 | 76 static void set_mark (int n); |
1797 | 77 |
2926 | 78 // Gag. This declaration has to match the Function typedef in |
79 // readline.h. | |
1797 | 80 |
4802 | 81 static int goto_mark (void); |
2926 | 82 |
83 static void read (bool = true); | |
2658 | 84 |
3504 | 85 static void read (const std::string&, bool = true); |
1797 | 86 |
2926 | 87 static void read_range (int = -1, int = -1, bool = true); |
2658 | 88 |
3504 | 89 static void read_range (const std::string&, int = -1, int = -1, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
90 bool = true); |
1797 | 91 |
3504 | 92 static void write (const std::string& = std::string ()); |
1797 | 93 |
3504 | 94 static void append (const std::string& = std::string ()); |
1797 | 95 |
3504 | 96 static void truncate_file (const std::string& = std::string (), int = -1); |
1797 | 97 |
2926 | 98 static string_vector list (int = -1, bool = false); |
1797 | 99 |
3504 | 100 static std::string get_entry (int); |
1797 | 101 |
3504 | 102 static void replace_entry (int, const std::string&); |
1797 | 103 |
3504 | 104 static void clean_up_and_save (const std::string& = std::string (), int = -1); |
1797 | 105 |
106 private: | |
107 | |
2926 | 108 // No copying! |
109 | |
110 command_history (const command_history&); | |
111 | |
112 command_history& operator = (const command_history&); | |
113 | |
114 static bool instance_ok (void); | |
115 | |
116 static void make_command_history (void); | |
117 | |
118 // The real thing. | |
119 static command_history *instance; | |
120 | |
121 protected: | |
122 | |
123 // To use something other than the GNU history library, derive a new | |
124 // class from command_history, overload these functions as | |
125 // necessary, and make instance point to the new class. | |
126 | |
3504 | 127 virtual void do_set_file (const std::string&); |
2926 | 128 |
3504 | 129 virtual std::string do_file (void); |
2926 | 130 |
131 virtual void do_set_size (int); | |
132 | |
133 virtual int do_size (void); | |
134 | |
135 virtual void do_ignore_entries (bool); | |
136 | |
137 virtual bool do_ignoring_entries (void); | |
138 | |
3504 | 139 virtual void do_add (const std::string&); |
2926 | 140 |
141 virtual void do_remove (int); | |
142 | |
143 virtual int do_where (void); | |
144 | |
145 virtual int do_length (void); | |
146 | |
147 virtual int do_max_input_history (void); | |
148 | |
149 virtual int do_base (void); | |
150 | |
151 virtual int do_current_number (void); | |
152 | |
153 virtual void do_stifle (int); | |
154 | |
155 virtual int do_unstifle (void); | |
156 | |
157 virtual int do_is_stifled (void); | |
158 | |
159 virtual void do_set_mark (int); | |
160 | |
4802 | 161 virtual int do_goto_mark (void); |
2926 | 162 |
3504 | 163 virtual void do_read (const std::string&, bool); |
2926 | 164 |
3504 | 165 virtual void do_read_range (const std::string&, int, int, bool); |
2926 | 166 |
3504 | 167 virtual void do_write (const std::string&); |
2926 | 168 |
3504 | 169 virtual void do_append (const std::string&); |
2926 | 170 |
3504 | 171 virtual void do_truncate_file (const std::string&, int); |
2926 | 172 |
173 virtual string_vector do_list (int, bool); | |
174 | |
3504 | 175 virtual std::string do_get_entry (int); |
2926 | 176 |
3504 | 177 virtual void do_replace_entry (int, const std::string&); |
2926 | 178 |
3504 | 179 virtual void do_clean_up_and_save (const std::string&, int); |
2926 | 180 |
181 void error (int); | |
182 | |
3504 | 183 void error (const std::string&); |
1797 | 184 |
185 // TRUE means we are ignoring new additions. | |
186 bool ignoring_additions; | |
187 | |
188 // The number of hisory lines we read from the history file. | |
189 int lines_in_file; | |
190 | |
191 // The number of history lines we've saved so far. | |
192 int lines_this_session; | |
193 | |
194 // The default history file. | |
3504 | 195 std::string xfile; |
1797 | 196 |
197 // The number of lines of history to save. | |
198 int xsize; | |
199 }; | |
200 | |
201 #endif |