Add "View Current File in Browser" for Firefox, Chrome, IE & Edge
Restore deleted "Launch in browser" customized shorcuts in [EU-FOSSA] by implementing them in more secure way.
This commit is contained in:
parent
0cddeaa9f2
commit
6dfd22d52f
@ -1063,6 +1063,7 @@ Do you want to launch Notepad++ in Administrator mode?"/>
|
||||
<OpenInAdminModeWithoutCloseCurrent title="Save failed" message="The file cannot be saved and it may be protected.
|
||||
Do you want to launch Notepad++ in Administrator mode?"/>
|
||||
<OpenInAdminModeFailed title="Open in Administrator mode failed" message="Notepad++ cannot be opened in Administrator mode."/>
|
||||
<ViewInBrowser title="View Current File in Browser" message="Application cannot be found in your system."/>
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
<PanelTitle name="Clipboard History"/>
|
||||
|
@ -2000,6 +2000,11 @@ void Notepad_plus::checkDocState()
|
||||
|
||||
enableCommand(IDM_FILE_OPEN_DEFAULT_VIEWER, isAssoCommandExisting(curBuf->getFullPathName()), MENU);
|
||||
|
||||
enableCommand(IDM_VIEW_IN_FIREFOX, isAssoCommandExisting(curBuf->getFullPathName()), MENU);
|
||||
enableCommand(IDM_VIEW_IN_CHROME, isAssoCommandExisting(curBuf->getFullPathName()), MENU);
|
||||
enableCommand(IDM_VIEW_IN_IE, isAssoCommandExisting(curBuf->getFullPathName()), MENU);
|
||||
enableCommand(IDM_VIEW_IN_EDGE, isAssoCommandExisting(curBuf->getFullPathName()), MENU);
|
||||
|
||||
enableConvertMenuItems(curBuf->getEolFormat());
|
||||
checkUnicodeMenuItems();
|
||||
checkLangsMenu(-1);
|
||||
|
@ -458,6 +458,14 @@ BEGIN
|
||||
MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE
|
||||
MENUITEM "Post-It", IDM_VIEW_POSTIT
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "View Current File in"
|
||||
BEGIN
|
||||
MENUITEM "Firefox", IDM_VIEW_IN_FIREFOX
|
||||
MENUITEM "Chrome", IDM_VIEW_IN_CHROME
|
||||
MENUITEM "Edge", IDM_VIEW_IN_EDGE
|
||||
MENUITEM "IE", IDM_VIEW_IN_IE
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "Show Symbol"
|
||||
BEGIN
|
||||
|
@ -1780,6 +1780,74 @@ void Notepad_plus::command(int id)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_IN_FIREFOX:
|
||||
case IDM_VIEW_IN_CHROME:
|
||||
case IDM_VIEW_IN_IE:
|
||||
{
|
||||
auto currentBuf = _pEditView->getCurrentBuffer();
|
||||
if (!currentBuf->isUntitled())
|
||||
{
|
||||
generic_string appName;
|
||||
|
||||
if (id == IDM_VIEW_IN_FIREFOX)
|
||||
{
|
||||
appName = TEXT("firefox.exe");
|
||||
}
|
||||
else if (id == IDM_VIEW_IN_CHROME)
|
||||
{
|
||||
appName = TEXT("chrome.exe");
|
||||
}
|
||||
else // if (id == IDM_VIEW_IN_IE)
|
||||
{
|
||||
appName = TEXT("IEXPLORE.EXE");
|
||||
}
|
||||
|
||||
TCHAR valData[MAX_PATH] = {'\0'};
|
||||
int valDataLen = MAX_PATH * sizeof(TCHAR);
|
||||
int valType;
|
||||
HKEY hKey2Check = nullptr;
|
||||
generic_string appEntry = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
|
||||
appEntry += appName;
|
||||
::RegOpenKeyEx(HKEY_LOCAL_MACHINE, appEntry.c_str(), 0, KEY_READ, &hKey2Check);
|
||||
::RegQueryValueEx(hKey2Check, TEXT(""), nullptr, reinterpret_cast<LPDWORD>(&valType), reinterpret_cast<LPBYTE>(valData), reinterpret_cast<LPDWORD>(&valDataLen));
|
||||
|
||||
|
||||
generic_string fullCurrentPath = TEXT("\"");
|
||||
fullCurrentPath += currentBuf->getFullPathName();
|
||||
fullCurrentPath += TEXT("\"");
|
||||
|
||||
if (hKey2Check && valData[0] != '\0')
|
||||
{
|
||||
::ShellExecute(NULL, TEXT("open"), valData, fullCurrentPath.c_str(), NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
_nativeLangSpeaker.messageBox("ViewInBrowser",
|
||||
_pPublicInterface->getHSelf(),
|
||||
TEXT("Application cannot be found in your system."),
|
||||
TEXT("View Current File in Browser"),
|
||||
MB_OK);
|
||||
}
|
||||
::RegCloseKey(hKey2Check);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_IN_EDGE:
|
||||
{
|
||||
auto currentBuf = _pEditView->getCurrentBuffer();
|
||||
if (!currentBuf->isUntitled())
|
||||
{
|
||||
// Don't put the quots for Edge, otherwise it doesn't work
|
||||
//fullCurrentPath = TEXT("\"");
|
||||
generic_string fullCurrentPath = currentBuf->getFullPathName();
|
||||
//fullCurrentPath += TEXT("\"");
|
||||
|
||||
ShellExecute(NULL, TEXT("open"), TEXT("shell:Appsfolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"), fullCurrentPath.c_str(), NULL, SW_SHOW);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_TAB_SPACE:
|
||||
{
|
||||
bool isChecked = !(::GetMenuState(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND) == MF_CHECKED);
|
||||
|
@ -232,6 +232,12 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
||||
{ VK_NULL, IDM_VIEW_ALWAYSONTOP, false, false, false, nullptr },
|
||||
{ VK_F11, IDM_VIEW_FULLSCREENTOGGLE, false, false, false, nullptr },
|
||||
{ VK_F12, IDM_VIEW_POSTIT, false, false, false, nullptr },
|
||||
|
||||
{ VK_NULL, IDM_VIEW_IN_FIREFOX, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_VIEW_IN_CHROME, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_VIEW_IN_IE, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_VIEW_IN_EDGE, false, false, false, nullptr },
|
||||
|
||||
{ VK_NULL, IDM_VIEW_TAB_SPACE, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_VIEW_EOL, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_VIEW_ALL_CHARACTERS, false, false, false, nullptr },
|
||||
|
@ -71,13 +71,14 @@ MenuPosition menuPos[] = {
|
||||
{ 2, 21, -1, "search-jumpDown" },
|
||||
{ 2, 23, -1, "search-bookmark" },
|
||||
|
||||
{ 3, 4, -1, "view-showSymbol" },
|
||||
{ 3, 5, -1, "view-zoom" },
|
||||
{ 3, 6, -1, "view-moveCloneDocument" },
|
||||
{ 3, 7, -1, "view-tab" },
|
||||
{ 3, 16, -1, "view-collapseLevel" },
|
||||
{ 3, 17, -1, "view-uncollapseLevel" },
|
||||
{ 3, 21, -1, "view-project" },
|
||||
{ 3, 4, -1, "view-currentFileIn" },
|
||||
{ 3, 6, -1, "view-showSymbol" },
|
||||
{ 3, 7, -1, "view-zoom" },
|
||||
{ 3, 8, -1, "view-moveCloneDocument" },
|
||||
{ 3, 9, -1, "view-tab" },
|
||||
{ 3, 18, -1, "view-collapseLevel" },
|
||||
{ 3, 19, -1, "view-uncollapseLevel" },
|
||||
{ 3, 23, -1, "view-project" },
|
||||
|
||||
{ 4, 5, -1, "encoding-characterSets" },
|
||||
{ 4, 5, 0, "encoding-arabic" },
|
||||
|
@ -351,6 +351,10 @@
|
||||
#define IDM_VIEW_MONITORING (IDM_VIEW + 97)
|
||||
#define IDM_VIEW_TAB_MOVEFORWARD (IDM_VIEW + 98)
|
||||
#define IDM_VIEW_TAB_MOVEBACKWARD (IDM_VIEW + 99)
|
||||
#define IDM_VIEW_IN_FIREFOX (IDM_VIEW + 100)
|
||||
#define IDM_VIEW_IN_CHROME (IDM_VIEW + 101)
|
||||
#define IDM_VIEW_IN_EDGE (IDM_VIEW + 102)
|
||||
#define IDM_VIEW_IN_IE (IDM_VIEW + 103)
|
||||
|
||||
#define IDM_VIEW_GOTO_ANOTHER_VIEW 10001
|
||||
#define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002
|
||||
|
Loading…
Reference in New Issue
Block a user