/*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2007-2008 - INRIA - Allan CORNET
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */

/*------------------------------------------------------------------------*/
#ifndef __HISTORYMANAGER_C_H__
#define __HISTORYMANAGER_C_H__
#include "BOOL.h"
#include "dynlib_history_manager.h"
/*------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/*------------------------------------------------------------------------*/
	/**
	* get history manager state
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL historyIsEnabled(void);

	/**
	 * append lines to History manager
	 * @param array of string
	 * @param size of the array of string
	 * @return TRUE or FALSE
	 */
	HISTORY_MANAGER_IMPEXP BOOL appendLinesToScilabHistory(char **lines_, int numberoflines);
	// Note it is lines_ because line is a keyword for term stuff

	/**
	* add a line to History manager
	* @param a line to add
	* line isn't added if it is the same as previous (FALSE)
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL appendLineToScilabHistory(char *line);

	/**
	* Display history
	*/
	HISTORY_MANAGER_IMPEXP void displayScilabHistory(void);

	/**
	* save history in a file
	* @param a filename if NULL saves in default filename
	* default filename --> SCIHOME/history.scilab
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL writeScilabHistoryToFile(char *filename);

	/**
	* load history from a file
	* @param a filename if NULL load from default filename
	* default filename --> SCIHOME/history.scilab
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL loadScilabHistoryFromFile(char *filename);

	/**
	* set filename of history
	* @param filename of history
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL setFilenameScilabHistory(char *filename);

	/**
	* get filename of history
	* @return a filename
	*/
	HISTORY_MANAGER_IMPEXP char *getFilenameScilabHistory(void);

	/**
	* set default filename of history
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL setDefaultFilenameScilabHistory(void);

	/**
	* reset history manager
	*/
	HISTORY_MANAGER_IMPEXP void resetScilabHistory(void);

	/**
	* Get all lines in history
	* @return a array of string
	*/
	HISTORY_MANAGER_IMPEXP char **getAllLinesOfScilabHistory(void);

	/**
	* Get numbers of lines in history
	* size of array returned by getAllLinesOfScilabHistory
	* @return int
	*/
	HISTORY_MANAGER_IMPEXP int getSizeAllLinesOfScilabHistory(void);

	/**
	* set new token to search in history
	* @param token (a string)
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL setSearchedTokenInScilabHistory(char *token);

	/**
	* reset search in history
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL resetSearchedTokenInScilabHistory(void);

	/**
	* get token searched in history
	* @return token (a string)
	*/
	HISTORY_MANAGER_IMPEXP char *getSearchedTokenInScilabHistory(void);

	/**
	* Get the previous line in Scilab history
	* @return a line or NULL
	* after a appendLine iterator go to end
	*/
	HISTORY_MANAGER_IMPEXP char *getPreviousLineInScilabHistory(void);

	/**
	* Get the next line in Scilab history
	* @return a line or NULL
	* after a appendLine iterator go to end
	*/
	HISTORY_MANAGER_IMPEXP char *getNextLineInScilabHistory(void);

	/**
	* Get numbers of lines in history
	* @return number of lines
	*/
	HISTORY_MANAGER_IMPEXP int getNumberOfLinesInScilabHistory(void);

	/**
	* set consecutive duplicate lines are added
	* @param doit (TRUE or FALSE)
	*/
	HISTORY_MANAGER_IMPEXP void setSaveConsecutiveDuplicateLinesInScilabHistory(BOOL doit);

	/**
	* indicate if consecutive duplicate lines are added
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL getSaveConsecutiveDuplicateLinesInScilabHistory(void);

	/**
	* Set after how many lines history is saved
	* @param number between 0 and Max
	* default value is 0 (disabled)
	*/
	HISTORY_MANAGER_IMPEXP void setAfterHowManyLinesScilabHistoryIsSaved(int num);

	/**
	* Get after how many lines history is saved
	* @return number between 0 and Max
	* default value is 0 (disabled)
	*/
	HISTORY_MANAGER_IMPEXP int getAfterHowManyLinesScilabHistoryIsSaved(void);

	/**
	* Get the Nth Line in history
	* @param N
	* @return the Nth Line
	*/
	HISTORY_MANAGER_IMPEXP char *getNthLineInScilabHistory(int N);

	/**
	* delete the Nth Line in history
	* @param N
	* @return TRUE or FALSE
	*/
	HISTORY_MANAGER_IMPEXP BOOL deleteNthLineScilabHistory(int N);

	/**
	* get number of lines of history
	* @return a number >= 0
	*/
	HISTORY_MANAGER_IMPEXP int getSizeScilabHistory(void);


/*------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
/*------------------------------------------------------------------------*/
#endif /* __HISTORYMANAGER_C_H__ */
/*------------------------------------------------------------------------*/
