[NEW_FEATURE] Automatic Backup System.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1227 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-04-23 18:18:19 +00:00
parent f8142f4aad
commit e4ff453125
4 changed files with 31 additions and 16 deletions

View File

@ -501,6 +501,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_COMMAND:
{
if (HIWORD(wParam) == SCEN_SETFOCUS)
{
HWND hMain = _mainEditView.getHSelf(), hSec = _subEditView.getHSelf();
@ -523,7 +524,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
else
command(LOWORD(wParam));
}
return TRUE;
}
return TRUE;
case NPPM_INTERNAL_SAVECURRENTSESSION:
{
NppParameters *nppParam = NppParameters::getInstance();
if (nppParam->getNppGUI()._rememberLastSession && _rememberThisSession)
{
Session currentSession;
getCurrentOpenedFiles(currentSession, true);
nppParam->writeSession(currentSession);
}
}
return TRUE;
case NPPM_INTERNAL_RELOADNATIVELANG:
{

View File

@ -1680,11 +1680,5 @@ void Notepad_plus::saveSession(const Session & session)
void Notepad_plus::saveCurrentSession()
{
NppParameters *nppParam = NppParameters::getInstance();
if (nppParam->getNppGUI()._rememberLastSession && _rememberThisSession)
{
Session currentSession;
getCurrentOpenedFiles(currentSession, true);
nppParam->writeSession(currentSession);
}
::PostMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_SAVECURRENTSESSION, 0, 0);
}

View File

@ -696,6 +696,9 @@ bool FileManager::backupCurrentBuffer()
// Set created file name in buffer
buffer->setBackupFileName(backupFilePath);
// Session changes, save it
hasModifForSession = true;
}
@ -743,7 +746,6 @@ bool FileManager::backupCurrentBuffer()
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
buffer->setModifiedStatus(false);
hasModifForSession = true;
result = true; //all done
::SetEvent(writeEvent);
@ -767,17 +769,20 @@ bool FileManager::backupCurrentBuffer()
generic_string file2Delete = buffer->getBackupFileName();
buffer->setBackupFileName(TEXT(""));
result = (::DeleteFile(file2Delete.c_str()) != 0);
// Session changes, save it
hasModifForSession = true;
}
//printStr(TEXT("backup deleted in backupCurrentBuffer"));
result = true; // no backup file to delete
}
//printStr(TEXT("backup sync"));
/*
if (hasModifForSession)
_pNotepadPlus->saveCurrentSession();
*/
if (result && hasModifForSession)
{
//printStr(buffer->getBackupFileName().c_str());
_pNotepadPlus->saveCurrentSession();
}
return result;
}
@ -794,7 +799,7 @@ bool FileManager::deleteCurrentBufferBackup()
if (::WaitForSingleObject(writeEvent, INFINITE) != WAIT_OBJECT_0)
{
// problem!!!
printStr(TEXT("pb!!!"));
printStr(TEXT("WaitForSingleObject problem in deleteCurrentBufferBackup()!"));
return false;
}
@ -832,7 +837,7 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g
if (::WaitForSingleObject(writeEvent, INFINITE) != WAIT_OBJECT_0)
{
// problem!!!
printStr(TEXT("pb!!!"));
printStr(TEXT("WaitForSingleObject problem in saveBuffer()!"));
return false;
}

View File

@ -394,7 +394,9 @@
#define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35)
#define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36)
#define NPPM_INTERNAL_GETSCINTEDTVIEW (NOTEPADPLUS_USER_INTERNAL + 37)
#define NPPM_INTERNAL_ENABLESNAPSHOT (NOTEPADPLUS_USER_INTERNAL + 38)
#define NPPM_INTERNAL_ENABLESNAPSHOT (NOTEPADPLUS_USER_INTERNAL + 38)
#define NPPM_INTERNAL_SAVECURRENTSESSION (NOTEPADPLUS_USER_INTERNAL + 39)
//wParam: 0
//lParam: document new index