[NEW_FEATURE] Automatic Backup System (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1211 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
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,8 +4270,10 @@ 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()));
@ -4298,7 +4300,6 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool /*includUntitle
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;
}