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