Add open file on selection & open container on selection commands

pull/2199/head
Don Ho 2016-08-22 00:52:26 +02:00
parent fe01f7501b
commit 863c4e90c1
9 changed files with 112 additions and 31 deletions

View File

@ -29,7 +29,7 @@ If ErrorLevel 1 goto End
signtool.exe sign /f %NPP_CERT% /p %NPP_CERT_PWD% /d "Notepad++" /du https://notepad-plus-plus.org/ /t http://timestamp.digicert.com/ ..\bin\NppShell_06.dll
If ErrorLevel 1 goto End
signtool.exe sign /f %NPP_CERT% /p %NPP_CERT_PWD% /d "Notepad++" /du https://notepad-plus-plus.org/ /t http://timestamp.digicert.com/ ..\bin\NppShell64_06.dll
signtool.exe sign /f %NPP_CERT% /p %NPP_CERT_PWD% /d "Notepad++" /du https://notepad-plus-plus.org/ /t http://timestamp.digicert.com/ ..\bin64\NppShell64_06.dll
rem signtool.exe sign /f %NPP_CERT% /p %NPP_CERT_PWD% /d "Notepad++" /du https://notepad-plus-plus.org/ /t http://timestamp.digicert.com/ ..\bin64\NppShell64_06.dll
If ErrorLevel 1 goto End
sign them manuelly as they are updated

View File

@ -440,6 +440,8 @@ enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, W
// INT NPPM_GETCURRENTCOLUMN(0, 0)
// return the caret current position column
#define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH)
#define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1
#define CURRENT_DIRECTORY 2
@ -450,6 +452,7 @@ enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, W
#define NPP_DIRECTORY 7
#define CURRENT_LINE 8
#define CURRENT_COLUMN 9
#define NPP_FULL_FILE_PATH 10
// Notification code

View File

@ -347,6 +347,14 @@ BEGIN
MENUITEM "Cut Binary Content", IDM_EDIT_CUT_BINARY
MENUITEM "Paste Binary Content", IDM_EDIT_PASTE_BINARY
END
POPUP "On Selection"
BEGIN
MENUITEM "Open as file", IDM_EDIT_OPENASFILE
MENUITEM "Open in folder", IDM_EDIT_OPENINFOLDER
//MENUITEM SEPARATOR
//MENUITEM "Search on Internet", IDM_EDIT_SEARCHONINTERNET
//MENUITEM "Change Search Engin...", IDM_EDIT_CHANGESEARCHENGIN
END
MENUITEM SEPARATOR
MENUITEM "Column Mode...", IDM_EDIT_COLUMNMODETIP
MENUITEM "Column Editor...", IDM_EDIT_COLUMNMODE

View File

@ -71,12 +71,12 @@ struct SortTaskListPred final
};
LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (hwnd == NULL)
return FALSE;
switch(Message)
switch(message)
{
case WM_NCCREATE:
{
@ -90,15 +90,15 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message,
default:
{
return (reinterpret_cast<Notepad_plus_Window *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, Message, wParam, lParam));
return (reinterpret_cast<Notepad_plus_Window *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, message, wParam, lParam));
}
}
}
LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (Message)
switch (message)
{
case WM_CREATE:
{
@ -117,25 +117,25 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPA
default:
{
if (this)
return _notepad_plus_plus_core.process(hwnd, Message, wParam, lParam);
return _notepad_plus_plus_core.process(hwnd, message, wParam, lParam);
}
}
return FALSE;
}
LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result = FALSE;
NppParameters *pNppParam = NppParameters::getInstance();
switch (Message)
switch (message)
{
case WM_NCACTIVATE:
{
// Note: lParam is -1 to prevent endless loops of calls
::SendMessage(_dockingManager.getHSelf(), WM_NCACTIVATE, wParam, -1);
return ::DefWindowProc(hwnd, Message, wParam, lParam);
return ::DefWindowProc(hwnd, message, wParam, lParam);
}
case WM_DRAWITEM:
@ -646,16 +646,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
// par defaut : NPPM_GETCURRENTDIRECTORY
TCHAR *fileStr = lstrcpy(str, _pEditView->getCurrentBuffer()->getFullPathName());
if (Message == NPPM_GETCURRENTDIRECTORY)
if (message == NPPM_GETCURRENTDIRECTORY)
PathRemoveFileSpec(str);
else if (Message == NPPM_GETFILENAME)
else if (message == NPPM_GETFILENAME)
fileStr = PathFindFileName(str);
else if (Message == NPPM_GETNAMEPART)
else if (message == NPPM_GETNAMEPART)
{
fileStr = PathFindFileName(str);
PathRemoveExtension(fileStr);
}
else if (Message == NPPM_GETEXTPART)
else if (message == NPPM_GETEXTPART)
fileStr = PathFindExtension(str);
// For the compability reason, if wParam is 0, then we assume the size of generic_string buffer (lParam) is large enough.
@ -699,12 +699,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_GETNPPFULLFILEPATH:
case NPPM_GETNPPDIRECTORY:
{
const int strSize = MAX_PATH;
TCHAR str[strSize];
::GetModuleFileName(NULL, str, strSize);
if (message == NPPM_GETNPPDIRECTORY)
PathRemoveFileSpec(str);
// For the compability reason, if wParam is 0, then we assume the size of generic_string buffer (lParam) is large enough.
@ -779,7 +782,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
size_t nbFileNames = static_cast<size_t>(lParam);
size_t j = 0;
if (Message != NPPM_GETOPENFILENAMESSECOND)
if (message != NPPM_GETOPENFILENAMESSECOND)
{
for (size_t i = 0; i < _mainDocTab.nbItem() && j < nbFileNames; ++i)
{
@ -789,7 +792,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
}
if (Message != NPPM_GETOPENFILENAMESPRIMARY)
if (message != NPPM_GETOPENFILENAMESPRIMARY)
{
for (size_t i = 0; i < _subDocTab.nbItem() && j < nbFileNames; ++i)
{
@ -871,7 +874,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
break;
}
}
return ::DefWindowProc(hwnd, Message, wParam, lParam);
return ::DefWindowProc(hwnd, message, wParam, lParam);
}
case NPPM_GETNBSESSIONFILES:
@ -999,7 +1002,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
switchEditViewTo(whichView);
activateDoc(index);
if (Message == NPPM_TRIGGERTABBARCONTEXTMENU)
if (message == NPPM_TRIGGERTABBARCONTEXTMENU)
{
// open here tab menu
NMHDR nmhdr;
@ -1318,7 +1321,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_SCROLLBEYONDLASTLINE:
{
const bool endAtLastLine = not (pNppParam->getSVP())._scrollBeyondLastLine;
@ -1407,7 +1409,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
}
return ::DefWindowProc(hwnd, Message, wParam, lParam);
return ::DefWindowProc(hwnd, message, wParam, lParam);
}
case WM_NOTIFY:
@ -1727,7 +1729,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
::LockWindowUpdate(NULL);
//Sends WM_DESTROY, Notepad++ will end
if (Message == WM_CLOSE)
if (message == WM_CLOSE)
::DestroyWindow(hwnd);
}
return TRUE;
@ -1770,7 +1772,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_sysMenuEntering = true;
}
return ::DefWindowProc(hwnd, Message, wParam, lParam);
return ::DefWindowProc(hwnd, message, wParam, lParam);
}
case WM_LBUTTONDBLCLK:
@ -1936,7 +1938,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_MSGTOPLUGIN :
{
return _pluginsManager.relayPluginMessages(Message, wParam, lParam);
return _pluginsManager.relayPluginMessages(message, wParam, lParam);
}
case NPPM_ALLOCATESUPPORTED:
@ -2132,7 +2134,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR:
case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR:
{
return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
return (message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
?(NppParameters::getInstance())->getCurrentDefaultFgColor()
:(NppParameters::getInstance())->getCurrentDefaultBgColor());
}
@ -2240,7 +2242,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
default:
{
if (Message == WDN_NOTIFY)
if (message == WDN_NOTIFY)
{
NMWINDLG* nmdlg = reinterpret_cast<NMWINDLG*>(lParam);
switch (nmdlg->type)
@ -2310,11 +2312,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
return ::DefWindowProc(hwnd, Message, wParam, lParam);
return ::DefWindowProc(hwnd, message, wParam, lParam);
}
}
_pluginsManager.relayNppMessages(Message, wParam, lParam);
_pluginsManager.relayNppMessages(message, wParam, lParam);
return result;
}

View File

@ -342,7 +342,6 @@ void Notepad_plus::command(int id)
}
else
{
_pEditView->execute(SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(lpchar));
}
GlobalUnlock(hglb);
@ -353,6 +352,68 @@ void Notepad_plus::command(int id)
}
break;
case IDM_EDIT_OPENINFOLDER:
case IDM_EDIT_OPENASFILE:
{
if (_pEditView->execute(SCI_GETSELECTIONS) != 1) // Multi-Selection || Column mode || no selection
return;
HWND hwnd = _pPublicInterface->getHSelf();
TCHAR curentWord[CURRENTWORD_MAXLENGTH];
::SendMessage(hwnd, NPPM_GETCURRENTWORD, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(curentWord));
TCHAR cmd2Exec[CURRENTWORD_MAXLENGTH];
if (id == IDM_EDIT_OPENINFOLDER)
{
lstrcpy(cmd2Exec, TEXT("explorer"));
}
else
{
::SendMessage(hwnd, NPPM_GETNPPFULLFILEPATH, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(cmd2Exec));
}
if (::PathFileExists(curentWord))
{
generic_string fullFilePath = id == IDM_EDIT_OPENINFOLDER ? TEXT("/select,") : TEXT("");
fullFilePath += TEXT("\"");
fullFilePath += curentWord;
fullFilePath += TEXT("\"");
if (id == IDM_EDIT_OPENINFOLDER ||
(id == IDM_EDIT_OPENASFILE && not ::PathIsDirectory(curentWord)))
::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW);
}
else
{
TCHAR currentDir[CURRENTWORD_MAXLENGTH];
::SendMessage(hwnd, NPPM_GETCURRENTDIRECTORY, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(currentDir));
generic_string fullFilePath = id == IDM_EDIT_OPENINFOLDER ? TEXT("/select,") : TEXT("");
fullFilePath += TEXT("\"");
fullFilePath += currentDir;
fullFilePath += TEXT("\\");
fullFilePath += curentWord;
if ((id == IDM_EDIT_OPENASFILE &&
(not::PathFileExists(fullFilePath.c_str() + 1) || ::PathIsDirectory(fullFilePath.c_str() + 1))))
return;
fullFilePath += TEXT("\"");
::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW);
}
}
break;
case IDM_EDIT_SEARCHONINTERNET:
{
}
break;
case IDM_EDIT_CHANGESEARCHENGIN:
{
}
break;
case IDM_EDIT_PASTE_AS_RTF:
case IDM_EDIT_PASTE_AS_HTML:
{

View File

@ -79,6 +79,8 @@ int whichVar(TCHAR *str)
return CURRENT_WORD;
else if (!lstrcmp(nppDir, str))
return NPP_DIRECTORY;
else if (!lstrcmp(nppFullFilePath, str))
return NPP_FULL_FILE_PATH;
else if (!lstrcmp(currentLine, str))
return CURRENT_LINE;
else if (!lstrcmp(currentColumn, str))

View File

@ -34,6 +34,7 @@ const TCHAR fileNamePart[] = TEXT("NAME_PART");
const TCHAR fileExtPart[] = TEXT("EXT_PART");
const TCHAR currentWord[] = TEXT("CURRENT_WORD");
const TCHAR nppDir[] = TEXT("NPP_DIRECTORY");
const TCHAR nppFullFilePath[] = TEXT("NPP_FULL_FILE_PATH");
const TCHAR currentLine[] = TEXT("CURRENT_LINE");
const TCHAR currentColumn[] = TEXT("CURRENT_COLUMN");

View File

@ -128,6 +128,11 @@
#define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65)
#define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66)
#define IDM_EDIT_OPENASFILE (IDM_EDIT + 73)
#define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74)
#define IDM_EDIT_SEARCHONINTERNET (IDM_EDIT + 75)
#define IDM_EDIT_CHANGESEARCHENGIN (IDM_EDIT + 76)
// Menu macro
#define IDM_MACRO_STARTRECORDINGMACRO (IDM_EDIT + 18)
#define IDM_MACRO_STOPRECORDINGMACRO (IDM_EDIT + 19)

View File

@ -14,8 +14,7 @@
<Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/$(CURRENT_WORD)</Command>
<Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">https://www.google.com/search?q=$(CURRENT_WORD)</Command>
<Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
<Command name="Open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
<Command name="Open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -nosession -multiInst</Command>
<Command name="Open file in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_FULL_FILE_PATH) $(CURRENT_WORD) -nosession -multiInst</Command>
<Command name="Send via Outlook" Ctrl="yes" Alt="yes" Shift="yes" Key="79">outlook /a &quot;$(FULL_CURRENT_PATH)&quot;</Command>
</UserDefinedCommands>
<PluginCommands />