2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2007-2008 - INRIA - Allan CORNET
4 * Copyright (C) 2011 - DIGITEO - Allan CORNET
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 /*------------------------------------------------------------------------*/
15 #ifndef __HISTORYMANAGER_CPP_H__
16 #define __HISTORYMANAGER_CPP_H__
17 /*------------------------------------------------------------------------*/
19 /*------------------------------------------------------------------------*/
24 /*------------------------------------------------------------------------*/
26 #include "CommandLine.hxx"
27 #include "HistoryFile.hxx"
28 #include "HistorySearch.hxx"
30 /*------------------------------------------------------------------------*/
45 * add a line to History manager
46 * @param a line to add
47 * line isn't added if it is the same as previous (FALSE)
48 * @return TRUE or FALSE
50 BOOL appendLine(char *cline);
53 * append lines to History manager
54 * @param array of string
55 * @param size of the array of string
56 * @return TRUE or FALSE
58 BOOL appendLines(char **lines,int nbrlines);
63 void displayHistory(void);
66 * get filename of history
69 char *getFilename(void);
72 * set filename of history
73 * @param filename of history
74 * @return TRUE or FALSE
76 void setFilename(char *filename);
79 * set default filename of history
80 * @return TRUE or FALSE
82 BOOL setDefaultFilename(void);
85 * save history in a file
86 * @param a filename if NULL saves in default filename
87 * default filename --> SCIHOME/history.scilab
88 * @return TRUE or FALSE
90 BOOL writeToFile(char *filename);
93 * load history from a file
94 * @param a filename if NULL load from default filename
95 * default filename --> SCIHOME/<scilab version>history.scilab
96 * @return TRUE or FALSE
98 BOOL loadFromFile(char *filename);
101 * reset history manager
106 * Get all lines in history
107 * @param output size of the array of string
108 * @return an array of strings
110 char **getAllLines(int *numberoflines);
113 * returns the first line in history
116 char *getFirstLine(void);
119 * returns the last line in history
122 char *getLastLine(void);
125 * get number of lines of history
126 * @return a number >= 0
128 int getNumberOfLines(void);
131 * Get the Nth Line in history
133 * @return the Nth Line
135 char *getNthLine(int N);
138 * delete the Nth Line in history
140 * @return TRUE or FALSE
142 BOOL deleteNthLine(int N);
145 * Allow to save consecutive duplicate lines
146 * @param doit : TRUE (to allow) or FALSE
148 void setSaveConsecutiveDuplicateLines(BOOL doit);
151 * get state about to save consecutive duplicate lines
152 * @return TRUE or FALSE
154 BOOL getSaveConsecutiveDuplicateLines(void);
157 * set after how many lines history is saved
158 * @param num : number of lines
160 void setAfterHowManyLinesHistoryIsSaved(int num);
163 * get after how many lines history is saved
164 * @return a int : number of lines
166 int getAfterHowManyLinesHistoryIsSaved(void);
169 * set new token to search in history
170 * @param token (a string)
171 * @return TRUE or FALSE
173 BOOL setToken(char *token);
176 * get token searched in history
177 * @return token (a string)
179 char *getToken(void);
182 * resettoken searched in history
183 * @return TRUE or FALSE
185 BOOL resetToken(void);
188 * Get the previous line in search
191 char *getPreviousLine(void);
194 * Get the next line in Scilab history
195 * @return a line or NULL
196 * after an appendLine iterator go to end
198 char *getNextLine(void);
201 * get info about history file was truncated
202 * @return TRUE or FALSE
204 BOOL isTruncated(void);
209 BOOL setNumberOfLinesMax(int nbLinesMax);
214 int getNumberOfLinesMax(void);
220 HistorySearch my_search;
222 list<CommandLine> CommandsList;
224 BOOL saveconsecutiveduplicatelines;
225 int afterhowmanylineshistoryissaved;
226 int numberoflinesbeforehistoryissaved;
229 * search if line is a beginning of a session
230 * @return TRUE or FALSE
232 BOOL isBeginningSessionLine(char *line);
235 * add as first line beginning session info
237 void fixHistorySession(void);
242 /*------------------------------------------------------------------------*/
243 #endif /* __cplusplus */
244 /*------------------------------------------------------------------------*/
245 #endif /* __HISTORYMANAGER_CPP_H__ */