1797
|
1 /* |
|
2 |
|
3 Copyright (C) 1996 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 the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
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 |
|
31 command_history |
|
32 { |
|
33 public: |
|
34 |
2658
|
35 command_history (const string& = string (), int = -1, bool = false) |
|
36 |
|
37 command_history (const string& = string (), int = -1) |
1797
|
38 |
|
39 ~command_history (void) { initialized = false; } |
|
40 |
|
41 void set_file (const string&); |
|
42 |
|
43 string file (void); |
|
44 |
|
45 void set_size (int); |
|
46 |
|
47 int size (void); |
|
48 |
|
49 void ignore_entries (bool = true); |
|
50 |
|
51 bool ignoring_entries (void); |
|
52 |
|
53 void add (const string&); |
|
54 |
|
55 void remove (int); |
|
56 |
|
57 int where (void); |
|
58 |
|
59 int base (void); |
|
60 |
|
61 int current_number (void); |
|
62 |
|
63 void stifle (int); |
|
64 |
|
65 int unstifle (void); |
|
66 |
|
67 int is_stifled (void); |
|
68 |
2658
|
69 void read (bool = true); |
|
70 |
|
71 void read (const string& = string (), bool = true) |
1797
|
72 |
2658
|
73 void read_range (int = -1, int = -1, bool = true) |
|
74 |
|
75 void read_range (const string& = string (), int = -1, int = -1, |
|
76 bool = true) |
1797
|
77 |
|
78 void write (const string& = string ()); |
|
79 |
|
80 void append (const string& = string ()); |
|
81 |
|
82 void truncate_file (const string& = string (), int = -1); |
|
83 |
|
84 string_vector list (int = -1, int = 0); |
|
85 |
|
86 string get_entry (int); |
|
87 |
|
88 void replace_entry (int, const string&); |
|
89 |
|
90 void clean_up_and_save (const string& = string (), int = -1); |
|
91 |
|
92 private: |
|
93 |
|
94 // We can only have one history object in any given program. |
|
95 static bool initialized; |
|
96 |
|
97 // TRUE means we are ignoring new additions. |
|
98 bool ignoring_additions; |
|
99 |
|
100 // The number of hisory lines we read from the history file. |
|
101 int lines_in_file; |
|
102 |
|
103 // The number of history lines we've saved so far. |
|
104 int lines_this_session; |
|
105 |
|
106 // The default history file. |
|
107 string xfile; |
|
108 |
|
109 // The number of lines of history to save. |
|
110 int xsize; |
|
111 |
|
112 void error (int); |
|
113 |
|
114 void error (const string&); |
|
115 |
|
116 command_history (const command_history&); |
|
117 |
|
118 command_history& operator = (const command_history&); |
|
119 }; |
|
120 |
|
121 #endif |
|
122 |
|
123 /* |
|
124 ;;; Local Variables: *** |
|
125 ;;; mode: C++ *** |
|
126 ;;; End: *** |
|
127 */ |