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

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<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>
<Main>
<!-- Main Menu Entries -->
@ -75,6 +75,7 @@
<Item id="41002" name="&amp;Open"/>
<Item id="41019" name="Explorer"/>
<Item id="41020" name="cmd"/>
<Item id="41025" name="Folder as Workspace"/>
<Item id="41003" name="&amp;Close"/>
<Item id="41004" name="Clos&amp;e All"/>
<Item id="41005" name="Close All BUT Current Document"/>
@ -320,8 +321,6 @@
<Item id="50000" name="Function Completion"/>
<Item id="50001" name="Word Completion"/>
<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="50006" name="Path Completion"/>
<Item id="44042" name="Hide Lines"/>
@ -357,6 +356,7 @@
<Item CMID="20" name="Open Containing Folder in cmd"/>
<Item CMID="21" name="Open in Default Viewer"/>
<Item CMID="22" name="Close All Unchanged"/>
<Item CMID="23" name="Open Containing Folder as Workspace"/>
</TabBar>
</Menu>
@ -535,13 +535,13 @@
<Item id="43035" name="Previous mark using 3rd style"/>
<Item id="43036" name="Previous mark using 4th 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="43040" name="Next mark using 2nd style"/>
<Item id="43041" name="Next mark using 3rd style"/>
<Item id="43042" name="Next mark using 4th 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="44101" name="View current file in Chrome"/>
<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">
<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="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>
<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="6334" name="Autodetect character encoding"/>
<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="6114" name="Enable"/>
<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-clear-all value="Clear all"/>
<finder-open-all value="Open all"/>
<finder-wrap-long-lines value="Word wrap long lines"/>
<common-ok value="OK"/>
<common-cancel value="Cancel"/>
<common-name value="Name: "/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<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>
<Main>
<!-- Main Menu Entries -->
@ -80,6 +80,7 @@
<Item id="41002" name="&amp;Ouvrir..."/>
<Item id="41019" name="Explorateur Windows"/>
<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="41004" name="Fermer tout"/>
<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="21" name="Ouvrir dans l'application par défaut"/>
<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>
</Menu>
<Dialog>

View File

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

View File

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

View File

@ -94,7 +94,26 @@ void Notepad_plus::command(int id)
cmd.run(_pPublicInterface->getHSelf(), TEXT("$(CURRENT_DIRECTORY)"));
}
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:
{
// Opens file in its default viewer.
@ -126,7 +145,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_OPENFOLDERASWORSPACE:
{
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
{
@ -424,7 +443,7 @@ void Notepad_plus::command(int id)
fullFilePath += TEXT("\"");
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);
}
else // Full file path - need concatenate with current full file path
@ -439,7 +458,7 @@ void Notepad_plus::command(int id)
fullFilePath += curentWord;
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",
_pPublicInterface->getHSelf(),
@ -700,7 +719,7 @@ void Notepad_plus::command(int id)
}
else
{
if (not (*pp[idx])->isClosed())
if (!(*pp[idx])->isClosed())
{
if ((*pp[idx])->checkIfNeedSave())
{
@ -769,7 +788,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_DOC_MAP:
{
if (_pDocMap && (not _pDocMap->isClosed()))
if (_pDocMap && (!_pDocMap->isClosed()))
{
_pDocMap->display(false);
_pDocMap->vzDlgDisplay(false);
@ -2252,7 +2271,7 @@ void Notepad_plus::command(int id)
Buffer* buf = _pEditView->getCurrentBuffer();
if (not buf->isReadOnly())
if (!buf->isReadOnly())
{
std::lock_guard<std::mutex> lock(command_mutex);
buf->setEolFormat(newFormat);
@ -2440,7 +2459,7 @@ void Notepad_plus::command(int id)
return;
}
if (not buf->isDirty())
if (!buf->isDirty())
{
buf->setEncoding(encoding);
buf->setUnicodeMode(uniCookie);
@ -3310,7 +3329,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_RESTORELASTCLOSEDFILE:
{
generic_string lastOpenedFullPath = _lastRecentFileList.getFirstItem();
if (not lastOpenedFullPath.empty())
if (!lastOpenedFullPath.empty())
{
BufferID lastOpened = doOpen(lastOpenedFullPath);
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(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_CONTAININGFOLDERASWORKSPACE, TEXT("Open Containing Folder as Workspace")));
itemUnitArray.push_back(MenuItemUnit(0, NULL));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_DEFAULT_VIEWER, TEXT("Open in Default Viewer")));
itemUnitArray.push_back(MenuItemUnit(0, NULL));

View File

@ -404,32 +404,33 @@ static const int tabContextMenuItemPos[] =
{
// +-------------- The order in tab menu (NppNotification.cpp : if (!_tabPopupMenu.isCreated())
// |
// | +------ Number in english.xml (<language>.xml) : <TabBar>
// | |
0, // 0 : Close
1, // 1 : Close ALL BUT This
5, // 2 : Save
6, // 3 : Save As
10, // 4 : Print
24, // 5 : Move to Other View
25, // 6 : Clone to Other View
20, // 7 : Full File Path to Clipboard
21, // 8 : Filename to Clipboard
22, // 9 : Current Dir. Path to Clipboard
// | +------ Number in english.xml (<language>.xml) : <TabBar>
// | |
0, // 0: Close
1, // 1: Close ALL BUT This
5, // 2: Save
6, // 3: Save As
10, // 4: Print
25, // 5: Move to Other View
26, // 6: Clone to Other View
21, // 7: Full File Path to Clipboard
22, // 8: Filename to Clipboard
23, // 9: Current Dir. Path to Clipboard
7, // 10: Rename
8, // 11: Move to Recycle Bin
17, // 12: Read-Only
18, // 13: Clear Read-Only Flag
26, // 14: Move to New Instance
27, // 15: Open to New Instance
18, // 12: Read-Only
19, // 13: Clear Read-Only Flag
27, // 14: Move to New Instance
28, // 15: Open to New Instance
9, // 16: Reload
2, // 17: Close ALL to the Left
3, // 18: Close ALL to the Right
12, // 19: Open Containing Folder in Explorer
13, // 20: Open Containing Folder in cmd
15, // 21: Open in Default Viewer
12, // 19: Open Containing Folder in Explorer
13, // 20: Open Containing Folder in cmd
16, // 21: Open in Default Viewer
4, // 22: Close ALL Unchanged
-1 //-------End
14, // 23: Open Containing Folder as Workspace
-1 //-------End
};

View File

@ -32,35 +32,36 @@
#define IDM_FILE (IDM + 1000)
// IMPORTANT: If list below is modified, you have to change the value of IDM_FILEMENU_LASTONE and IDM_FILEMENU_EXISTCMDPOSITION
#define IDM_FILE_NEW (IDM_FILE + 1)
#define IDM_FILE_OPEN (IDM_FILE + 2)
#define IDM_FILE_CLOSE (IDM_FILE + 3)
#define IDM_FILE_CLOSEALL (IDM_FILE + 4)
#define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5)
#define IDM_FILE_SAVE (IDM_FILE + 6)
#define IDM_FILE_SAVEALL (IDM_FILE + 7)
#define IDM_FILE_SAVEAS (IDM_FILE + 8)
#define IDM_FILE_CLOSEALL_TOLEFT (IDM_FILE + 9)
#define IDM_FILE_PRINT (IDM_FILE + 10)
#define IDM_FILE_PRINTNOW 1001
#define IDM_FILE_EXIT (IDM_FILE + 11)
#define IDM_FILE_LOADSESSION (IDM_FILE + 12)
#define IDM_FILE_SAVESESSION (IDM_FILE + 13)
#define IDM_FILE_RELOAD (IDM_FILE + 14)
#define IDM_FILE_SAVECOPYAS (IDM_FILE + 15)
#define IDM_FILE_DELETE (IDM_FILE + 16)
#define IDM_FILE_RENAME (IDM_FILE + 17)
#define IDM_FILE_CLOSEALL_TORIGHT (IDM_FILE + 18)
#define IDM_FILE_OPEN_FOLDER (IDM_FILE + 19)
#define IDM_FILE_OPEN_CMD (IDM_FILE + 20)
#define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21)
#define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22)
#define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23)
#define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24)
#define IDM_FILE_NEW (IDM_FILE + 1)
#define IDM_FILE_OPEN (IDM_FILE + 2)
#define IDM_FILE_CLOSE (IDM_FILE + 3)
#define IDM_FILE_CLOSEALL (IDM_FILE + 4)
#define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5)
#define IDM_FILE_SAVE (IDM_FILE + 6)
#define IDM_FILE_SAVEALL (IDM_FILE + 7)
#define IDM_FILE_SAVEAS (IDM_FILE + 8)
#define IDM_FILE_CLOSEALL_TOLEFT (IDM_FILE + 9)
#define IDM_FILE_PRINT (IDM_FILE + 10)
#define IDM_FILE_PRINTNOW 1001
#define IDM_FILE_EXIT (IDM_FILE + 11)
#define IDM_FILE_LOADSESSION (IDM_FILE + 12)
#define IDM_FILE_SAVESESSION (IDM_FILE + 13)
#define IDM_FILE_RELOAD (IDM_FILE + 14)
#define IDM_FILE_SAVECOPYAS (IDM_FILE + 15)
#define IDM_FILE_DELETE (IDM_FILE + 16)
#define IDM_FILE_RENAME (IDM_FILE + 17)
#define IDM_FILE_CLOSEALL_TORIGHT (IDM_FILE + 18)
#define IDM_FILE_OPEN_FOLDER (IDM_FILE + 19)
#define IDM_FILE_OPEN_CMD (IDM_FILE + 20)
#define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21)
#define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22)
#define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23)
#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:
// 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
// and without counting "Recent files history" items