[NEW_FEATURE] Automatic Backup System (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1211 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 2014-04-02 22:02:10 +00:00
parent 9b341806ae
commit ac4b7ea8db
4 changed files with 43 additions and 32 deletions

View File

@ -4245,7 +4245,7 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool
}
void Notepad_plus::getCurrentOpenedFiles(Session & session, bool /*includUntitledDoc*/)
void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledDoc)
{
_mainEditView.saveCurrentPos(); //save position so itll be correct in the session
_subEditView.saveCurrentPos(); //both views
@ -4270,33 +4270,34 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool /*includUntitle
Buffer * buf = MainFileManager->getBufferByID(bufID);
if (PathFileExists(buf->getFullPathName()))
if (!includUntitledDoc)
if (!PathFileExists(buf->getFullPathName()))
continue;
generic_string languageName = getLangFromMenu(buf);
const TCHAR *langName = languageName.c_str();
sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), int(buf->getLastModifiedTimestamp()));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT);
for (int j = 0 ; j < maxLine ; ++j)
{
generic_string languageName = getLangFromMenu(buf);
const TCHAR *langName = languageName.c_str();
sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), int(buf->getLastModifiedTimestamp()));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT);
for (int j = 0 ; j < maxLine ; ++j)
if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0)
{
if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0)
{
sfi.marks.push_back(j);
}
sfi.marks.push_back(j);
}
if (i == activeIndex)
{
editView->getCurrentFoldStates(sfi._foldStates);
}
else
{
sfi._foldStates = buf->getHeaderLineState(editView);
}
viewFiles->push_back(sfi);
}
if (i == activeIndex)
{
editView->getCurrentFoldStates(sfi._foldStates);
}
else
{
sfi._foldStates = buf->getHeaderLineState(editView);
}
viewFiles->push_back(sfi);
}
}
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);

View File

@ -266,6 +266,8 @@ public:
NppParameters::getInstance()->writeShortcuts();
};
void saveSession(const Session & session);
void saveCurrentSession();
void saveFindHistory(){
_findReplaceDlg.saveFindHistory();
(NppParameters::getInstance())->writeFindHistory();

View File

@ -1408,3 +1408,15 @@ void Notepad_plus::saveSession(const Session & session)
{
(NppParameters::getInstance())->writeSession(session);
}
void Notepad_plus::saveCurrentSession()
{
NppParameters *nppParam = NppParameters::getInstance();
if (nppParam->getNppGUI()._rememberLastSession && _rememberThisSession)
{
Session currentSession;
getCurrentOpenedFiles(currentSession, true);
nppParam->writeSession(currentSession);
}
}

View File

@ -736,14 +736,10 @@ bool FileManager::backupCurrentBuffer()
result = true; // no backup file to delete
}
//printStr(TEXT("backup sync"));
/*
if (hasModifForSession && nppgui._rememberLastSession && _rememberThisSession)
{
Session currentSession;
getCurrentOpenedFiles(currentSession);
saveSession(currentSession);
}
*/
if (hasModifForSession)
_pNotepadPlus->saveCurrentSession();
::ReleaseMutex(mutex);
return result;
}