00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_cmd_hist_h)
00024 #define octave_cmd_hist_h 1
00025
00026 #include <string>
00027
00028 #include "str-vec.h"
00029
00030 class
00031 command_history
00032 {
00033 protected:
00034
00035 command_history (void)
00036 : ignoring_additions (false), lines_in_file (0),
00037 lines_this_session (0), xfile (), xsize (-1) { }
00038
00039 public:
00040
00041 virtual ~command_history (void) { }
00042
00043 static void set_file (const std::string&);
00044
00045 static std::string file (void);
00046
00047 static void set_size (int);
00048
00049 static int size (void);
00050
00051 static void ignore_entries (bool = true);
00052
00053 static bool ignoring_entries (void);
00054
00055 static void add (const std::string&);
00056
00057 static void remove (int);
00058
00059 static int where (void);
00060
00061 static int length (void);
00062
00063 static int max_input_history (void);
00064
00065 static int base (void);
00066
00067 static int current_number (void);
00068
00069 static void stifle (int);
00070
00071 static int unstifle (void);
00072
00073 static int is_stifled (void);
00074
00075 static void set_mark (int n);
00076
00077
00078
00079
00080 static int goto_mark (void);
00081
00082 static void read (bool = true);
00083
00084 static void read (const std::string&, bool = true);
00085
00086 static void read_range (int = -1, int = -1, bool = true);
00087
00088 static void read_range (const std::string&, int = -1, int = -1,
00089 bool = true);
00090
00091 static void write (const std::string& = std::string ());
00092
00093 static void append (const std::string& = std::string ());
00094
00095 static void truncate_file (const std::string& = std::string (), int = -1);
00096
00097 static string_vector list (int = -1, bool = false);
00098
00099 static std::string get_entry (int);
00100
00101 static void replace_entry (int, const std::string&);
00102
00103 static void clean_up_and_save (const std::string& = std::string (), int = -1);
00104
00105 private:
00106
00107
00108
00109 command_history (const command_history&);
00110
00111 command_history& operator = (const command_history&);
00112
00113 static bool instance_ok (void);
00114
00115 static void make_command_history (void);
00116
00117
00118 static command_history *instance;
00119
00120 protected:
00121
00122
00123
00124
00125
00126 virtual void do_set_file (const std::string&);
00127
00128 virtual std::string do_file (void);
00129
00130 virtual void do_set_size (int);
00131
00132 virtual int do_size (void);
00133
00134 virtual void do_ignore_entries (bool);
00135
00136 virtual bool do_ignoring_entries (void);
00137
00138 virtual void do_add (const std::string&);
00139
00140 virtual void do_remove (int);
00141
00142 virtual int do_where (void);
00143
00144 virtual int do_length (void);
00145
00146 virtual int do_max_input_history (void);
00147
00148 virtual int do_base (void);
00149
00150 virtual int do_current_number (void);
00151
00152 virtual void do_stifle (int);
00153
00154 virtual int do_unstifle (void);
00155
00156 virtual int do_is_stifled (void);
00157
00158 virtual void do_set_mark (int);
00159
00160 virtual int do_goto_mark (void);
00161
00162 virtual void do_read (const std::string&, bool);
00163
00164 virtual void do_read_range (const std::string&, int, int, bool);
00165
00166 virtual void do_write (const std::string&);
00167
00168 virtual void do_append (const std::string&);
00169
00170 virtual void do_truncate_file (const std::string&, int);
00171
00172 virtual string_vector do_list (int, bool);
00173
00174 virtual std::string do_get_entry (int);
00175
00176 virtual void do_replace_entry (int, const std::string&);
00177
00178 virtual void do_clean_up_and_save (const std::string&, int);
00179
00180 void error (int);
00181
00182 void error (const std::string&);
00183
00184
00185 bool ignoring_additions;
00186
00187
00188 int lines_in_file;
00189
00190
00191 int lines_this_session;
00192
00193
00194 std::string xfile;
00195
00196
00197 int xsize;
00198 };
00199
00200 #endif
00201
00202
00203
00204
00205
00206