From 08794510bec63bb0f4aec0c9f497f6b0f5422fd8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 23 Oct 2023 00:07:00 +0200 Subject: [PATCH] Make session inaccessible files remembered (part 2/2) Following the commit: 4248c2ae22e07a030c9dd0684de1fd38125e9dfd If the user enables the option "Remember inaccessible files from past session" (disabled by default), and an opened session (the default session "session.xml" or a user session) contains one or several inaccessible files, a message dialog will appear, giving the user the choice to open or not open the placeholders. If the user chooses to open them, empty and read-only documents will be opened as placeholders for these inaccessible files. Fix #12079, fix #12744, fix #13696, close #14252 --- PowerEditor/installer/nativeLang/english.xml | 15 +++++- .../nativeLang/english_customizable.xml | 14 +++++- PowerEditor/installer/nativeLang/french.xml | 13 ++++- .../nativeLang/taiwaneseMandarin.xml | 14 +++++- PowerEditor/src/Notepad_plus.cpp | 37 ++++++++------ PowerEditor/src/Notepad_plus.h | 2 +- PowerEditor/src/NppIO.cpp | 35 +++++++++---- PowerEditor/src/Parameters.cpp | 20 ++++++++ PowerEditor/src/Parameters.h | 17 +++++-- PowerEditor/src/ScintillaComponent/Buffer.cpp | 49 +++++++++++++++++-- PowerEditor/src/ScintillaComponent/Buffer.h | 17 ++++--- .../src/WinControls/Preference/preference.rc | 22 +++++---- .../WinControls/Preference/preferenceDlg.cpp | 8 +++ .../WinControls/Preference/preference_rc.h | 1 + 14 files changed, 213 insertions(+), 51 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 1a5b7cf32..ea416a7a8 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1167,6 +1167,7 @@ You can define several column markers by using white space to separate the diffe + @@ -1481,8 +1482,20 @@ Please test those commands and, if needed, re-edit them. Alternatively, you can downgrade to Notepad++ v8.5.2 and restore your previous data. Notepad++ will backup your old "shortcuts.xml" and save it as "shortcuts.xml.v8.5.2.backup". Renaming "shortcuts.xml.v8.5.2.backup" -> "shortcuts.xml", your commands should be restored and work properly."/> + + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 05f3ebaf0..ca8d4ae0e 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1177,6 +1177,7 @@ You can define several column markers by using white space to separate the diffe + @@ -1493,7 +1494,18 @@ Notepad++ will backup your old "shortcuts.xml" and save it as "sh Renaming "shortcuts.xml.v8.5.2.backup" -> "shortcuts.xml", your commands should be restored and work properly."/> + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 7c6754392..3412f5905 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1167,6 +1167,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour + @@ -1481,6 +1482,16 @@ Veuillez tester ces commandes et, si besoin, ré-éditer celles-ci. Autrement, vous pouvez revenir vers Notepad++ v8.5.2 et restaurer les données précédentes. Notepad++ va sauvegarder votre ancien "shortcuts.xml" et l'enregistrer sous "shortcuts.xml.v8.5.2.backup". En renommant "shortcuts.xml.v8.5.2.backup" -> "shortcuts.xml", vos commandes devraient être proprement restaurées."/> + + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 86a8bc980..2cd6cc6ad 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1,6 +1,6 @@ - +
@@ -1131,6 +1131,7 @@ + @@ -1378,6 +1379,17 @@ 繼續嗎?"/> + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c5462d699..d2808e547 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -6410,6 +6410,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { break; } + case DOC_MODIFIED: //ask for reloading { // Since it is being monitored DOC_NEEDRELOAD is going to handle the change. @@ -6446,6 +6447,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) } break; } + case DOC_NEEDRELOAD: // by log monitoring { doReload(buffer->getID(), false); @@ -6465,6 +6467,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) break; } + case DOC_DELETED: //ask for keep { prepareBufferChangedDialog(buffer); @@ -6475,21 +6478,27 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) scnN.nmhdr.idFrom = (uptr_t)buffer->getID(); _pluginsManager.notify(&scnN); - int doCloseDoc = doCloseOrNot(buffer->getFullPathName()) == IDNO; - if (doCloseDoc) + if (buffer->isInaccessible() && nppParam.isPlaceHolderEnabled()) { - //close in both views, doing current view last since that has to remain opened - bool isSnapshotMode = nppGUI.isSnapshotMode(); - doClose(buffer->getID(), otherView(), isSnapshotMode); - doClose(buffer->getID(), currentView(), isSnapshotMode); - return; + buffer->setUnsync(true); } else { - // buffer in Notepad++ is not syncronized anymore with the file on disk - buffer->setUnsync(true); + int doCloseDoc = doCloseOrNot(buffer->getFullPathName()) == IDNO; + if (doCloseDoc) + { + //close in both views, doing current view last since that has to remain opened + bool isSnapshotMode = nppGUI.isSnapshotMode(); + doClose(buffer->getID(), otherView(), isSnapshotMode); + doClose(buffer->getID(), currentView(), isSnapshotMode); + return; + } + else + { + // buffer in Notepad++ is not syncronized anymore with the file on disk + buffer->setUnsync(true); + } } - break; } } @@ -6649,14 +6658,14 @@ std::vector Notepad_plus::loadCommandlineParams(const TCHAR * co if (pCmdParams->_isSessionFile && fnss.size() == 1) { Session session2Load; - if (nppParams.loadSession(session2Load, fnss.getFileName(0))) + const wchar_t* sessionFileName = fnss.getFileName(0); + if (nppParams.loadSession(session2Load, sessionFileName)) { const bool isSnapshotMode = false; - const bool shouldLoadFileBrowser = true; if (nppGUI._multiInstSetting == multiInstOnSession) - nppParams.setLoadedSessionFilePath(fnss.getFileName(0)); - loadSession(session2Load, isSnapshotMode, shouldLoadFileBrowser); + nppParams.setLoadedSessionFilePath(sessionFileName); + loadSession(session2Load, isSnapshotMode, sessionFileName); } return std::vector(); } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 4c333c1bb..34b401dab 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -220,7 +220,7 @@ public: void macroPlayback(Macro); void loadLastSession(); - bool loadSession(Session & session, bool isSnapshotMode = false, bool shouldLoadFileBrowser = false); + bool loadSession(Session & session, bool isSnapshotMode = false, const wchar_t* userCreatedSessionName = nullptr); void prepareBufferChangedDialog(Buffer * buffer); void notifyBufferChanged(Buffer * buffer, int mask); diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index b46f3c99e..ff786d0ee 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -2104,9 +2104,13 @@ void Notepad_plus::loadLastSession() _isFolding = false; } -bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shouldLoadFileBrowser) +bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wchar_t* userCreatedSessionName) { NppParameters& nppParam = NppParameters::getInstance(); + const NppGUI& nppGUI = nppParam.getNppGUI(); + + nppParam.setTheWarningHasBeenGiven(false); + bool allSessionFilesLoaded = true; BufferID lastOpened = BUFFER_INVALID; //size_t i = 0; @@ -2145,7 +2149,9 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou } else { - lastOpened = MainFileManager.newPlaceholderDocument(pFn, MAIN_VIEW); + BufferID foundBufID = MainFileManager.getBufferFromName(pFn); + if (foundBufID == BUFFER_INVALID) + lastOpened = nppGUI._keepSessionAbsentFileEntries ? MainFileManager.newPlaceholderDocument(pFn, MAIN_VIEW, userCreatedSessionName) : BUFFER_INVALID; } if (isWow64Off) { @@ -2168,8 +2174,6 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou if (!id) // it could be due to the hidden language from the sub-menu "Languages" { - const NppGUI& nppGUI = nppParam.getNppGUI(); - for (size_t k = 0; k < nppGUI._excludedLangList.size(); ++k) // try to find it in exclude lang list { if (nppGUI._excludedLangList[k]._langName == pLn) @@ -2283,7 +2287,9 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou } else { - lastOpened = MainFileManager.newPlaceholderDocument(pFn, SUB_VIEW); + BufferID foundBufID = MainFileManager.getBufferFromName(pFn); + if (foundBufID == BUFFER_INVALID) + lastOpened = nppGUI._keepSessionAbsentFileEntries ? MainFileManager.newPlaceholderDocument(pFn, SUB_VIEW, userCreatedSessionName) : BUFFER_INVALID; } if (isWow64Off) { @@ -2396,12 +2402,24 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou if (_pDocumentListPanel) _pDocumentListPanel->reload(); - if (shouldLoadFileBrowser && !session._fileBrowserRoots.empty()) + if (userCreatedSessionName && !session._fileBrowserRoots.empty()) { - // Force launch file browser and add roots + // If the session is user's created session but not session.xml, we force to launch Folder as Workspace and add roots launchFileBrowser(session._fileBrowserRoots, session._fileBrowserSelectedItem, true); } + // Especially File status auto-detection set on "Enable for all opened files": nppGUI._fileAutoDetection & cdEnabledOld + // when "Remember inaccessible files from past session" is enabled: nppGUI._keepSessionAbsentFileEntries + // and while loading a user session: userCreatedSessionName != nullptr + // there are some (or 1) absent files: nppParam.theWarningHasBeenGiven() + // and user want to create the placeholders for these files: nppParam.isPlaceHolderEnabled() + // + // When above conditions are true, the created placeholders are not read-only, due to the lack of file-detection on them. + if (nppGUI._keepSessionAbsentFileEntries && nppParam.theWarningHasBeenGiven() && nppParam.isPlaceHolderEnabled() && userCreatedSessionName && (nppGUI._fileAutoDetection & cdEnabledOld)) + { + checkModifiedDocument(false); // so here we launch file-detection for all placeholders manually + } + return allSessionFilesLoaded; } @@ -2464,8 +2482,7 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) if (nppParam.loadSession(session2Load, sessionFileName.c_str())) { const bool isSnapshotMode = false; - const bool shouldLoadFileBrowser = true; - isAllSuccessful = loadSession(session2Load, isSnapshotMode, shouldLoadFileBrowser); + isAllSuccessful = loadSession(session2Load, isSnapshotMode, sessionFileName.c_str()); result = true; if (isEmptyNpp && nppGUI._multiInstSetting == multiInstOnSession) nppParam.setLoadedSessionFilePath(sessionFileName); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 7630424ec..45a7a5ba9 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -4871,6 +4871,21 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } } + else if (!lstrcmp(nm, TEXT("KeepSessionAbsentFileEntries"))) + { + TiXmlNode *n = childNode->FirstChild(); + if (n) + { + const TCHAR* val = n->Value(); + if (val) + { + if (lstrcmp(val, TEXT("yes")) == 0) + _nppGUI._keepSessionAbsentFileEntries = true; + else + _nppGUI._keepSessionAbsentFileEntries = false; + } + } + } else if (!lstrcmp(nm, TEXT("DetectEncoding"))) { TiXmlNode *n = childNode->FirstChild(); @@ -7038,6 +7053,11 @@ void NppParameters::createXmlTreeFromGUIParams() insertGUIConfigBoolNode(newGUIRoot, TEXT("RememberLastSession"), _nppGUI._rememberLastSession); } + // yes< / GUIConfig> + { + insertGUIConfigBoolNode(newGUIRoot, TEXT("KeepSessionAbsentFileEntries"), _nppGUI._keepSessionAbsentFileEntries); + } + // yes< / GUIConfig> { insertGUIConfigBoolNode(newGUIRoot, TEXT("DetectEncoding"), _nppGUI._detectEncoding); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 09a3e57c1..1c73721a5 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -785,6 +785,7 @@ struct NppGUI final bool _isMaximized = false; bool _isMinimizedToTray = false; bool _rememberLastSession = true; // remember next session boolean will be written in the settings + bool _keepSessionAbsentFileEntries = false; bool _isCmdlineNosessionActivated = false; // used for if -nosession is indicated on the launch time bool _detectEncoding = true; bool _saveAllConfirm = true; @@ -1942,6 +1943,9 @@ private: bool _isEndSessionStarted = false; bool _isEndSessionCritical = false; + bool _isPlaceHolderEnabled = false; + bool _theWarningHasBeenGiven = false; + public: std::wstring getWingupFullPath() const { return _wingupFullPath; }; std::wstring getWingupParams() const { return _wingupParams; }; @@ -1952,12 +1956,17 @@ public: void setWingupDir(const std::wstring& val2set) { _wingupDir = val2set; }; void setElevationRequired(bool val2set) { _isElevationRequired = val2set; }; - bool doNppLogNetworkDriveIssue() { return _doNppLogNetworkDriveIssue; }; - bool doNppLogNulContentCorruptionIssue() { return _doNppLogNulContentCorruptionIssue; }; + bool doNppLogNetworkDriveIssue() const { return _doNppLogNetworkDriveIssue; }; + bool doNppLogNulContentCorruptionIssue() const { return _doNppLogNulContentCorruptionIssue; }; void endSessionStart() { _isEndSessionStarted = true; }; - bool isEndSessionStarted() { return _isEndSessionStarted; }; + bool isEndSessionStarted() const { return _isEndSessionStarted; }; void makeEndSessionCritical() { _isEndSessionCritical = true; }; - bool isEndSessionCritical() { return _isEndSessionCritical; }; + bool isEndSessionCritical() const { return _isEndSessionCritical; }; + + void setPlaceHolderEnable(bool isEnabled) { _isPlaceHolderEnabled = isEnabled; }; + bool isPlaceHolderEnabled() const { return _isPlaceHolderEnabled; } + void setTheWarningHasBeenGiven(bool isEnabled) { _theWarningHasBeenGiven = isEnabled; }; + bool theWarningHasBeenGiven() const { return _theWarningHasBeenGiven; } private: void getLangKeywordsFromXmlTree(); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 4ca5ca0c3..266f09391 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -265,7 +265,17 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it } bool isOK = false; - if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName.c_str())) //document has been deleted + if (_currentStatus == DOC_INACCESSIBLE && !PathFileExists(_fullPathName.c_str())) //document is absent on its first load - we set readonly and not dirty, and make it be as document which has been deleted + { + _currentStatus = DOC_DELETED;//DOC_INACCESSIBLE; + _isInaccessible = true; + _isFileReadOnly = true; + _isDirty = false; + _timeStamp = {}; + doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); + isOK = true; + } + else if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName.c_str())) //document has been deleted { _currentStatus = DOC_DELETED; _isFileReadOnly = false; @@ -1347,12 +1357,45 @@ BufferID FileManager::newEmptyDocument() return id; } -BufferID FileManager::newPlaceholderDocument(const TCHAR* missingFilename, int whichOne) +BufferID FileManager::newPlaceholderDocument(const TCHAR* missingFilename, int whichOne, const wchar_t* userCreatedSessionName) { + NppParameters& nppParamInst = NppParameters::getInstance(); + + if (!nppParamInst.theWarningHasBeenGiven()) + { + int res = 0; + if (userCreatedSessionName) + { + res = (nppParamInst.getNativeLangSpeaker())->messageBox( + "FileInaccessibleUserSession", + _pNotepadPlus->_pEditView->getHSelf(), + L"Some files from your manually-saved session \"$STR_REPLACE$\" are inaccessible. They can be opened as empty and read-only documents as placeholders.\n\nWould you like to create those placeholders?\n\nNOTE: Choosing not to create the placeholders or closing them later, your manually-saved session will NOT be modified on exit.", + L"File inaccessinble", + MB_YESNO | MB_APPLMODAL, + 0, + userCreatedSessionName); + } + else + { + res = (nppParamInst.getNativeLangSpeaker())->messageBox( + "FileInaccessibleDefaultSessionXml", + _pNotepadPlus->_pEditView->getHSelf(), + L"Some files from your past session are inaccessible. They can be opened as empty and read-only documents as placeholders.\n\nWould you like to create those placeholders?\n\nNOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your \"session.xml\" now.", + L"File inaccessinble", + MB_YESNO | MB_APPLMODAL); + } + + nppParamInst.setTheWarningHasBeenGiven(true); + nppParamInst.setPlaceHolderEnable(res == IDYES); + } + + if (!nppParamInst.isPlaceHolderEnabled()) + return BUFFER_INVALID; + BufferID buf = MainFileManager.newEmptyDocument(); _pNotepadPlus->loadBufferIntoView(buf, whichOne); buf->setFileName(missingFilename); - buf->_currentStatus = DOC_REGULAR; + buf->_currentStatus = DOC_INACCESSIBLE; return buf; } diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 29ab6b384..bee4fe9e9 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -28,11 +28,12 @@ typedef Buffer* BufferID; //each buffer has unique ID by which it can be retriev typedef sptr_t Document; enum DocFileStatus { - DOC_REGULAR = 0x01, // should not be combined with anything - DOC_UNNAMED = 0x02, // not saved (new ##) - DOC_DELETED = 0x04, // doesn't exist in environment anymore, but not DOC_UNNAMED - DOC_MODIFIED = 0x08, // File in environment has changed - DOC_NEEDRELOAD = 0x10 // File is modified & needed to be reload (by log monitoring) + DOC_REGULAR = 0x01, // should not be combined with anything + DOC_UNNAMED = 0x02, // not saved (new ##) + DOC_DELETED = 0x04, // doesn't exist in environment anymore, but not DOC_UNNAMED + DOC_MODIFIED = 0x08, // File in environment has changed + DOC_NEEDRELOAD = 0x10, // File is modified & needed to be reload (by log monitoring) + DOC_INACCESSIBLE = 0x20 // File is absent on its load; this status is temporay for setting file not dirty & readonly; and it will be replaced to DOC_DELETED }; enum BufferStatusInfo { @@ -89,7 +90,7 @@ public: BufferID loadFile(const TCHAR * filename, Document doc = static_cast(NULL), int encoding = -1, const TCHAR *backupFileName = nullptr, FILETIME fileNameTimestamp = {}); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document BufferID newEmptyDocument(); // create an empty placeholder for a missing file when loading session - BufferID newPlaceholderDocument(const TCHAR * missingFilename, int whichOne); + BufferID newPlaceholderDocument(const TCHAR * missingFilename, int whichOne, const wchar_t* userCreatedSessionName); //create Buffer from existing Scintilla, used from new Scintillas. BufferID bufferFromDocument(Document doc, bool isMainEditZone); @@ -185,6 +186,8 @@ public: bool isUntitled() const { return ((_currentStatus & DOC_UNNAMED) == DOC_UNNAMED); } + bool isInaccessible() const { return _isInaccessible; } + bool getFileReadOnly() const { return _isFileReadOnly; } void setFileReadOnly(bool ro) { @@ -414,4 +417,6 @@ private: MapPosition _mapPosition; std::mutex _reloadFromDiskRequestGuard; + + bool _isInaccessible = false; }; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 119d490b7..b71e2e70c 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -371,23 +371,25 @@ IDD_PREFERENCE_SUB_BACKUP DIALOGEX 115, 10, 460, 205 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_GRP_STATIC,79,1,289,75,BS_CENTER + GROUPBOX "Session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_GRP_STATIC,79,1,289,98,BS_CENTER CONTROL "Remember current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,10,270,10 CONTROL "Enable session snapshot and periodic backup",IDC_BACKUPDIR_RESTORESESSION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,25,270,10 EDITTEXT IDC_BACKUPDIR_RESTORESESSION_EDIT,164,40,21,14,ES_NUMBER RTEXT "Backup in every",IDD_BACKUPDIR_RESTORESESSION_STATIC1,82,42,78,8 LTEXT "seconds",IDD_BACKUPDIR_RESTORESESSION_STATIC2,190,42,66,8 - GROUPBOX "Backup on save",IDC_BACKUPDIR_GRP_STATIC,79,81,289,101,BS_CENTER - CONTROL "None",IDC_RADIO_BKNONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,104,90,87,10 - CONTROL "Simple backup",IDC_RADIO_BKSIMPLE,"Button",BS_AUTORADIOBUTTON,104,104,111,10 - CONTROL "Verbose backup",IDC_RADIO_BKVERBOSE,"Button",BS_AUTORADIOBUTTON,104,117,111,10 - GROUPBOX "Custom Backup Directory",IDC_BACKUPDIR_USERCUSTOMDIR_GRPSTATIC,95,135,260,40 - CONTROL "",IDC_BACKUPDIR_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,91,135,8,10 - RTEXT "Directory :",IDD_BACKUPDIR_STATIC,99,152,40,8 - EDITTEXT IDC_BACKUPDIR_EDIT,146,150,179,14,ES_AUTOHSCROLL - PUSHBUTTON "...",IDD_BACKUPDIR_BROWSE_BUTTON,332,150,16,14 RTEXT "Backup path:",IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC,85,60,61,8 + CONTROL "Remember inaccessible files from past session",IDC_CHECK_KEEPABSENTFILESINSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,87,270,10 + EDITTEXT IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT,153,58,208,14,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Backup on save",IDC_BACKUPDIR_GRP_STATIC,79,102,289,101,BS_CENTER + CONTROL "None",IDC_RADIO_BKNONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,104,111,87,10 + CONTROL "Simple backup",IDC_RADIO_BKSIMPLE,"Button",BS_AUTORADIOBUTTON,104,125,111,10 + CONTROL "Verbose backup",IDC_RADIO_BKVERBOSE,"Button",BS_AUTORADIOBUTTON,104,138,111,10 + GROUPBOX "Custom Backup Directory",IDC_BACKUPDIR_USERCUSTOMDIR_GRPSTATIC,95,156,260,40 + CONTROL "",IDC_BACKUPDIR_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,156,8,10 + RTEXT "Directory :",IDD_BACKUPDIR_STATIC,99,173,40,8 + EDITTEXT IDC_BACKUPDIR_EDIT,146,171,179,14,ES_AUTOHSCROLL + PUSHBUTTON "...",IDD_BACKUPDIR_BROWSE_BUTTON,332,171,16,14 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index a3ede00de..9a0b17c20 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -3939,6 +3939,7 @@ intptr_t CALLBACK BackupSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM generic_string backupFilePath = NppParameters::getInstance().getUserPath(); backupFilePath += TEXT("\\backup\\"); ::SetDlgItemText(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT, backupFilePath.c_str()); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_KEEPABSENTFILESINSESSION, BM_SETCHECK, nppGUI._keepSessionAbsentFileEntries, 0); int ID2CheckBackupOnSave = 0; @@ -4082,6 +4083,13 @@ intptr_t CALLBACK BackupSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM updateBackupSessionGUI(); return TRUE; } + + case IDC_CHECK_KEEPABSENTFILESINSESSION: + { + nppGUI._keepSessionAbsentFileEntries = isCheckedOrNot(IDC_CHECK_KEEPABSENTFILESINSESSION); + return TRUE; + } + case IDC_BACKUPDIR_RESTORESESSION_CHECK: { nppGUI._isSnapshotMode = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_GETCHECK, 0, 0); diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 4bd4cb3aa..0e04e3201 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -400,6 +400,7 @@ #define IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC (IDD_PREFERENCE_SUB_BACKUP + 22) #define IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT (IDD_PREFERENCE_SUB_BACKUP + 23) #define IDD_AUTOC_IGNORENUMBERS (IDD_PREFERENCE_SUB_BACKUP + 24) + #define IDC_CHECK_KEEPABSENTFILESINSESSION (IDD_PREFERENCE_SUB_BACKUP + 25) #define IDD_PREFERENCE_SUB_AUTOCOMPLETION 6850 //(IDD_PREFERENCE_BOX + 850) #define IDD_AUTOCINSERT_GRPSTATIC (IDD_PREFERENCE_SUB_AUTOCOMPLETION + 1)