Make session inaccessible files remembered (part 2/2)

Following the commit: 4248c2ae22

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
This commit is contained in:
Don Ho 2023-10-23 00:07:00 +02:00
parent 4248c2ae22
commit 08794510be
14 changed files with 213 additions and 51 deletions

View File

@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="English" filename="english.xml" version="8.5.5">
<Native-Langue name="English" filename="english.xml" version="8.5.9">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1167,6 +1167,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6821" name="seconds"/>
<Item id="6822" name="Backup path:"/>
<Item id="6309" name="Remember current session for next launch"/>
<Item id="6825" name="Remember inaccessible files from past session"/>
<Item id="6801" name="Backup on save"/>
<Item id="6315" name="None"/>
<Item id="6316" name="Simple backup"/>
@ -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 &quot;shortcuts.xml&quot; and save it as &quot;shortcuts.xml.v8.5.2.backup&quot;.
Renaming &quot;shortcuts.xml.v8.5.2.backup&quot; -&gt; &quot;shortcuts.xml&quot;, your commands should be restored and work properly."/><!-- HowToReproduce: Close Notepad++, remove shortcuts.xml.v8.5.2.backup & v852ShortcutsCompatibilityWarning.xml if present, relaunch Notepad++, delete or modify a shortcuts via Shortcut Mapper, close Notepad++, then the message will show up -->
<NbFileToOpenImportantWarning title="Amount of files to open is too large" message="$INT_REPLACE$ files are about to be opened.
Are you sure you want to open them?"/>
<NotEnoughRoom4Saving title="Save failed" message="Failed to save file.
It seems there's not enough space on disk to save file. Your file is not saved."/>
<FileInaccessibleUserSession title="File inaccessible" message="Some files from your manually-saved session &quot;$STR_REPLACE$&quot; are inaccessible. They can be opened as empty and read-only documents as placeholders.
Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your manually-saved session will NOT be modified on exit."/>
<FileInaccessibleDefaultSessionXml title="File inaccessible" message="Some files from your past session are inaccessible. They can be opened as empty and read-only documents as placeholders.
Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your &quot;session.xml&quot; now."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>

View File

@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="English" filename="english_customizable.xml" version="8.5.5">
<Native-Langue name="English" filename="english_customizable.xml" version="8.5.9">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1177,6 +1177,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6821" name="seconds"/>
<Item id="6822" name="Backup path:"/>
<Item id="6309" name="Remember current session for next launch"/>
<Item id="6825" name="Remember inaccessible files from past session"/>
<Item id="6801" name="Backup on save"/>
<Item id="6315" name="None"/>
<Item id="6316" name="Simple backup"/>
@ -1493,7 +1494,18 @@ Notepad++ will backup your old &quot;shortcuts.xml&quot; and save it as &quot;sh
Renaming &quot;shortcuts.xml.v8.5.2.backup&quot; -&gt; &quot;shortcuts.xml&quot;, your commands should be restored and work properly."/><!-- HowToReproduce: Close Notepad++, remove shortcuts.xml.v8.5.2.backup & v852ShortcutsCompatibilityWarning.xml if present, relaunch Notepad++, delete or modify a shortcuts via Shortcut Mapper, close Notepad++, then the message will show up -->
<NotEnoughRoom4Saving title="Save failed" message="Failed to save file.
It seems there's not enough space on disk to save file. Your file is not saved."/>
<NbFileToOpenImportantWarning title="Amount of files to open is too large" message="$INT_REPLACE$ files are about to be opened.
Are you sure you want to open them?"/>
<FileInaccessibleUserSession title="File inaccessible" message="Some files from your manually-saved session &quot;$STR_REPLACE$&quot; are inaccessible. They can be opened as empty and read-only documents as placeholders.
Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your manually-saved session will NOT be modified on exit."/>
<FileInaccessibleDefaultSessionXml title="File inaccessible" message="Some files from your past session are inaccessible. They can be opened as empty and read-only documents as placeholders.
Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your &quot;session.xml&quot; now."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>

View File

@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="français" filename="french.xml" version="8.5.5">
<Native-Langue name="français" filename="french.xml" version="8.5.9">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1167,6 +1167,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour
<Item id="6821" name="secondes"/>
<Item id="6822" name="dans le dossier"/>
<Item id="6309" name="Mémoriser la session actuelle"/>
<Item id="6825" name="Mémoriser les fichiers inaccessibles de la session précédente"/>
<Item id="6801" name="Sauvegarde"/>
<Item id="6315" name="Aucune"/>
<Item id="6316" name="Simple"/>
@ -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 &quot;shortcuts.xml&quot; et l'enregistrer sous &quot;shortcuts.xml.v8.5.2.backup&quot;.
En renommant &quot;shortcuts.xml.v8.5.2.backup&quot; -&gt; &quot;shortcuts.xml&quot;, vos commandes devraient être proprement restaurées."/><!-- HowToReproduce: Close Notepad++, remove shortcuts.xml.v8.5.2.backup & v852ShortcutsCompatibilityWarning.xml if present, relaunch Notepad++, delete or modify a shortcuts via Shortcut Mapper, close Notepad++, then the message will show up -->
<FileInaccessibleUserSession title="Fichier inaccessible" message="Certains fichiers de votre session sauvegardée manuellement &quot;$STR_REPLACE$&quot; sont inaccessibles. Ils peuvent être ouverts comme des documents vides et en lecture seule en tant qu'espaces réservés.
Voulez-vous créer des espaces réservés pour eux ?
Notez que si vous choisissez de ne pas créer d'espaces réservés ou de les fermer plus tard, votre session sauvegardée manuellement ne sera PAS modifiée à la sortie."/>
<FileInaccessibleDefaultSessionXml title="Fichier inaccessible" message="Certains fichiers de votre session précédente sont inaccessibles. Ils peuvent être ouverts comme des documents vides et en lecture seule en tant qu'espaces réservés.
Voulez-vous créer des espaces réservés pour eux ?
Notez que si vous choisissez de ne pas créer d'espaces réservés ou de les fermer plus tard, votre fichier de session sera modifié à la sortie. Nous vous suggérons de faire une sauvegarde du fichier de session &quot;session.xml&quot; maintenant."/>
<NotEnoughRoom4Saving title="Échec de l'enregistrement" message="Échec de l'enregistrement du fichier.
Il semblerait qu'il n'y a pas assez d'espace disque pour enregistrer le fichier. Votre fichier n'est pas enregistré."/>
</MessageBox>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<NotepadPlus>
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.5.5">
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.5.9">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1131,6 +1131,7 @@
<Item id="6821" name="秒備份一次"/>
<Item id="6822" name="備份資料夾:"/>
<Item id="6309" name="開啟程式時繼續上次的工作階段"/>
<Item id="6825" name="保存上次的工作階段中無法讀取的文件"/>
<Item id="6801" name="備份"/>
<Item id="6315" name="無"/>
<Item id="6316" name="簡易備份"/>
@ -1378,6 +1379,17 @@
繼續嗎?"/>
<NeedToRestartToLoadPlugins title="重新啟動 Notepad++" message="你必須重新啟動 Notepad++ 才能載入已安裝的外掛模組。"/>
<ChangeHistoryEnabledWarning title="重新啟動 Notepad++" message="你必須重新啟動 Notepad++ 才能啟動文件修改紀錄。"/>
<FileInaccessibleUserSession title="檔案不存在" message="儲存的工作階段 &quot;$STR_REPLACE$&quot;
你想為它們創建佔位欄嗎?
請注意,如果你選擇不創建佔位欄或稍後關閉它們,工作階段檔案將不會在 Notepad++ 關閉時被修改。
"/>
<FileInaccessibleDefaultSessionXml title="檔案不存在" message="過去的工作階段中有一些已不存在的檔案。它們可以以空白唯讀文件的形式作為佔位欄而創建。
你想為它們創建佔位欄嗎?
請注意,如果你選擇不創建佔位欄或稍後關閉它們,工作階段檔案將在 Notepad++ 關閉時被修改。我們建議你現在備份工作階段檔案 &quot;session.xml&quot; 。"/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="剪貼簿記錄"/>

View File

@ -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<generic_string> 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<generic_string>();
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
// <GUIConfig name = "RememberLastSession">yes< / GUIConfig>
{
insertGUIConfigBoolNode(newGUIRoot, TEXT("KeepSessionAbsentFileEntries"), _nppGUI._keepSessionAbsentFileEntries);
}
// <GUIConfig name = "DetectEncoding">yes< / GUIConfig>
{
insertGUIConfigBoolNode(newGUIRoot, TEXT("DetectEncoding"), _nppGUI._detectEncoding);

View File

@ -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();

View File

@ -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;
}

View File

@ -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<Document>(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;
};

View File

@ -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

View File

@ -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);

View File

@ -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)