Add stackoverflow as search engine

This commit is contained in:
Don HO 2019-02-19 13:05:02 +01:00
parent 188565fd4a
commit 5bcf55c59e
5 changed files with 24 additions and 10 deletions

View File

@ -483,6 +483,10 @@ void Notepad_plus::command(int id)
{ {
url = TEXT("https://search.yahoo.com/search?q=$(CURRENT_WORD)"); 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()); Command cmd(url.c_str());
cmd.run(_pPublicInterface->getHSelf()); cmd.run(_pPublicInterface->getHSelf());

View File

@ -880,7 +880,7 @@ struct NppGUI final
unsigned char _availableClouds = '\0'; // this option will never be read/written from/to config.xml unsigned char _availableClouds = '\0'; // this option will never be read/written from/to config.xml
bool _useNewStyleSaveDlg = false; 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; SearchEngineChoice _searchEngineChoice = se_google;
generic_string _searchEngineCustom; generic_string _searchEngineCustom;

View File

@ -403,12 +403,13 @@ IDD_PREFERENCE_SEARCHENGINE_BOX DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
GROUPBOX "Search Engine (for command ""Search on Internet"")",IDC_SEARCHENGINES_GB_STATIC,89,24,268,130,BS_CENTER 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,125,37,180,10 CONTROL "DuckDuckGo",IDC_SEARCHENGINE_DUCKDUCKGO_RADIO,"Button",BS_AUTORADIOBUTTON,105,37,180,10
CONTROL "Google",IDC_SEARCHENGINE_GOOGLE_RADIO,"Button",BS_AUTORADIOBUTTON,125,52,180,10 CONTROL "Google",IDC_SEARCHENGINE_GOOGLE_RADIO,"Button",BS_AUTORADIOBUTTON,105,52,180,10
CONTROL "Bing",IDC_SEARCHENGINE_BING_RADIO,"Button",BS_AUTORADIOBUTTON,125,67,180,10 CONTROL "Bing",IDC_SEARCHENGINE_BING_RADIO,"Button",BS_AUTORADIOBUTTON,105,67,180,10
CONTROL "Yahoo!",IDC_SEARCHENGINE_YAHOO_RADIO,"Button",BS_AUTORADIOBUTTON,125,82,180,10 CONTROL "Yahoo!",IDC_SEARCHENGINE_YAHOO_RADIO,"Button",BS_AUTORADIOBUTTON,105,82,180,10
CONTROL "Set your search engine here:",IDC_SEARCHENGINE_CUSTOM_RADIO,"Button",BS_AUTORADIOBUTTON,125,97,180,10 CONTROL "Stack Overflow",IDC_SEARCHENGINE_STACKOVERFLOW_RADIO,"Button",BS_AUTORADIOBUTTON,105,97,180,10
EDITTEXT IDC_SEARCHENGINE_EDIT,134,112,179,14,ES_AUTOHSCROLL CONTROL "Set your search engine here:",IDC_SEARCHENGINE_CUSTOM_RADIO, "Button",BS_AUTORADIOBUTTON,105,112,180,10
LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,134,127,220,20 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 END

View File

@ -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_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_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_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<LPARAM>(nppGUI._searchEngineCustom.c_str())); ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(nppGUI._searchEngineCustom.c_str()));
::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), nppGUI._searchEngineChoice == nppGUI.se_custom); ::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; break;
case IDC_SEARCHENGINE_STACKOVERFLOW_RADIO:
{
nppGUI._searchEngineChoice = nppGUI.se_stackoverflow;
::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false);
}
break;
case IDC_SEARCHENGINE_CUSTOM_RADIO: case IDC_SEARCHENGINE_CUSTOM_RADIO:
{ {
nppGUI._searchEngineChoice = nppGUI.se_custom; nppGUI._searchEngineChoice = nppGUI.se_custom;

View File

@ -153,6 +153,7 @@
#define IDC_SEARCHENGINE_CUSTOM_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 6) #define IDC_SEARCHENGINE_CUSTOM_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 6)
#define IDC_SEARCHENGINE_EDIT (IDD_PREFERENCE_SEARCHENGINE_BOX + 7) #define IDC_SEARCHENGINE_EDIT (IDD_PREFERENCE_SEARCHENGINE_BOX + 7)
#define IDD_SEARCHENGINE_NOTE_STATIC (IDD_PREFERENCE_SEARCHENGINE_BOX + 8) #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 IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300)
#define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1) #define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1)