Add "Open Containing Folder as Workspace" command

and add this command in context menu of tabs.

Close #3028, close #8880
This commit is contained in:
Don HO 2020-09-22 00:32:12 +02:00
parent b0b119411b
commit 320aca73be
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
9 changed files with 97 additions and 63 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus> <NotepadPlus>
<Native-Langue name="English" filename="english.xml" version="7.9"> <Native-Langue name="English" filename="english.xml" version="7.9.1">
<Menu> <Menu>
<Main> <Main>
<!-- Main Menu Entries --> <!-- Main Menu Entries -->
@ -75,6 +75,7 @@
<Item id="41002" name="&amp;Open"/> <Item id="41002" name="&amp;Open"/>
<Item id="41019" name="Explorer"/> <Item id="41019" name="Explorer"/>
<Item id="41020" name="cmd"/> <Item id="41020" name="cmd"/>
<Item id="41025" name="Folder as Workspace"/>
<Item id="41003" name="&amp;Close"/> <Item id="41003" name="&amp;Close"/>
<Item id="41004" name="Clos&amp;e All"/> <Item id="41004" name="Clos&amp;e All"/>
<Item id="41005" name="Close All BUT Current Document"/> <Item id="41005" name="Close All BUT Current Document"/>
@ -355,6 +356,7 @@
<Item CMID="20" name="Open Containing Folder in cmd"/> <Item CMID="20" name="Open Containing Folder in cmd"/>
<Item CMID="21" name="Open in Default Viewer"/> <Item CMID="21" name="Open in Default Viewer"/>
<Item CMID="22" name="Close All Unchanged"/> <Item CMID="22" name="Close All Unchanged"/>
<Item CMID="23" name="Open Containing Folder as Workspace"/>
</TabBar> </TabBar>
</Menu> </Menu>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus> <NotepadPlus>
<Native-Langue name="English" filename="english_customizable.xml" version="7.8.7"> <Native-Langue name="English" filename="english_customizable.xml" version="7.9.1">
<Menu> <Menu>
<Main> <Main>
<!-- Main Menu Entries --> <!-- Main Menu Entries -->
@ -75,6 +75,7 @@
<Item id="41002" name="&amp;Open"/> <Item id="41002" name="&amp;Open"/>
<Item id="41019" name="Explorer"/> <Item id="41019" name="Explorer"/>
<Item id="41020" name="cmd"/> <Item id="41020" name="cmd"/>
<Item id="41025" name="Folder as Workspace"/>
<Item id="41003" name="&amp;Close"/> <Item id="41003" name="&amp;Close"/>
<Item id="41004" name="Clos&amp;e All"/> <Item id="41004" name="Clos&amp;e All"/>
<Item id="41005" name="Close All BUT Current Document"/> <Item id="41005" name="Close All BUT Current Document"/>
@ -320,8 +321,6 @@
<Item id="50000" name="Function Completion"/> <Item id="50000" name="Function Completion"/>
<Item id="50001" name="Word Completion"/> <Item id="50001" name="Word Completion"/>
<Item id="50002" name="Function Parameters Hint"/> <Item id="50002" name="Function Parameters Hint"/>
<Item id="50003" name="Switch to previous document"/>
<Item id="50004" name="Switch to next document"/>
<Item id="50005" name="Toggle macro record"/> <Item id="50005" name="Toggle macro record"/>
<Item id="50006" name="Path Completion"/> <Item id="50006" name="Path Completion"/>
<Item id="44042" name="Hide Lines"/> <Item id="44042" name="Hide Lines"/>
@ -357,6 +356,7 @@
<Item CMID="20" name="Open Containing Folder in cmd"/> <Item CMID="20" name="Open Containing Folder in cmd"/>
<Item CMID="21" name="Open in Default Viewer"/> <Item CMID="21" name="Open in Default Viewer"/>
<Item CMID="22" name="Close All Unchanged"/> <Item CMID="22" name="Close All Unchanged"/>
<Item CMID="23" name="Open Containing Folder as Workspace"/>
</TabBar> </TabBar>
</Menu> </Menu>
@ -535,13 +535,13 @@
<Item id="43035" name="Previous mark using 3rd style"/> <Item id="43035" name="Previous mark using 3rd style"/>
<Item id="43036" name="Previous mark using 4th style"/> <Item id="43036" name="Previous mark using 4th style"/>
<Item id="43037" name="Previous mark using 5th style"/> <Item id="43037" name="Previous mark using 5th style"/>
<Item id="43038" name="Previous mark created with Mark..."/> <Item id="43038" name="Previous mark created with Mark"/>
<Item id="43039" name="Next mark using 1st style"/> <Item id="43039" name="Next mark using 1st style"/>
<Item id="43040" name="Next mark using 2nd style"/> <Item id="43040" name="Next mark using 2nd style"/>
<Item id="43041" name="Next mark using 3rd style"/> <Item id="43041" name="Next mark using 3rd style"/>
<Item id="43042" name="Next mark using 4th style"/> <Item id="43042" name="Next mark using 4th style"/>
<Item id="43043" name="Next mark using 5th style"/> <Item id="43043" name="Next mark using 5th style"/>
<Item id="43044" name="Next mark created with Mark..."/> <Item id="43044" name="Next mark created with Mark"/>
<Item id="44100" name="View current file in Firefox"/> <Item id="44100" name="View current file in Firefox"/>
<Item id="44101" name="View current file in Chrome"/> <Item id="44101" name="View current file in Chrome"/>
<Item id="44103" name="View current file in IE"/> <Item id="44103" name="View current file in IE"/>
@ -912,6 +912,8 @@ You can define several column markers by using white space to separate the diffe
<Searching title="Searching"> <Searching title="Searching">
<Item id="6901" name="Don't fill find field in Find dialog with selected word"/> <Item id="6901" name="Don't fill find field in Find dialog with selected word"/>
<Item id="6902" name="Use monospaced font in Find dialog (Need to restart Notepad++)"/> <Item id="6902" name="Use monospaced font in Find dialog (Need to restart Notepad++)"/>
<Item id="6903" name="Find dialog remains open after search that outputs to results window"/>
<Item id="6904" name="Confirm Replace All in All Opened Documents"/>
</Searching> </Searching>
<RecentFilesHistory title="Recent Files History"> <RecentFilesHistory title="Recent Files History">
@ -1016,6 +1018,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6331" name="Show only filename in title bar"/> <Item id="6331" name="Show only filename in title bar"/>
<Item id="6334" name="Autodetect character encoding"/> <Item id="6334" name="Autodetect character encoding"/>
<Item id="6349" name="Use DirectWrite (May improve rendering special characters, need to restart Notepad++)"/> <Item id="6349" name="Use DirectWrite (May improve rendering special characters, need to restart Notepad++)"/>
<Item id="6350" name="Enable fullbox mode"/>
<Item id="6337" name="Workspace file ext.:"/> <Item id="6337" name="Workspace file ext.:"/>
<Item id="6114" name="Enable"/> <Item id="6114" name="Enable"/>
<Item id="6117" name="Enable MRU behaviour"/> <Item id="6117" name="Enable MRU behaviour"/>
@ -1317,6 +1320,7 @@ Find in all files except exe, obj &amp;&amp; log:
<finder-select-all value="Select all"/> <finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/> <finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/> <finder-open-all value="Open all"/>
<finder-wrap-long-lines value="Word wrap long lines"/>
<common-ok value="OK"/> <common-ok value="OK"/>
<common-cancel value="Cancel"/> <common-cancel value="Cancel"/>
<common-name value="Name: "/> <common-name value="Name: "/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus> <NotepadPlus>
<Native-Langue name="Français" filename="french.xml" version="7.9"> <Native-Langue name="Français" filename="french.xml" version="7.9.1">
<Menu> <Menu>
<Main> <Main>
<!-- Main Menu Entries --> <!-- Main Menu Entries -->
@ -80,6 +80,7 @@
<Item id="41002" name="&amp;Ouvrir..."/> <Item id="41002" name="&amp;Ouvrir..."/>
<Item id="41019" name="Explorateur Windows"/> <Item id="41019" name="Explorateur Windows"/>
<Item id="41020" name="Invite de commande (cmd)"/> <Item id="41020" name="Invite de commande (cmd)"/>
<Item id="41025" name="Dossier en tant qu'espace de travail"/>
<Item id="41003" name="Fermer"/> <Item id="41003" name="Fermer"/>
<Item id="41004" name="Fermer tout"/> <Item id="41004" name="Fermer tout"/>
<Item id="41005" name="Fermer tout sauf le document actuel"/> <Item id="41005" name="Fermer tout sauf le document actuel"/>
@ -352,6 +353,7 @@
<Item CMID="20" name="Ouvrir le répertoire du fichier en cours dans l'invite de commande"/> <Item CMID="20" name="Ouvrir le répertoire du fichier en cours dans l'invite de commande"/>
<Item CMID="21" name="Ouvrir dans l'application par défaut"/> <Item CMID="21" name="Ouvrir dans l'application par défaut"/>
<Item CMID="22" name="Fermer tous les documents non-modifiés"/> <Item CMID="22" name="Fermer tous les documents non-modifiés"/>
<Item CMID="23" name="Ouvrir le répertoire du fichier en cours en tant qu'espace de travail"/>
</TabBar> </TabBar>
</Menu> </Menu>
<Dialog> <Dialog>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<NotepadPlus> <NotepadPlus>
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="7.9"> <Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="7.9.1">
<Menu> <Menu>
<Main> <Main>
<!-- Main Menu Entries --> <!-- Main Menu Entries -->
@ -75,6 +75,7 @@
<Item id="41002" name="開啟舊檔(&amp;O)..."/> <Item id="41002" name="開啟舊檔(&amp;O)..."/>
<Item id="41019" name="在檔案總管內"/> <Item id="41019" name="在檔案總管內"/>
<Item id="41020" name="在 CMD 內"/> <Item id="41020" name="在 CMD 內"/>
<Item id="41025" name="在資料夾工作區內"/>
<Item id="41003" name="關閉此檔案"/> <Item id="41003" name="關閉此檔案"/>
<Item id="41004" name="關閉所有檔案"/> <Item id="41004" name="關閉所有檔案"/>
<Item id="41005" name="除此檔案外,關閉所有檔案"/> <Item id="41005" name="除此檔案外,關閉所有檔案"/>
@ -351,6 +352,7 @@
<Item CMID="20" name="於 CMD 開啟檔案位置"/> <Item CMID="20" name="於 CMD 開啟檔案位置"/>
<Item CMID="21" name="在電腦預設顯示器中開啟"/> <Item CMID="21" name="在電腦預設顯示器中開啟"/>
<Item CMID="22" name="關閉所有已存檔未變更的檔案"/> <Item CMID="22" name="關閉所有已存檔未變更的檔案"/>
<Item CMID="23" name="在資料夾工作區開啟檔案位置如同根目錄"/>
</TabBar> </TabBar>
</Menu> </Menu>
<Dialog> <Dialog>

View File

@ -237,6 +237,8 @@ BEGIN
BEGIN BEGIN
MENUITEM "Explorer", IDM_FILE_OPEN_FOLDER MENUITEM "Explorer", IDM_FILE_OPEN_FOLDER
MENUITEM "cmd", IDM_FILE_OPEN_CMD MENUITEM "cmd", IDM_FILE_OPEN_CMD
MENUITEM SEPARATOR
MENUITEM "Folder as Workspace", IDM_FILE_CONTAININGFOLDERASWORKSPACE
END END
MENUITEM "Open in Default Viewer", IDM_FILE_OPEN_DEFAULT_VIEWER MENUITEM "Open in Default Viewer", IDM_FILE_OPEN_DEFAULT_VIEWER
MENUITEM "Open Folder as Workspace...", IDM_FILE_OPENFOLDERASWORSPACE MENUITEM "Open Folder as Workspace...", IDM_FILE_OPENFOLDERASWORSPACE

View File

@ -95,6 +95,25 @@ void Notepad_plus::command(int id)
} }
break; break;
case IDM_FILE_CONTAININGFOLDERASWORKSPACE:
{
TCHAR currentFile[CURRENTWORD_MAXLENGTH];
TCHAR currentDir[CURRENTWORD_MAXLENGTH];
::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETFULLCURRENTPATH, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(currentFile));
::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETCURRENTDIRECTORY, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(currentDir));
if (!_pFileBrowser)
{
command(IDM_VIEW_FILEBROWSER);
}
vector<generic_string> folders;
folders.push_back(currentDir);
launchFileBrowser(folders, currentFile);
}
break;
case IDM_FILE_OPEN_DEFAULT_VIEWER: case IDM_FILE_OPEN_DEFAULT_VIEWER:
{ {
// Opens file in its default viewer. // Opens file in its default viewer.
@ -126,7 +145,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_OPENFOLDERASWORSPACE: case IDM_FILE_OPENFOLDERASWORSPACE:
{ {
generic_string folderPath = folderBrowser(_pPublicInterface->getHSelf(), TEXT("Select a folder to add in Folder as Workspace panel")); generic_string folderPath = folderBrowser(_pPublicInterface->getHSelf(), TEXT("Select a folder to add in Folder as Workspace panel"));
if (not folderPath.empty()) if (!folderPath.empty())
{ {
if (_pFileBrowser == nullptr) // first launch, check in params to open folders if (_pFileBrowser == nullptr) // first launch, check in params to open folders
{ {
@ -424,7 +443,7 @@ void Notepad_plus::command(int id)
fullFilePath += TEXT("\""); fullFilePath += TEXT("\"");
if (id == IDM_EDIT_OPENINFOLDER || if (id == IDM_EDIT_OPENINFOLDER ||
(id == IDM_EDIT_OPENASFILE && not ::PathIsDirectory(curentWord))) (id == IDM_EDIT_OPENASFILE && !::PathIsDirectory(curentWord)))
::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW); ::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW);
} }
else // Full file path - need concatenate with current full file path else // Full file path - need concatenate with current full file path
@ -439,7 +458,7 @@ void Notepad_plus::command(int id)
fullFilePath += curentWord; fullFilePath += curentWord;
if ((id == IDM_EDIT_OPENASFILE && if ((id == IDM_EDIT_OPENASFILE &&
(not::PathFileExists(fullFilePath.c_str() + 1) || ::PathIsDirectory(fullFilePath.c_str() + 1)))) (!::PathFileExists(fullFilePath.c_str() + 1) || ::PathIsDirectory(fullFilePath.c_str() + 1))))
{ {
_nativeLangSpeaker.messageBox("FilePathNotFoundWarning", _nativeLangSpeaker.messageBox("FilePathNotFoundWarning",
_pPublicInterface->getHSelf(), _pPublicInterface->getHSelf(),
@ -700,7 +719,7 @@ void Notepad_plus::command(int id)
} }
else else
{ {
if (not (*pp[idx])->isClosed()) if (!(*pp[idx])->isClosed())
{ {
if ((*pp[idx])->checkIfNeedSave()) if ((*pp[idx])->checkIfNeedSave())
{ {
@ -769,7 +788,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_DOC_MAP: case IDM_VIEW_DOC_MAP:
{ {
if (_pDocMap && (not _pDocMap->isClosed())) if (_pDocMap && (!_pDocMap->isClosed()))
{ {
_pDocMap->display(false); _pDocMap->display(false);
_pDocMap->vzDlgDisplay(false); _pDocMap->vzDlgDisplay(false);
@ -2252,7 +2271,7 @@ void Notepad_plus::command(int id)
Buffer* buf = _pEditView->getCurrentBuffer(); Buffer* buf = _pEditView->getCurrentBuffer();
if (not buf->isReadOnly()) if (!buf->isReadOnly())
{ {
std::lock_guard<std::mutex> lock(command_mutex); std::lock_guard<std::mutex> lock(command_mutex);
buf->setEolFormat(newFormat); buf->setEolFormat(newFormat);
@ -2440,7 +2459,7 @@ void Notepad_plus::command(int id)
return; return;
} }
if (not buf->isDirty()) if (!buf->isDirty())
{ {
buf->setEncoding(encoding); buf->setEncoding(encoding);
buf->setUnicodeMode(uniCookie); buf->setUnicodeMode(uniCookie);
@ -3310,7 +3329,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_RESTORELASTCLOSEDFILE: case IDM_FILE_RESTORELASTCLOSEDFILE:
{ {
generic_string lastOpenedFullPath = _lastRecentFileList.getFirstItem(); generic_string lastOpenedFullPath = _lastRecentFileList.getFirstItem();
if (not lastOpenedFullPath.empty()) if (!lastOpenedFullPath.empty())
{ {
BufferID lastOpened = doOpen(lastOpenedFullPath); BufferID lastOpened = doOpen(lastOpenedFullPath);
if (lastOpened != BUFFER_INVALID) if (lastOpened != BUFFER_INVALID)

View File

@ -531,6 +531,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
itemUnitArray.push_back(MenuItemUnit(0, NULL)); itemUnitArray.push_back(MenuItemUnit(0, NULL));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_FOLDER, TEXT("Open Containing Folder in Explorer"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_FOLDER, TEXT("Open Containing Folder in Explorer")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_CMD, TEXT("Open Containing Folder in cmd"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_CMD, TEXT("Open Containing Folder in cmd")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CONTAININGFOLDERASWORKSPACE, TEXT("Open Containing Folder as Workspace")));
itemUnitArray.push_back(MenuItemUnit(0, NULL)); itemUnitArray.push_back(MenuItemUnit(0, NULL));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_DEFAULT_VIEWER, TEXT("Open in Default Viewer"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_DEFAULT_VIEWER, TEXT("Open in Default Viewer")));
itemUnitArray.push_back(MenuItemUnit(0, NULL)); itemUnitArray.push_back(MenuItemUnit(0, NULL));

View File

@ -411,24 +411,25 @@ static const int tabContextMenuItemPos[] =
5, // 2: Save 5, // 2: Save
6, // 3: Save As 6, // 3: Save As
10, // 4: Print 10, // 4: Print
24, // 5 : Move to Other View 25, // 5: Move to Other View
25, // 6 : Clone to Other View 26, // 6: Clone to Other View
20, // 7 : Full File Path to Clipboard 21, // 7: Full File Path to Clipboard
21, // 8 : Filename to Clipboard 22, // 8: Filename to Clipboard
22, // 9 : Current Dir. Path to Clipboard 23, // 9: Current Dir. Path to Clipboard
7, // 10: Rename 7, // 10: Rename
8, // 11: Move to Recycle Bin 8, // 11: Move to Recycle Bin
17, // 12: Read-Only 18, // 12: Read-Only
18, // 13: Clear Read-Only Flag 19, // 13: Clear Read-Only Flag
26, // 14: Move to New Instance 27, // 14: Move to New Instance
27, // 15: Open to New Instance 28, // 15: Open to New Instance
9, // 16: Reload 9, // 16: Reload
2, // 17: Close ALL to the Left 2, // 17: Close ALL to the Left
3, // 18: Close ALL to the Right 3, // 18: Close ALL to the Right
12, // 19: Open Containing Folder in Explorer 12, // 19: Open Containing Folder in Explorer
13, // 20: Open Containing Folder in cmd 13, // 20: Open Containing Folder in cmd
15, // 21: Open in Default Viewer 16, // 21: Open in Default Viewer
4, // 22: Close ALL Unchanged 4, // 22: Close ALL Unchanged
14, // 23: Open Containing Folder as Workspace
-1 //-------End -1 //-------End
}; };

View File

@ -57,10 +57,11 @@
#define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22) #define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22)
#define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23) #define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23)
#define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24) #define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24)
#define IDM_FILE_CONTAININGFOLDERASWORKSPACE (IDM_FILE + 25)
// IMPORTANT: If list above is modified, you have to change the following values: // IMPORTANT: If list above is modified, you have to change the following values:
// To be updated if new menu item(s) is (are) added in menu "File" // To be updated if new menu item(s) is (are) added in menu "File"
#define IDM_FILEMENU_LASTONE IDM_FILE_CLOSEALL_UNCHANGED #define IDM_FILEMENU_LASTONE IDM_FILE_CONTAININGFOLDERASWORKSPACE
// 0 based position of command "Exit" including the bars in the file menu // 0 based position of command "Exit" including the bars in the file menu
// and without counting "Recent files history" items // and without counting "Recent files history" items