[NEW_FEATURE] Automatic Backup System (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1213 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-04-03 18:38:09 +00:00
parent 026aaf94a4
commit db0489c8ed
4 changed files with 40 additions and 26 deletions

View File

@ -235,7 +235,7 @@ public:
}; };
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
bool fileCloseAll(bool doDeleteBackup); bool fileCloseAll(bool doDeleteBackup, bool isBackupMode = false);
bool fileCloseAllButCurrent(); bool fileCloseAllButCurrent();
bool fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes); bool fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes);
bool fileCloseAllToLeft(); bool fileCloseAllToLeft();

View File

@ -1407,7 +1407,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
//Causing them to show on restart even though they are loaded by session //Causing them to show on restart even though they are loaded by session
_lastRecentFileList.setLock(true); //only lock when the session is remembered _lastRecentFileList.setLock(true); //only lock when the session is remembered
} }
bool allClosed = fileCloseAll(false); //try closing files before doing anything else bool allClosed = fileCloseAll(false, true); //try closing files before doing anything else
if (nppgui._rememberLastSession) if (nppgui._rememberLastSession)
{ {

View File

@ -117,7 +117,7 @@ void Notepad_plus::command(int id)
break; break;
case IDM_FILE_CLOSEALL: case IDM_FILE_CLOSEALL:
fileCloseAll(true); fileCloseAll(true, false);
checkDocState(); checkDocState();
break; break;

View File

@ -582,7 +582,7 @@ bool Notepad_plus::fileClose(BufferID id, int curView)
return true; return true;
} }
bool Notepad_plus::fileCloseAll(bool doDeleteBackup) bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isBackupMode)
{ {
//closes all documents, makes the current view the only one visible //closes all documents, makes the current view the only one visible
@ -597,19 +597,26 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup)
} }
else if (buf->isDirty()) else if (buf->isDirty())
{ {
activateBuffer(id, MAIN_VIEW); if (isBackupMode)
if(!activateBuffer(id, SUB_VIEW)) {
switchEditViewTo(MAIN_VIEW);
}
else
{
activateBuffer(id, MAIN_VIEW);
if(!activateBuffer(id, SUB_VIEW))
switchEditViewTo(MAIN_VIEW);
int res = doSaveOrNot(buf->getFullPathName()); int res = doSaveOrNot(buf->getFullPathName());
if (res == IDYES) if (res == IDYES)
{ {
if (!fileSave(id)) if (!fileSave(id))
return false; //abort entire procedure return false; //abort entire procedure
} }
else if (res == IDCANCEL) else if (res == IDCANCEL)
{ {
return false; return false;
}
} }
} }
} }
@ -623,19 +630,26 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup)
} }
else if (buf->isDirty()) else if (buf->isDirty())
{ {
activateBuffer(id, SUB_VIEW); if (isBackupMode)
switchEditViewTo(SUB_VIEW);
int res = doSaveOrNot(buf->getFullPathName());
if (res == IDYES)
{ {
if (!fileSave(id))
return false; //abort entire procedure
} }
else if (res == IDCANCEL) else
{ {
return false; activateBuffer(id, SUB_VIEW);
//otherwise continue (IDNO) switchEditViewTo(SUB_VIEW);
int res = doSaveOrNot(buf->getFullPathName());
if (res == IDYES)
{
if (!fileSave(id))
return false; //abort entire procedure
}
else if (res == IDCANCEL)
{
return false;
//otherwise continue (IDNO)
}
} }
} }
} }