diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index d1950c83..67c0f50a 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1063,6 +1063,7 @@ Do you want to launch Notepad++ in Administrator mode?"/> + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 5f28ef40..b4aec465 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -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); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index d6a6e24c..358fa4b9 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -459,6 +459,14 @@ BEGIN 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 MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 3abe99f4..11cd1597 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -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(&valType), reinterpret_cast(valData), reinterpret_cast(&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); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index f63151fe..988f7b9c 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -231,7 +231,13 @@ 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_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 }, diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 2502b624..e3db0f86 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -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" }, diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 8a4b297e..3e1455ca 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -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