diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 85f74368d..a3cc4bd17 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -18,6 +18,8 @@ #define _WIN32_IE 0x500 #endif +//#define INCLUDE_DEPRECATED_FEATURES 1 + #include #include "Notepad_plus.h" #include "SysMsg.h" @@ -59,7 +61,7 @@ struct SortTaskListPred Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL), _pMainSplitter(NULL), _isfullScreen(false), _recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false), - _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false) + _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true) { _winVersion = getWindowsVersion(); @@ -294,6 +296,9 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi scnN.nmhdr.idFrom = 0; _pluginsManager.notify(&scnN); + if (_hideMenu) + ::SetMenu(_hSelf, NULL); + ::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE)) { @@ -1804,19 +1809,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) } break; - case SCN_DOUBLECLICK : - { - if (_isHotspotDblClicked) - { - int pos = notifyView->execute(SCI_GETCURRENTPOS); - notifyView->execute(SCI_SETCURRENTPOS, pos); - notifyView->execute(SCI_SETANCHOR, pos); - _isHotspotDblClicked = false; - } - } - // - break; - case SCN_SAVEPOINTREACHED: notifyView->setCurrentDocState(false); notifyDocTab->updateCurrentTabItem(); @@ -2164,10 +2156,25 @@ BOOL Notepad_plus::notify(SCNotification *notification) break; } + case SCN_DOUBLECLICK : + { + if (_isHotspotDblClicked) + { + int pos = notifyView->execute(SCI_GETCURRENTPOS); + notifyView->execute(SCI_SETCURRENTPOS, pos); + notifyView->execute(SCI_SETANCHOR, pos); + _isHotspotDblClicked = false; + } + else + { + markSelectedText(); + } + } + break; + case SCN_UPDATEUI: braceMatch(); - //_pEditView->recalcHorizontalScrollbar(); - // To update the line and the col status + markSelectedText(); updateStatusBar(); break; @@ -7577,19 +7584,11 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } return TRUE; } -/* - case WM_INITMENU: - _windowsMenu.initMenu((HMENU)wParam, _pEditView); - return TRUE; -*/ + case WM_INITMENUPOPUP: _windowsMenu.initPopupMenu((HMENU)wParam, _pEditView); return TRUE; -/* - case WM_UNINITMENUPOPUP: - _windowsMenu.uninitPopupMenu((HMENU)wParam, _pEditView); - return TRUE; -*/ + case NPPM_DMMSHOW: { _dockingManager.showDockableDlg((HWND)lParam, SW_SHOW); @@ -7738,6 +7737,20 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return (HWND)lParam == pMainTB; } + case WM_ENTERMENULOOP: + { + if (_hideMenu) + ::SetMenu(_hSelf, _mainMenuHandle); + return FALSE; + } + + case WM_EXITMENULOOP: + { + if (_hideMenu) + ::SetMenu(_hSelf, NULL); + return FALSE; + } + default: { if (Message == WDN_NOTIFY) @@ -7804,17 +7817,6 @@ LRESULT CALLBACK Notepad_plus::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM switch(Message) { - /* case WM_GETMINMAXINFO : // It's the 1st? msg (even before WM_NCCREATE) - { - if (isFirstGetMinMaxInfoMsg) - { - isFirstGetMinMaxInfoMsg = false; - return ::DefWindowProc(hwnd, Message, wParam, lParam); - } - else - return ((Notepad_plus *)::GetWindowLong(hwnd, GWL_USERDATA))->runProc(hwnd, Message, wParam, lParam); - }*/ - case WM_NCCREATE : // First message we get the ptr of instantiated object // then stock it into GWL_USERDATA index in order to retrieve afterward { @@ -7851,18 +7853,14 @@ void Notepad_plus::fullScreenToggle() fullscreenArea.bottom = GetSystemMetrics(SM_CYSCREEN); //Caution, this will not work on windows 95, so probably add some checking of some sorts like Unicode checks, IF 95 were to be supported - //if (_isMultimonitorSupported) { - currentMonitor = MonitorFromWindow(_hSelf, MONITOR_DEFAULTTONEAREST); //should always be valid monitor handle - mi.cbSize = sizeof(MONITORINFO); - if (GetMonitorInfo(currentMonitor, &mi) != FALSE) { - fullscreenArea = mi.rcMonitor; - fullscreenArea.right -= fullscreenArea.left; - fullscreenArea.bottom -= fullscreenArea.top; - } - // else { - //Error!, original RECT should serve as fallback - //} - //} + currentMonitor = MonitorFromWindow(_hSelf, MONITOR_DEFAULTTONEAREST); //should always be valid monitor handle + mi.cbSize = sizeof(MONITORINFO); + if (GetMonitorInfo(currentMonitor, &mi) != FALSE) + { + fullscreenArea = mi.rcMonitor; + fullscreenArea.right -= fullscreenArea.left; + fullscreenArea.bottom -= fullscreenArea.top; + } //Hide menu ::SetMenu(_hSelf, NULL); @@ -8011,24 +8009,6 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool return false; } -/* -void Notepad_plus::changeMenuShortcut(unsigned long cmdID, const char *shortcutStr) -{ - char cmdName[64]; - ::GetMenuString(_mainMenuHandle, cmdID, cmdName, sizeof(cmdName), MF_BYCOMMAND); - - size_t i = 0; - for ( ; i < strlen(cmdName) ; i++) - { - if (cmdName[i] == '\t') - break; - } - cmdName[++i] = '\0'; - string itemStr = cmdName; - itemStr += shortcutStr; - ::ModifyMenu(_mainMenuHandle, cmdID, MF_BYCOMMAND, cmdID, itemStr.c_str()); -} -*/ void Notepad_plus::getCurrentOpenedFiles(Session & session) { @@ -8205,6 +8185,29 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy) } +void Notepad_plus::markSelectedText() +{ + LangType lt = _pEditView->getCurrentDocType(); + if (lt == L_TXT) + _pEditView->defineDocType(L_CPP); + _pEditView->defineDocType(lt); + + // Mark all if there is selection. + CharacterRange range = _pEditView->getSelection(); + if (range.cpMin == range.cpMax) + { + return; + } + + char text2Find[MAX_PATH]; + _pEditView->getSelectedText(text2Find, sizeof(text2Find)); + + FindOption op; + op._isWholeWord = false; + _findReplaceDlg.markAll2(text2Find); +} + + typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); winVer getWindowsVersion() diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 245a42421..422268e81 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -219,6 +219,7 @@ private: WindowsMenu _windowsMenu; HMENU _mainMenuHandle; + bool _hideMenu; LONG_PTR _prevStyles; // For FullScreen feature @@ -345,7 +346,7 @@ private: void enableMenu(int cmdID, bool doEnable) const { int flag = doEnable?MF_ENABLED | MF_BYCOMMAND:MF_DISABLED | MF_GRAYED | MF_BYCOMMAND; - ::EnableMenuItem(::GetMenu(_hSelf), cmdID, flag); + ::EnableMenuItem(_mainMenuHandle, cmdID, flag); } void enableCommand(int cmdID, bool doEnable, int which) const; void checkClipboard(); @@ -468,7 +469,7 @@ private: }; void checkFolderMarginStyleMenu(int id2Check) const { - ::CheckMenuRadioItem(::GetMenu(_hSelf), IDM_VIEW_FOLDERMAGIN_SIMPLE, IDM_VIEW_FOLDERMAGIN_BOX, id2Check, MF_BYCOMMAND); + ::CheckMenuRadioItem(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_SIMPLE, IDM_VIEW_FOLDERMAGIN_BOX, id2Check, MF_BYCOMMAND); }; int getFolderMaginStyleIDFrom(folderStyle fStyle) const { @@ -484,7 +485,7 @@ private: }; void checkMenuItem(int itemID, bool willBeChecked) const { - ::CheckMenuItem(::GetMenu(_hSelf), itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED)); + ::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED)); }; void charAdded(char chAdded); void MaintainIndentation(char ch); @@ -636,7 +637,7 @@ private: char menuLangName[ 16 ]; for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ ) - if ( ::GetMenuString( ::GetMenu( _hSelf ), i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) + if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) if ( !strcmp( langName, menuLangName ) ) { id = i; @@ -646,7 +647,7 @@ private: if ( id == 0 ) { for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ ) - if ( ::GetMenuString( ::GetMenu( _hSelf ), i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) + if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) if ( !strcmp( langName, menuLangName ) ) { id = i; @@ -668,7 +669,7 @@ private: if ( ( id != IDM_LANG_USER ) || !( buf.isUserDefineLangExt() ) ) { - ( ::GetMenuString( ::GetMenu( _hSelf ), id, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ); + ( ::GetMenuString( _mainMenuHandle, id, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ); userLangName = (char *)menuLangName; } else @@ -688,6 +689,8 @@ private: void setFileOpenSaveDlgFilters(FileDialog & fDlg); void reloadOnSwitchBack(); + + void markSelectedText(); }; #endif //NOTEPAD_PLUS_H diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 036f47cc5..bb2aee52a 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -850,9 +850,13 @@ bool FindReplaceDlg::processReplace() int FindReplaceDlg::markAll(const char *str2find) { _doStyleFoundToken = true; - int nbFound = processAll(MARK_ALL, true, NULL, str2find); + return nbFound; +} +int FindReplaceDlg::markAll2(const char *str2find) +{ + int nbFound = processAll(MARK_ALL_2, true, NULL, str2find); return nbFound; } @@ -935,6 +939,10 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons (*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK); } } + else if (op == MARK_ALL_2) + { + (*_ppEditView)->execute(SCI_SETLEXER, SCLEX_NULL); + } int posFind = int((*_ppEditView)->execute(SCI_SEARCHINTARGET, (WPARAM)str2Search.length(), (LPARAM)str2Search.c_str())); @@ -999,6 +1007,13 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons } startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen; } + else if (op == MARK_ALL_2) + { + (*_ppEditView)->execute(SCI_STARTSTYLING, start, STYLING_MASK); + (*_ppEditView)->execute(SCI_SETSTYLING, end - start, SCE_UNIVERSAL_FOUND_STYLE_2); + (*_ppEditView)->execute(SCI_COLOURISE, start, end+1); + startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen; + } else if (op == COUNT_ALL) { startPosition = posFind + foundTextLen; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index a79cd2e5f..d52732a26 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -45,6 +45,7 @@ const int REPLACE_ALL = 0; const int MARK_ALL = 1; const int COUNT_ALL = 2; const int FIND_ALL = 3; +const int MARK_ALL_2 = 4; const int DISPLAY_POS_TOP = 2; const int DISPLAY_POS_MIDDLE = 1; @@ -223,6 +224,8 @@ public : bool processReplace(); int markAll(const char *str2find); + int markAll2(const char *str2find); + int processAll(int op, bool isEntire = false, const char *dir2search = NULL, const char *str2find = NULL); void replaceAllInOpenedDocs(); void findAllIn(InWhat op); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index baee28421..e1a864d8c 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -624,6 +624,13 @@ void ScintillaEditView::defineDocType(LangType typeDoc) int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE); if (iFind != -1) + { + Style & styleFind = stylers.getStyler(iFind); + setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); + } + + iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE_2); + if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index fea0eca3e..41a8579f4 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -109,6 +109,7 @@ //For All lexer #define SCE_UNIVERSAL_SELECT_STYLE 30 #define SCE_UNIVERSAL_FOUND_STYLE 31 +#define SCE_UNIVERSAL_FOUND_STYLE_2 29 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 #define SCE_P_NUMBER 2