diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index eaa1e3d0..3047365f 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -483,6 +483,10 @@ void Notepad_plus::command(int id) { url = TEXT("https://search.yahoo.com/search?q=$(CURRENT_WORD)"); } + else if (nppGui._searchEngineChoice == nppGui.se_stackoverflow) + { + url = TEXT("https://stackoverflow.com/search?q=$(CURRENT_WORD)"); + } Command cmd(url.c_str()); cmd.run(_pPublicInterface->getHSelf()); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index b21fb084..e4798fd6 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -880,7 +880,7 @@ struct NppGUI final unsigned char _availableClouds = '\0'; // this option will never be read/written from/to config.xml bool _useNewStyleSaveDlg = false; - enum SearchEngineChoice{ se_custom = 0, se_duckDuckGo = 1, se_google = 2, se_bing = 3, se_yahoo = 4 }; + enum SearchEngineChoice{ se_custom = 0, se_duckDuckGo = 1, se_google = 2, se_bing = 3, se_yahoo = 4, se_stackoverflow = 5 }; SearchEngineChoice _searchEngineChoice = se_google; generic_string _searchEngineCustom; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index fd39051b..d12c1698 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -403,12 +403,13 @@ IDD_PREFERENCE_SEARCHENGINE_BOX DIALOGEX 0, 0, 455, 185 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Search Engine (for command ""Search on Internet"")",IDC_SEARCHENGINES_GB_STATIC,89,24,268,130,BS_CENTER - CONTROL "DuckDuckGo",IDC_SEARCHENGINE_DUCKDUCKGO_RADIO,"Button",BS_AUTORADIOBUTTON,125,37,180,10 - CONTROL "Google",IDC_SEARCHENGINE_GOOGLE_RADIO,"Button",BS_AUTORADIOBUTTON,125,52,180,10 - CONTROL "Bing",IDC_SEARCHENGINE_BING_RADIO,"Button",BS_AUTORADIOBUTTON,125,67,180,10 - CONTROL "Yahoo!",IDC_SEARCHENGINE_YAHOO_RADIO,"Button",BS_AUTORADIOBUTTON,125,82,180,10 - CONTROL "Set your search engine here:",IDC_SEARCHENGINE_CUSTOM_RADIO,"Button",BS_AUTORADIOBUTTON,125,97,180,10 - EDITTEXT IDC_SEARCHENGINE_EDIT,134,112,179,14,ES_AUTOHSCROLL - LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,134,127,220,20 -END + GROUPBOX "Search Engine (for command ""Search on Internet"")",IDC_SEARCHENGINES_GB_STATIC,74,24,297,145,BS_CENTER + CONTROL "DuckDuckGo",IDC_SEARCHENGINE_DUCKDUCKGO_RADIO,"Button",BS_AUTORADIOBUTTON,105,37,180,10 + CONTROL "Google",IDC_SEARCHENGINE_GOOGLE_RADIO,"Button",BS_AUTORADIOBUTTON,105,52,180,10 + CONTROL "Bing",IDC_SEARCHENGINE_BING_RADIO,"Button",BS_AUTORADIOBUTTON,105,67,180,10 + CONTROL "Yahoo!",IDC_SEARCHENGINE_YAHOO_RADIO,"Button",BS_AUTORADIOBUTTON,105,82,180,10 + CONTROL "Stack Overflow",IDC_SEARCHENGINE_STACKOVERFLOW_RADIO,"Button",BS_AUTORADIOBUTTON,105,97,180,10 + CONTROL "Set your search engine here:",IDC_SEARCHENGINE_CUSTOM_RADIO, "Button",BS_AUTORADIOBUTTON,105,112,180,10 + EDITTEXT IDC_SEARCHENGINE_EDIT,114,128,179,14,ES_AUTOHSCROLL + LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,114,143,245,20 +END \ No newline at end of file diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index bc65cb04..d4594630 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -3394,6 +3394,7 @@ INT_PTR CALLBACK SearchEngineChoiceDlg::run_dlgProc(UINT message, WPARAM wParam, ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_GOOGLE_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_google ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_BING_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_bing ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_YAHOO_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_yahoo ? BST_CHECKED : BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_STACKOVERFLOW_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_stackoverflow ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_EDIT, WM_SETTEXT, 0, reinterpret_cast(nppGUI._searchEngineCustom.c_str())); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), nppGUI._searchEngineChoice == nppGUI.se_custom); @@ -3432,6 +3433,13 @@ INT_PTR CALLBACK SearchEngineChoiceDlg::run_dlgProc(UINT message, WPARAM wParam, } break; + case IDC_SEARCHENGINE_STACKOVERFLOW_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_stackoverflow; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false); + } + break; + case IDC_SEARCHENGINE_CUSTOM_RADIO: { nppGUI._searchEngineChoice = nppGUI.se_custom; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index cc90047d..42cc8ec1 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -153,6 +153,7 @@ #define IDC_SEARCHENGINE_CUSTOM_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 6) #define IDC_SEARCHENGINE_EDIT (IDD_PREFERENCE_SEARCHENGINE_BOX + 7) #define IDD_SEARCHENGINE_NOTE_STATIC (IDD_PREFERENCE_SEARCHENGINE_BOX + 8) + #define IDC_SEARCHENGINE_STACKOVERFLOW_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 9) #define IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300) #define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1)