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