diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index 2758016b7..f2df7d9ec 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -31,6 +31,7 @@ + @@ -113,6 +114,10 @@ + + + + @@ -806,6 +811,17 @@ + + + + + + + + + + + @@ -879,6 +895,7 @@ + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 9ca047508..173d39b61 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -31,6 +31,7 @@ + @@ -120,6 +121,10 @@ + + + + @@ -808,12 +813,22 @@ - + - + + + + + + + + + + + @@ -888,6 +903,7 @@ + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 3ff63f603..6eea08374 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -31,6 +31,7 @@ + @@ -114,6 +115,10 @@ + + + + @@ -794,6 +799,17 @@ + + + + + + + + + + + @@ -868,6 +884,7 @@ + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a79290157..2d6ea6e49 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -202,7 +202,7 @@ Notepad_plus::~Notepad_plus() LRESULT Notepad_plus::init(HWND hwnd) { NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); // Menu _mainMenuHandle = ::GetMenu(hwnd); @@ -750,7 +750,7 @@ void Notepad_plus::killAllChildren() bool Notepad_plus::saveGUIParams() { - NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI(); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); nppGUI._toolBarStatus = _toolBar.getState(); @@ -818,7 +818,7 @@ bool Notepad_plus::saveFileBrowserParam() void Notepad_plus::saveDockingParams() { - NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI(); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); // Save the docking information nppGUI._dockingData._leftWidth = _dockingManager.getDockedContSize(CONT_LEFT); @@ -4360,7 +4360,7 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const // found if (_pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, posStart)) { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); nppGUI._disableSmartHiliteTmp = true; auto currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd); @@ -4413,7 +4413,7 @@ bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const // found if (_pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, posStart)) { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); nppGUI._disableSmartHiliteTmp = true; auto currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 350468b6b..437132cac 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -349,11 +349,11 @@ BEGIN 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 + MENUITEM "Open File", IDM_EDIT_OPENASFILE + MENUITEM "Open Containing Folder in Explorer", IDM_EDIT_OPENINFOLDER + MENUITEM SEPARATOR + MENUITEM "Search on Internet", IDM_EDIT_SEARCHONINTERNET + MENUITEM "Change Search Engine...", IDM_EDIT_CHANGESEARCHENGINE END MENUITEM SEPARATOR MENUITEM "Column Mode...", IDM_EDIT_COLUMNMODETIP diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index 1dc683898..842ee0350 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -94,7 +94,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin } NppParameters *pNppParams = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParams->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParams->getNppGUI()); if (cmdLineParams->_isNoPlugin) _notepad_plus_plus_core._pluginsManager.disable(); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 04b769fb2..d4676d02f 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1286,7 +1286,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SETCARETWIDTH: { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); if (nppGUI._caretWidth < 4) { @@ -1339,7 +1339,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SETCARETBLINKRATE: { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); _mainEditView.execute(SCI_SETCARETPERIOD, nppGUI._caretBlinkRate); _subEditView.execute(SCI_SETCARETPERIOD, nppGUI._caretBlinkRate); return TRUE; diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 518f82861..d65c01c13 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -372,6 +372,7 @@ void Notepad_plus::command(int id) ::SendMessage(hwnd, NPPM_GETNPPFULLFILEPATH, CURRENTWORD_MAXLENGTH, reinterpret_cast(cmd2Exec)); } + // Full file path if (::PathFileExists(curentWord)) { generic_string fullFilePath = id == IDM_EDIT_OPENINFOLDER ? TEXT("/select,") : TEXT(""); @@ -383,7 +384,7 @@ void Notepad_plus::command(int id) (id == IDM_EDIT_OPENASFILE && not ::PathIsDirectory(curentWord))) ::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW); } - else + else // Full file path - need concatenate with current full file path { TCHAR currentDir[CURRENTWORD_MAXLENGTH]; ::SendMessage(hwnd, NPPM_GETCURRENTDIRECTORY, CURRENTWORD_MAXLENGTH, reinterpret_cast(currentDir)); @@ -393,9 +394,17 @@ void Notepad_plus::command(int id) fullFilePath += currentDir; fullFilePath += TEXT("\\"); fullFilePath += curentWord; - if ((id == IDM_EDIT_OPENASFILE && + + if ((id == IDM_EDIT_OPENASFILE && (not::PathFileExists(fullFilePath.c_str() + 1) || ::PathIsDirectory(fullFilePath.c_str() + 1)))) + { + _nativeLangSpeaker.messageBox("FilePathNotFoundWarning", + _pPublicInterface->getHSelf(), + TEXT("The file you're trying to open doesn't exist."), + TEXT("File Open"), + MB_OK | MB_APPLMODAL); return; + } fullFilePath += TEXT("\""); ::ShellExecute(hwnd, TEXT("open"), cmd2Exec, fullFilePath.c_str(), TEXT("."), SW_SHOW); } @@ -404,13 +413,48 @@ void Notepad_plus::command(int id) case IDM_EDIT_SEARCHONINTERNET: { + if (_pEditView->execute(SCI_GETSELECTIONS) != 1) // Multi-Selection || Column mode || no selection + return; + const NppGUI & nppGui = (NppParameters::getInstance())->getNppGUI(); + generic_string url; + if (nppGui._searchEngineChoice == nppGui.se_custom) + { + if (nppGui._searchEngineCustom.empty()) + { + url = TEXT("https://www.google.com/search?q=$(CURRENT_WORD)"); + } + else + { + url = nppGui._searchEngineCustom.c_str(); + } + } + else if (nppGui._searchEngineChoice == nppGui.se_duckDuckGo) + { + url = TEXT("https://duckduckgo.com/?q=$(CURRENT_WORD)"); + } + else if (nppGui._searchEngineChoice == nppGui.se_google) + { + url = TEXT("https://www.google.com/search?q=$(CURRENT_WORD)"); + } + else if (nppGui._searchEngineChoice == nppGui.se_bing) + { + url = TEXT("https://www.bing.com/search?q=$(CURRENT_WORD)"); + } + else if (nppGui._searchEngineChoice == nppGui.se_yahoo) + { + url = TEXT("https://search.yahoo.com/search?q=$(CURRENT_WORD)"); + } + + Command cmd(url.c_str()); + cmd.run(_pPublicInterface->getHSelf()); } break; - case IDM_EDIT_CHANGESEARCHENGIN: + case IDM_EDIT_CHANGESEARCHENGINE: { - + command(IDM_SETTING_PREFERECE); + _preference.showDialogByName(TEXT("SearchEngine")); } break; @@ -2378,15 +2422,13 @@ void Notepad_plus::command(int id) case IDM_SETTING_EDITCONTEXTMENU : { - //if (contion) - { - generic_string warning, title; - _nativeLangSpeaker.messageBox("ContextMenuXmlEditWarning", - _pPublicInterface->getHSelf(), - TEXT("Editing contextMenu.xml allows you to modify your Notepad++ popup context menu on edit zone.\rYou have to restart your Notepad++ to take effect after modifying contextMenu.xml."), - TEXT("Editing contextMenu"), - MB_OK|MB_APPLMODAL); - } + generic_string warning, title; + _nativeLangSpeaker.messageBox("ContextMenuXmlEditWarning", + _pPublicInterface->getHSelf(), + TEXT("Editing contextMenu.xml allows you to modify your Notepad++ popup context menu on edit zone.\rYou have to restart your Notepad++ to take effect after modifying contextMenu.xml."), + TEXT("Editing contextMenu"), + MB_OK|MB_APPLMODAL); + NppParameters *pNppParams = NppParameters::getInstance(); BufferID bufID = doOpen((pNppParams->getContextMenuPath())); switchToFile(bufID); @@ -2765,7 +2807,7 @@ void Notepad_plus::command(int id) case IDM_SYSTRAYPOPUP_NEWDOC: { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); ::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); fileNew(); } @@ -2773,14 +2815,14 @@ void Notepad_plus::command(int id) case IDM_SYSTRAYPOPUP_ACTIVATE : { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); ::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); } break; case IDM_SYSTRAYPOPUP_NEW_AND_PASTE: { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); ::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); BufferID bufferID = _pEditView->getCurrentBufferID(); Buffer * buf = MainFileManager->getBufferByID(bufferID); @@ -2794,7 +2836,7 @@ void Notepad_plus::command(int id) case IDM_SYSTRAYPOPUP_OPENFILE: { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); ::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); fileOpen(); } diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 078a783ea..df29ce059 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1297,13 +1297,13 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy) // Disable file autodetection before opening save dialog to prevent use-after-delete bug. NppParameters *pNppParam = NppParameters::getInstance(); - ChangeDetect cdBefore = ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection; - ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = cdDisabled; + ChangeDetect cdBefore = (const_cast(pNppParam->getNppGUI()))._fileAutoDetection; + (const_cast(pNppParam->getNppGUI()))._fileAutoDetection = cdDisabled; TCHAR *pfn = fDlg.doSaveDlg(); // Enable file autodetection again. - ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = cdBefore; + (const_cast(pNppParam->getNppGUI()))._fileAutoDetection = cdBefore; if (pfn) { diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 3b633a5ca..fea9965b2 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -710,7 +710,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) braceMatch(); - NppGUI & nppGui = (NppGUI &)nppParam->getNppGUI(); + NppGUI & nppGui = const_cast(nppParam->getNppGUI()); if (nppGui._enableTagsMatchHilite) { diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 45ae7bfbd..6a7f0f0f6 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -146,6 +146,10 @@ static const WinMenuKeyDefinition winKeyDefs[] = {VK_SPACE, IDM_EDIT_AUTOCOMPLETE_PATH, true, true, false, nullptr}, {VK_RETURN, IDM_EDIT_AUTOCOMPLETE_CURRENTFILE, true, false, false, nullptr}, {VK_SPACE, IDM_EDIT_FUNCCALLTIP, true, false, true, nullptr}, + {VK_NULL, IDM_EDIT_OPENASFILE, false, false, false, nullptr}, + {VK_NULL, IDM_EDIT_OPENINFOLDER, false, false, false, nullptr}, + {VK_NULL, IDM_EDIT_SEARCHONINTERNET, false, false, false, nullptr}, + {VK_NULL, IDM_EDIT_CHANGESEARCHENGINE, false, false, false, nullptr}, {VK_R, IDM_EDIT_RTL, true, true, false, nullptr}, {VK_L, IDM_EDIT_LTR, true, true, false, nullptr}, {VK_NULL, IDM_EDIT_SORTLINES_LEXICOGRAPHIC_ASCENDING, false, false, false, nullptr}, @@ -329,11 +333,11 @@ static const WinMenuKeyDefinition winKeyDefs[] = {VK_NULL, IDM_HOMESWEETHOME, false, false, false, nullptr}, {VK_NULL, IDM_PROJECTPAGE, false, false, false, nullptr}, - {VK_NULL, IDM_ONLINEHELP, false, false, false, nullptr}, + //{VK_NULL, IDM_ONLINEHELP, false, false, false, nullptr}, {VK_NULL, IDM_FORUM, false, false, false, nullptr}, {VK_NULL, IDM_PLUGINSHOME, false, false, false, nullptr}, {VK_F1, IDM_ABOUT, false, false, false, nullptr}, - {VK_F1, IDM_HELP, false, false, true, nullptr}, + //{VK_F1, IDM_HELP, false, false, true, nullptr}, {VK_TAB, IDC_PREV_DOC, true, false, true, TEXT("Switch to previous document")}, {VK_TAB, IDC_NEXT_DOC, true, false, false, TEXT("Switch to next document")}, @@ -454,42 +458,12 @@ static const ScintillaKeyDefinition scintKeyDefs[] = {TEXT("SCI_DELLINERIGHT"), SCI_DELLINERIGHT, true, false, true, VK_DELETE, 0}, {TEXT("SCI_LINEDELETE"), SCI_LINEDELETE, true, false, true, VK_L, 0}, {TEXT("SCI_LINECUT"), SCI_LINECUT, true, false, false, VK_L, 0}, - {TEXT("SCI_LINECOPY"), SCI_LINECOPY, true, false, true, VK_T, 0}, + {TEXT("SCI_LINECOPY"), SCI_LINECOPY, true, false, true, VK_X, 0}, {TEXT("SCI_LINETRANSPOSE"), SCI_LINETRANSPOSE, true, false, false, VK_T, 0}, {TEXT("SCI_LINEDUPLICATE"), SCI_LINEDUPLICATE, false, false, false, 0, 0}, {TEXT("SCI_CANCEL"), SCI_CANCEL, false, false, false, VK_ESCAPE, 0}, {TEXT("SCI_SWAPMAINANCHORCARET"), SCI_SWAPMAINANCHORCARET, false, false, false, 0, 0}, {TEXT("SCI_ROTATESELECTION"), SCI_ROTATESELECTION, false, false, false, 0, 0} - - // {TEXT("SCI_EMPTYUNDOBUFFER"), SCI_EMPTYUNDOBUFFER, false, false, false, 0, 0}, - // {TEXT("SCI_TOGGLECARETSTICKY"), SCI_TOGGLECARETSTICKY, false, false, false, 0, 0}, - // {TEXT("SCI_CALLTIPCANCEL"), SCI_CALLTIPCANCEL, false, false, false, 0, 0}, - // {TEXT("SCI_SETSAVEPOINT"), SCI_SETSAVEPOINT, false, false, false, 0, 0}, - // {TEXT("SCI_CLEARDOCUMENTSTYLE"), SCI_CLEARDOCUMENTSTYLE, false, false, false, 0, 0}, - // - // - //{TEXT("SCI_CHOOSECARETX"), SCI_CHOOSECARETX, false, false, false, 0, 0}, - // {TEXT("SCI_AUTOCCOMPLETE"), SCI_AUTOCCOMPLETE, false, false, false, 0, 0}, - // {TEXT("SCI_AUTOCCANCEL"), SCI_AUTOCCANCEL, false, false, false, 0, 0}, - // {TEXT("SCI_CLEARREGISTEREDIMAGES"), SCI_CLEARREGISTEREDIMAGES, false, false, false, 0, 0}, - // {TEXT("SCI_HOMEDISPLAYEXTEND"), SCI_HOMEDISPLAYEXTEND, false, true, true, VK_HOME, 0}, - // {TEXT("SCI_LINEENDDISPLAYEXTEND"), SCI_LINEENDDISPLAYEXTEND, false, true, true, VK_END, 0}, - // - // {TEXT("SCI_DELWORDRIGHTEND"), SCI_DELWORDRIGHTEND, false, false, false, 0, 0}, - // {TEXT("SCI_LOWERCASE"), SCI_LOWERCASE, false, false, false, 0, 0}, - // {TEXT("SCI_UPPERCASE"), SCI_UPPERCASE, false, false, false, 0, 0}, - // {TEXT("SCI_LOWERCASE"), SCI_LOWERCASE, true, false, false, VK_U, 0}, - // {TEXT("SCI_UPPERCASE"), SCI_UPPERCASE, true, false, true, VK_U, 0}, - // - // {TEXT("SCI_FORMFEED"), SCI_FORMFEED, true, false, false, VK_L, 0}, - // {TEXT("SCI_CLEARALLCMDKEYS"), SCI_CLEARALLCMDKEYS, false, false, false, 0, 0}, - // {TEXT("SCI_STARTRECORD"), SCI_STARTRECORD, false, false, false, 0, 0}, - // {TEXT("SCI_STOPRECORD"), SCI_STOPRECORD, false, false, false, 0, 0}, - // {TEXT("SCI_SEARCHANCHOR"), SCI_SEARCHANCHOR, false, false, false, 0, 0}, - // {TEXT("SCI_TARGETFROMSELECTION"), SCI_TARGETFROMSELECTION, false, false, false, 0, 0}, - // {TEXT("SCI_STYLERESETDEFAULT"), SCI_STYLERESETDEFAULT, false, false, false, 0, 0}, - // {TEXT("SCI_STYLECLEARALL"), SCI_STYLECLEARALL, false, false, false, 0, 0}, - // }; @@ -2329,7 +2303,7 @@ void NppParameters::feedUserCmds(TiXmlNode *node) childNode = childNode->NextSibling(TEXT("Command")) ) { Shortcut sc; - if (getShortcuts(childNode, sc))// && sc.isValid()) + if (getShortcuts(childNode, sc)) { TiXmlNode *aNode = childNode->FirstChild(); if (aNode) @@ -2337,9 +2311,8 @@ void NppParameters::feedUserCmds(TiXmlNode *node) const TCHAR *cmdStr = aNode->Value(); if (cmdStr) { - int cmdID = ID_USER_CMD + int32_t(_userCommands.size()); + int cmdID = ID_USER_CMD + static_cast(_userCommands.size()); UserCommand uc(sc, cmdStr, cmdID); - //if (uc.isValid()) _userCommands.push_back(uc); } } @@ -2904,7 +2877,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) if (root) { TiXmlNode *sessionNode = root->InsertEndChild(TiXmlElement(TEXT("Session"))); - (sessionNode->ToElement())->SetAttribute(TEXT("activeView"), static_cast(session._activeView)); + (sessionNode->ToElement())->SetAttribute(TEXT("activeView"), static_cast(session._activeView)); struct ViewElem { TiXmlNode *viewNode; @@ -2922,7 +2895,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) for (size_t k = 0; k < nbElem ; ++k) { - (viewElems[k].viewNode->ToElement())->SetAttribute(TEXT("activeIndex"), static_cast(viewElems[k].activeIndex)); + (viewElems[k].viewNode->ToElement())->SetAttribute(TEXT("activeIndex"), static_cast(viewElems[k].activeIndex)); vector & viewSessionFiles = *(viewElems[k].viewFiles); for (size_t i = 0, len = viewElems[k].viewFiles->size(); i < len ; ++i) @@ -2939,20 +2912,20 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) (fileNameNode->ToElement())->SetAttribute(TEXT("encoding"), viewSessionFiles[i]._encoding); (fileNameNode->ToElement())->SetAttribute(TEXT("filename"), viewSessionFiles[i]._fileName.c_str()); (fileNameNode->ToElement())->SetAttribute(TEXT("backupFilePath"), viewSessionFiles[i]._backupFilePath.c_str()); - (fileNameNode->ToElement())->SetAttribute(TEXT("originalFileLastModifTimestamp"), int(viewSessionFiles[i]._originalFileLastModifTimestamp)); + (fileNameNode->ToElement())->SetAttribute(TEXT("originalFileLastModifTimestamp"), static_cast(viewSessionFiles[i]._originalFileLastModifTimestamp)); for (size_t j = 0, len = viewSessionFiles[i]._marks.size() ; j < len ; ++j) { size_t markLine = viewSessionFiles[i]._marks[j]; TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark"))); - markNode->ToElement()->SetAttribute(TEXT("line"), int(markLine)); + markNode->ToElement()->SetAttribute(TEXT("line"), static_cast(markLine)); } for (size_t j = 0, len = viewSessionFiles[i]._foldStates.size() ; j < len ; ++j) { size_t foldLine = viewSessionFiles[i]._foldStates[j]; TiXmlNode *foldNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold"))); - foldNode->ToElement()->SetAttribute(TEXT("line"), int(foldLine)); + foldNode->ToElement()->SetAttribute(TEXT("line"), static_cast(foldLine)); } } } @@ -3513,7 +3486,7 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA // 2 restes : L_H, L_USER LangType NppParameters::getLangIDFromStr(const TCHAR *langName) { - int lang = static_cast(L_TEXT); + int lang = static_cast(L_TEXT); for(; lang < L_EXTERNAL; ++lang) { const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; @@ -4502,7 +4475,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) { int i; if (element->Attribute(TEXT("autoCAction"), &i)) - _nppGUI._autocStatus = (NppGUI::AutocStatus)i; + _nppGUI._autocStatus = static_cast(i); if (element->Attribute(TEXT("triggerFromNbChar"), &i)) _nppGUI._autocFromLen = i; @@ -4660,6 +4633,16 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = 0; _nppGUI._multiInstSetting = (MultiInstSetting)val; } + else if (!lstrcmp(nm, TEXT("searchEngine"))) + { + int i; + if (element->Attribute(TEXT("searchEngineChoice"), &i)) + _nppGUI._searchEngineChoice = static_cast(i); + + const TCHAR * searchEngineCustom = element->Attribute(TEXT("searchEngineCustom")); + if (searchEngineCustom && searchEngineCustom[0]) + _nppGUI._searchEngineCustom = searchEngineCustom; + } else if (!lstrcmp(nm, TEXT("MISC"))) { const TCHAR * optName = element->Attribute(TEXT("fileSwitcherWithoutExtColumn")); @@ -5049,6 +5032,7 @@ bool NppParameters::writeGUIParams() bool delimiterSelectionExist = false; bool multiInstExist = false; bool miscExist = false; + bool searchEngineExist = false; TiXmlNode *dockingParamNode = NULL; @@ -5292,7 +5276,7 @@ bool NppParameters::writeGUIParams() } else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings"))) { - element->SetAttribute(TEXT("format"), static_cast(_nppGUI._newDocDefaultSettings._format)); + element->SetAttribute(TEXT("format"), static_cast(_nppGUI._newDocDefaultSettings._format)); element->SetAttribute(TEXT("encoding"), _nppGUI._newDocDefaultSettings._unicodeMode); element->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); element->SetAttribute(TEXT("codepage"), _nppGUI._newDocDefaultSettings._codepage); @@ -5317,7 +5301,7 @@ bool NppParameters::writeGUIParams() element->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str()); element->SetAttribute(TEXT("isSnapshotMode"), _nppGUI._isSnapshotMode && _nppGUI._rememberLastSession?TEXT("yes"):TEXT("no")); - element->SetAttribute(TEXT("snapshotBackupTiming"), int32_t(_nppGUI._snapshotBackupTiming)); + element->SetAttribute(TEXT("snapshotBackupTiming"), static_cast(_nppGUI._snapshotBackupTiming)); backExist = true; } else if (!lstrcmp(nm, TEXT("MRU"))) @@ -5378,7 +5362,7 @@ bool NppParameters::writeGUIParams() { autocExist = true; element->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); - element->SetAttribute(TEXT("triggerFromNbChar"), int32_t(_nppGUI._autocFromLen)); + element->SetAttribute(TEXT("triggerFromNbChar"), static_cast(_nppGUI._autocFromLen)); const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); element->SetAttribute(TEXT("funcParams"), pStr); } @@ -5498,8 +5482,8 @@ bool NppParameters::writeGUIParams() } else if (!lstrcmp(nm, TEXT("delimiterSelection"))) { - element->SetAttribute(TEXT("leftmostDelimiter"), static_cast(_nppGUI._leftmostDelimiter)); - element->SetAttribute(TEXT("rightmostDelimiter"), static_cast(_nppGUI._rightmostDelimiter)); + element->SetAttribute(TEXT("leftmostDelimiter"), static_cast(_nppGUI._leftmostDelimiter)); + element->SetAttribute(TEXT("rightmostDelimiter"), static_cast(_nppGUI._rightmostDelimiter)); if(_nppGUI._delimiterSelectionOnEntireDocument) element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("yes")); else @@ -5511,6 +5495,12 @@ bool NppParameters::writeGUIParams() multiInstExist = true; element->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting); } + else if (!lstrcmp(nm, TEXT("searchEngine"))) + { + searchEngineExist = true; + element->SetAttribute(TEXT("searchEngineChoice"), _nppGUI._searchEngineChoice); + element->SetAttribute(TEXT("searchEngineCustom"), _nppGUI._searchEngineCustom); + } } if (!noUpdateExist) @@ -5580,7 +5570,7 @@ bool NppParameters::writeGUIParams() { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("NewDocDefaultSettings")); - GUIConfigElement->SetAttribute(TEXT("format"), static_cast(_nppGUI._newDocDefaultSettings._format)); + GUIConfigElement->SetAttribute(TEXT("format"), static_cast(_nppGUI._newDocDefaultSettings._format)); GUIConfigElement->SetAttribute(TEXT("encoding"), _nppGUI._newDocDefaultSettings._unicodeMode); GUIConfigElement->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); GUIConfigElement->SetAttribute(TEXT("codepage"), _nppGUI._newDocDefaultSettings._codepage); @@ -5610,7 +5600,7 @@ bool NppParameters::writeGUIParams() GUIConfigElement->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str()); GUIConfigElement->SetAttribute(TEXT("isSnapshotMode"), _nppGUI.isSnapshotMode()?TEXT("yes"):TEXT("no")); - GUIConfigElement->SetAttribute(TEXT("snapshotBackupTiming"), int32_t(_nppGUI._snapshotBackupTiming)); + GUIConfigElement->SetAttribute(TEXT("snapshotBackupTiming"), static_cast(_nppGUI._snapshotBackupTiming)); } if (!doTaskListExist) @@ -5654,7 +5644,7 @@ bool NppParameters::writeGUIParams() TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("auto-completion")); GUIConfigElement->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); - GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), int32_t(_nppGUI._autocFromLen)); + GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), static_cast(_nppGUI._autocFromLen)); const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr); } @@ -5741,12 +5731,14 @@ bool NppParameters::writeGUIParams() const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no"); GUIConfigElement->SetAttribute(TEXT("short"), pStr); } + if (!stylerThemeExist) { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("stylerTheme")); GUIConfigElement->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str()); } + if (!delimiterSelectionExist) { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); @@ -5755,12 +5747,14 @@ bool NppParameters::writeGUIParams() GUIConfigElement->SetAttribute(TEXT("rightmostDelimiter"), _nppGUI._rightmostDelimiter); GUIConfigElement->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), _nppGUI._delimiterSelectionOnEntireDocument); } + if (!multiInstExist) { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("multiInst")); GUIConfigElement->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting); } + if (!miscExist) { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); @@ -5770,6 +5764,15 @@ bool NppParameters::writeGUIParams() GUIConfigElement->SetAttribute(TEXT("backSlashIsEscapeCharacterForSql"), _nppGUI._backSlashIsEscapeCharacterForSql?TEXT("yes"):TEXT("no")); GUIConfigElement->SetAttribute(TEXT("newStyleSaveDlg"), _nppGUI._useNewStyleSaveDlg?TEXT("yes"):TEXT("no")); } + + if (!searchEngineExist) + { + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("searchEngine")); + GUIConfigElement->SetAttribute(TEXT("searchEngineChoice"), _nppGUI._searchEngineChoice); + GUIConfigElement->SetAttribute(TEXT("searchEngineCustom"), _nppGUI._searchEngineCustom); + } + insertDockingParamNode(GUIRoot); return true; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 6e56865ef..afbd207fa 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -786,9 +786,6 @@ struct NppGUI final generic_string _definedSessionExt; generic_string _definedWorkspaceExt; - - - struct AutoUpdateOptions { @@ -819,6 +816,10 @@ struct NppGUI final generic_string _cloudPath; // 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; + + enum SearchEngineChoice{ se_custom = 0, se_duckDuckGo = 1, se_google = 2, se_bing = 3, se_yahoo = 4 }; + SearchEngineChoice _searchEngineChoice = se_google; + generic_string _searchEngineCustom; }; struct ScintillaViewParams diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index cce724cd0..071cd0e4a 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -385,8 +385,21 @@ BEGIN GROUPBOX "Settings on cloud",IDC_SETTINGSONCLOUD_GB_STATIC,89,44,268,102,BS_CENTER CONTROL "No Cloud",IDC_NOCLOUD_RADIO,"Button",BS_AUTORADIOBUTTON,125,57,180,10 CONTROL "Set your cloud location path here:",IDC_WITHCLOUD_RADIO,"Button",BS_AUTORADIOBUTTON,125,72,180,10 - EDITTEXT IDC_CLOUDPATH_EDIT,134,88,179,14,ES_AUTOHSCROLL + EDITTEXT IDC_CLOUDPATH_EDIT,134,88,179,14,ES_AUTOHSCROLL PUSHBUTTON "...",IDD_CLOUDPATH_BROWSE_BUTTON,320,87,16,14 LTEXT "",IDC_SETTINGSONCLOUD_WARNING_STATIC,131,117,135,20 END +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 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index e13a22a06..0a3ea3f5c 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -95,9 +95,9 @@ static int encodings[] = { 20866 }; -INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -147,6 +147,9 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM _settingsOnCloudDlg.init(_hInst, _hSelf); _settingsOnCloudDlg.create(IDD_PREFERENCE_SETTINGSONCLOUD_BOX, false, false); + _searchEngineDlg.init(_hInst, _hSelf); + _searchEngineDlg.create(IDD_PREFERENCE_SEARCHENGINE_BOX, false, false); + _wVector.push_back(DlgInfo(&_barsDlg, TEXT("General"), TEXT("Global"))); _wVector.push_back(DlgInfo(&_marginsDlg, TEXT("Editing"), TEXT("Scintillas"))); @@ -162,6 +165,7 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM _wVector.push_back(DlgInfo(&_multiInstDlg, TEXT("Multi-Instance"), TEXT("MultiInstance"))); _wVector.push_back(DlgInfo(&_delimiterSettingsDlg, TEXT("Delimiter"), TEXT("Delimiter"))); _wVector.push_back(DlgInfo(&_settingsOnCloudDlg, TEXT("Cloud"), TEXT("Cloud"))); + _wVector.push_back(DlgInfo(&_searchEngineDlg, TEXT("Search Engine"), TEXT("SearchEngine"))); _wVector.push_back(DlgInfo(&_settingsDlg, TEXT("MISC."), TEXT("MISC"))); @@ -188,6 +192,7 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM _multiInstDlg.reSizeTo(rc); _delimiterSettingsDlg.reSizeTo(rc); _settingsOnCloudDlg.reSizeTo(rc); + _searchEngineDlg.reSizeTo(rc); NppParameters *pNppParam = NppParameters::getInstance(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); @@ -238,6 +243,20 @@ void PreferenceDlg::makeCategoryList() setListSelection(0); } +int32_t PreferenceDlg::getIndexFromName(const TCHAR *name) const +{ + if (not name) + return -1; + + int32_t i = 0; + for (auto it = _wVector.begin() ; it != _wVector.end(); ++it, ++i) + { + if (it->_internalName == name) + return i; + } + return -1; +} + void PreferenceDlg::setListSelection(size_t currentSel) const { // Stupid LB API doesn't allow LB_SETSEL to be used on single select listbox, so we do it in a hard way @@ -279,7 +298,18 @@ bool PreferenceDlg::renameDialogTitle(const TCHAR *internalName, const TCHAR *ne return true; } -void PreferenceDlg::showDialogByIndex(size_t index) +void PreferenceDlg::showDialogByName(const TCHAR *name) const +{ + int32_t i = getIndexFromName(name); + if (i >= 0) + { + showDialogByIndex(i); + setListSelection(i); + } +} + + +void PreferenceDlg::showDialogByIndex(size_t index) const { size_t len = _wVector.size(); for (size_t i = 0; i < len; ++i) @@ -307,11 +337,11 @@ void PreferenceDlg::destroy() _delimiterSettingsDlg.destroy(); } -INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -592,11 +622,11 @@ void MarginsDlg::initScintParam() } -INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - switch (Message) + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -820,11 +850,11 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa return FALSE; } -INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - switch (Message) + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -1116,13 +1146,13 @@ void RecentFilesHistoryDlg::setCustomLen(int val) ::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0?SW_SHOW:SW_HIDE); } -INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); NewDocDefaultSettings & ndds = (NewDocDefaultSettings &)nppGUI.getNewDocDefaultSettings(); - switch (Message) + switch (message) { case WM_INITDIALOG: { @@ -1314,12 +1344,12 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR return FALSE; } -INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -1407,12 +1437,12 @@ INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT Message, WPARAM wParam, L return FALSE; } -INT_PTR CALLBACK RecentFilesHistoryDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK RecentFilesHistoryDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -1542,12 +1572,12 @@ INT_PTR CALLBACK RecentFilesHistoryDlg::run_dlgProc(UINT Message, WPARAM wParam, return FALSE; } -INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -1733,12 +1763,12 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP return FALSE; } -INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/* lParam*/) +INT_PTR CALLBACK TabSettings::run_dlgProc(UINT message, WPARAM wParam, LPARAM/* lParam*/) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -1952,12 +1982,12 @@ void trim(generic_string & str) else str.erase(str.begin(), str.end()); }; -INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); - switch (Message) + switch (message) { case WM_INITDIALOG : { @@ -2255,11 +2285,11 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR } -INT_PTR CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK BackupDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - switch (Message) + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -2449,11 +2479,11 @@ void BackupDlg::updateBackupGUI() } -INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - switch (Message) + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -2644,7 +2674,6 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA const int NB_MAX_CHAR = 9; ValueDlg valDlg; - //NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); valDlg.init(NULL, _hSelf, static_cast(nppGUI._autocFromLen), TEXT("Nb char : ")); valDlg.setNBNumber(1); @@ -2717,10 +2746,10 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA } -INT_PTR CALLBACK MultiInstDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK MultiInstDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); - switch (Message) + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -2763,10 +2792,10 @@ INT_PTR CALLBACK MultiInstDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) return FALSE; } -INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); - switch (Message) + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); + switch (message) { case WM_INITDIALOG : { @@ -2879,10 +2908,10 @@ INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, return FALSE; } -INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters * nppParams = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI &)(nppParams->getNppGUI()); + NppGUI & nppGUI = const_cast(nppParams->getNppGUI()); if (HIWORD(wParam) == EN_CHANGE) { @@ -2917,7 +2946,7 @@ INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LP } } - switch (Message) + switch (message) { case WM_INITDIALOG: { @@ -2984,5 +3013,92 @@ INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LP return FALSE; } +INT_PTR CALLBACK SearchEngineChoiceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) +{ + NppParameters * nppParams = NppParameters::getInstance(); + NppGUI & nppGUI = const_cast(nppParams->getNppGUI()); + if (HIWORD(wParam) == EN_CHANGE) + { + switch (LOWORD(wParam)) + { + case IDC_SEARCHENGINE_EDIT: + { + TCHAR input[MAX_PATH] = { '\0' }; + ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast(input)); + nppGUI._searchEngineCustom = input; + return TRUE; + } + } + } + + switch (message) + { + case WM_INITDIALOG: + { + if (nppGUI._searchEngineChoice == nppGUI.se_custom) + { + if (nppGUI._searchEngineCustom.empty()) + { + nppGUI._searchEngineChoice = nppGUI.se_google; + } + } + ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_CUSTOM_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_custom ? BST_CHECKED : BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_SEARCHENGINE_DUCKDUCKGO_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_duckDuckGo ? 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_YAHOO_RADIO, BM_SETCHECK, nppGUI._searchEngineChoice == nppGUI.se_yahoo ? 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); + } + break; + + case WM_COMMAND: + { + switch (wParam) + { + case IDC_SEARCHENGINE_DUCKDUCKGO_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_duckDuckGo; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false); + } + break; + + case IDC_SEARCHENGINE_GOOGLE_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_google; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false); + } + break; + + case IDC_SEARCHENGINE_BING_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_bing; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false); + } + break; + + case IDC_SEARCHENGINE_YAHOO_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_yahoo; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), false); + } + break; + + case IDC_SEARCHENGINE_CUSTOM_RADIO: + { + nppGUI._searchEngineChoice = nppGUI.se_custom; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SEARCHENGINE_EDIT), true); + } + break; + + default: + return FALSE; + } + } + break; + } + return FALSE; +} diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 769b8f634..8d6a50a65 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -26,32 +26,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef PREFERENCE_DLG_H -#define PREFERENCE_DLG_H +#pragma once -#ifndef CONTROLS_TAB_H #include "ControlsTab.h" -#endif //CONTROLS_TAB_H - -#ifndef PREFERENCE_RC_H #include "preference_rc.h" -#endif //PREFERENCE_RC_H - -#ifndef URLCTRL_INCLUDED #include "URLCtrl.h" -#endif //URLCTRL_INCLUDED - -#ifndef PARAMETERS_H #include "Parameters.h" -#endif //PARAMETERS_H - -#ifndef REG_EXT_DLG_H #include "regExtDlg.h" -#endif //REG_EXT_DLG_H - -#ifndef WORD_STYLE_H #include "WordStyleDlg.h" -#endif //WORD_STYLE_H class SettingsDlg : public StaticDialog { @@ -59,7 +41,7 @@ public : SettingsDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class BarsDlg : public StaticDialog @@ -67,7 +49,7 @@ class BarsDlg : public StaticDialog public : BarsDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class MarginsDlg : public StaticDialog @@ -80,7 +62,7 @@ public : private : URLCtrl _verticalEdgeLineNbColVal; - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); void initScintParam(); }; @@ -103,7 +85,7 @@ private : ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, BST_UNCHECKED, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), doIt); }; - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class DefaultDirectoryDlg : public StaticDialog @@ -112,7 +94,7 @@ public : DefaultDirectoryDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class RecentFilesHistoryDlg : public StaticDialog @@ -128,7 +110,7 @@ private : URLCtrl _customLenVal; std::vector _langList; void setCustomLen(int val); - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class LangMenuDlg : public StaticDialog @@ -138,7 +120,7 @@ public : private : LexerStylerArray _lsArray; - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); std::vector _langList; }; @@ -152,7 +134,7 @@ public : private : URLCtrl _tabSizeVal; - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; @@ -167,7 +149,7 @@ class PrintSettingsDlg : public StaticDialog public : PrintSettingsDlg():_focusedEditCtrl(0), _selStart(0), _selEnd(0){}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); std::vector varList; int _focusedEditCtrl; DWORD _selStart; @@ -180,7 +162,7 @@ public : BackupDlg() {}; private : void updateBackupGUI(); - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; @@ -190,7 +172,7 @@ public : AutoCompletionDlg() {}; private : URLCtrl _nbCharVal; - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class MultiInstDlg : public StaticDialog @@ -199,7 +181,7 @@ public : MultiInstDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class DelimiterSettingsDlg : public StaticDialog @@ -208,7 +190,7 @@ public : DelimiterSettingsDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); POINT _singleLineModePoint, _multiLineModePoint; RECT _closerRect, _closerLabelRect; }; @@ -219,7 +201,16 @@ public : SettingsOnCloudDlg() {}; private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); +}; + +class SearchEngineChoiceDlg : public StaticDialog +{ +public : + SearchEngineChoiceDlg() {}; + +private : + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; class PreferenceDlg : public StaticDialog @@ -246,14 +237,17 @@ public : int getListSelectedIndex() const { return static_cast(::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0)); }; + + void showDialogByName(const TCHAR *name) const; void setListSelection(size_t currentSel) const; virtual void destroy(); private : - INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); void makeCategoryList(); - void showDialogByIndex(size_t index); + int32_t getIndexFromName(const TCHAR *name) const; + void showDialogByIndex(size_t index) const; //ControlsTab _ctrlTab; WindowVector _wVector; BarsDlg _barsDlg; @@ -271,8 +265,6 @@ private : MultiInstDlg _multiInstDlg; DelimiterSettingsDlg _delimiterSettingsDlg; SettingsOnCloudDlg _settingsOnCloudDlg; + SearchEngineChoiceDlg _searchEngineDlg; }; - - -#endif //PREFERENCE_DLG_H \ No newline at end of file diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index db2401bc6..45aba902e 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -135,6 +135,16 @@ #define IDC_WITHCLOUD_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 7) #define IDC_CLOUDPATH_EDIT (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 8) #define IDD_CLOUDPATH_BROWSE_BUTTON (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 9) + +#define IDD_PREFERENCE_SEARCHENGINE_BOX 6270 //(IDD_PREFERENCE_BOX + 250) + #define IDC_SEARCHENGINES_GB_STATIC (IDD_PREFERENCE_SEARCHENGINE_BOX + 1) + #define IDC_SEARCHENGINE_DUCKDUCKGO_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 2) + #define IDC_SEARCHENGINE_GOOGLE_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 3) + #define IDC_SEARCHENGINE_BING_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 4) + #define IDC_SEARCHENGINE_YAHOO_RADIO (IDD_PREFERENCE_SEARCHENGINE_BOX + 5) + #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 IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300) #define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1) diff --git a/PowerEditor/src/contextMenu.xml b/PowerEditor/src/contextMenu.xml index f048b75ed..74ef28b8b 100644 --- a/PowerEditor/src/contextMenu.xml +++ b/PowerEditor/src/contextMenu.xml @@ -61,6 +61,9 @@ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Context_Menu + + + diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index d62bba708..60b99f82a 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -62,6 +62,7 @@ MenuPosition menuPos[] = { { 1, 16, -1, "edit-eolConversion" }, { 1, 17, -1, "edit-blankOperations" }, { 1, 18, -1, "edit-pasteSpecial" }, + { 1, 19, -1, "edit-onSelection" }, { 2, 18, -1, "search-markAll" }, { 2, 19, -1, "search-unmarkAll" }, @@ -830,6 +831,13 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference) preference.renameDialogTitle(TEXT("Cloud"), nameW); } + changeDlgLang(preference._searchEngineDlg.getHSelf(), "SearchEngine", titre); + if (titre[0] != '\0') + { + const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); + preference.renameDialogTitle(TEXT("SearchEngine"), nameW); + } + preference.setListSelection(currentSel); } diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 50add7235..ec3b333b0 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -131,7 +131,7 @@ #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) + #define IDM_EDIT_CHANGESEARCHENGINE (IDM_EDIT + 76) // Menu macro #define IDM_MACRO_STARTRECORDINGMACRO (IDM_EDIT + 18) diff --git a/PowerEditor/src/shortcuts.xml b/PowerEditor/src/shortcuts.xml index 08f55bc6f..dbce3ab53 100644 --- a/PowerEditor/src/shortcuts.xml +++ b/PowerEditor/src/shortcuts.xml @@ -10,9 +10,8 @@ firefox "$(FULL_CURRENT_PATH)" iexplore "$(FULL_CURRENT_PATH)" chrome "$(FULL_CURRENT_PATH)" - safari "$(FULL_CURRENT_PATH)" + safari "$(FULL_CURRENT_PATH)" http://www.php.net/$(CURRENT_WORD) - https://www.google.com/search?q=$(CURRENT_WORD) https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD) $(NPP_FULL_FILE_PATH) $(CURRENT_WORD) -nosession -multiInst outlook /a "$(FULL_CURRENT_PATH)" diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 7569c92ed..1136c049f 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -413,7 +413,7 @@ DEVOMER*/ Notepad_plus_Window notepad_plus_plus; - NppGUI & nppGui = (NppGUI &)pNppParameters->getNppGUI(); + NppGUI & nppGui = const_cast(pNppParameters->getNppGUI()); generic_string updaterDir = pNppParameters->getNppPath(); updaterDir += TEXT("\\updater\\");