[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 _mainEditView.saveCurrentPos(); //save position so itll be correct in the session
_subEditView.saveCurrentPos(); //both views _subEditView.saveCurrentPos(); //both views
@ -4270,8 +4270,10 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool /*includUntitle
Buffer * buf = MainFileManager->getBufferByID(bufID); Buffer * buf = MainFileManager->getBufferByID(bufID);
if (PathFileExists(buf->getFullPathName())) if (!includUntitledDoc)
{ if (!PathFileExists(buf->getFullPathName()))
continue;
generic_string languageName = getLangFromMenu(buf); generic_string languageName = getLangFromMenu(buf);
const TCHAR *langName = languageName.c_str(); const TCHAR *langName = languageName.c_str();
sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), int(buf->getLastModifiedTimestamp())); 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); viewFiles->push_back(sfi);
} }
} }
}
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
} }

View File

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

View File

@ -1408,3 +1408,15 @@ void Notepad_plus::saveSession(const Session & session)
{ {
(NppParameters::getInstance())->writeSession(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 result = true; // no backup file to delete
} }
//printStr(TEXT("backup sync")); //printStr(TEXT("backup sync"));
/*
if (hasModifForSession && nppgui._rememberLastSession && _rememberThisSession) if (hasModifForSession)
{ _pNotepadPlus->saveCurrentSession();
Session currentSession;
getCurrentOpenedFiles(currentSession);
saveSession(currentSession);
}
*/
::ReleaseMutex(mutex); ::ReleaseMutex(mutex);
return result; return result;
} }