/*--------------------------------------------------------------------------*/ BOOL HistoryManager::reset(void) { char* pstCommentBeginSession = NULL; m_Commands.clear(); m_HF.reset(); m_HF.setDefaultFilename(); m_HS.reset(); m_bAllowConsecutiveCommand = FALSE; m_iSaveLimit = 0; m_iSavedLines = 0; CommandHistoryReset(); /* Add date & time begin session */ pstCommentBeginSession = getCommentDateSession(FALSE); if (pstCommentBeginSession) { appendLine(pstCommentBeginSession); FREE(pstCommentBeginSession); pstCommentBeginSession = NULL; return TRUE; } return FALSE; }
/*--------------------------------------------------------------------------*/ void HistoryManager::reset(void) { char *commentbeginsession = NULL; CommandsList.clear(); my_file.reset(); my_file.setDefaultFilename(); my_search.reset(); saveconsecutiveduplicatelines = FALSE; afterhowmanylineshistoryissaved = 0; numberoflinesbeforehistoryissaved = 0; CommandHistoryReset(); /* Add date & time begin session */ commentbeginsession = getCommentDateSession(FALSE); if (commentbeginsession) { appendLine(commentbeginsession); FREE(commentbeginsession); commentbeginsession = NULL; } }
/*--------------------------------------------------------------------------*/ void HistoryManager::fixHistorySession(void) { /* add date & time @ begin session */ char* pstCommentBeginSession = getCommentDateSession(FALSE); if (pstCommentBeginSession) { m_Commands.push_front(pstCommentBeginSession); FREE(pstCommentBeginSession); pstCommentBeginSession = NULL; } }
/*--------------------------------------------------------------------------*/ void HistoryManager::fixHistorySession(void) { /* add date & time @ begin session */ char *commentbeginsession = getCommentDateSession(FALSE); if (commentbeginsession) { CommandLine Line(commentbeginsession); CommandsList.push_front(Line); FREE(commentbeginsession); commentbeginsession = NULL; } }
/*------------------------------------------------------------------------*/ BOOL HistoryManager::loadFromFile(char *filename) { if (filename) { char *commentbeginsession = NULL; std::string name; name.assign(filename); if (my_file.loadFromFile(name) == HISTORY_TRUNCATED) { bTruncated = TRUE; } CommandsList.clear(); CommandsList = my_file.getHistory(); if (CommandsList.size() > 0) { char *firstLine = getFirstLine(); if (firstLine) { if (!isBeginningSessionLine(firstLine)) { fixHistorySession(); } FREE(firstLine); firstLine = NULL; } } /* add date & time @ begin session */ commentbeginsession = getCommentDateSession(FALSE); appendLine(commentbeginsession); FREE(commentbeginsession); commentbeginsession = NULL; CommandHistoryLoadFromFile(); return TRUE; } return FALSE; }
/*------------------------------------------------------------------------*/ HistoryManager* HistoryManager::getInstance() { if (m_pHM == NULL) { m_pHM = new HistoryManager(); /* add date & time @ begin session */ char *commentbeginsession = getCommentDateSession(FALSE); if (commentbeginsession) { appendLineToScilabHistory(commentbeginsession); FREE(commentbeginsession); commentbeginsession = NULL; } m_pHM->setToken(""); } return m_pHM; }
/*------------------------------------------------------------------------*/ BOOL HistoryManager::loadFromFile(char* _pstFilename) { if (_pstFilename) { char* pstCommentBeginSession = NULL; if (m_HF.loadFromFile(_pstFilename) == HISTORY_TRUNCATED) { m_bTruncated = TRUE; } m_Commands.clear(); m_Commands = m_HF.getHistory(); if (m_Commands.size() > 0) { char* pstFirstLine = getFirstLine(); if (pstFirstLine) { if (!isBeginningSessionLine(pstFirstLine)) { fixHistorySession(); } FREE(pstFirstLine); pstFirstLine = NULL; } } /* add date & time @ begin session */ pstCommentBeginSession = getCommentDateSession(FALSE); appendLine(pstCommentBeginSession); FREE(pstCommentBeginSession); pstCommentBeginSession = NULL; CommandHistoryLoadFromFile(); return TRUE; } return FALSE; }