[NEW_FEATURE] Add hilighting all token wile selecting a word (in progress).

Add auto hide menu feature (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@168 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-04-16 22:45:47 +00:00
parent 1a5e5c27bb
commit a2aa87d8c3
6 changed files with 106 additions and 74 deletions

View File

@ -18,6 +18,8 @@
#define _WIN32_IE 0x500 #define _WIN32_IE 0x500
#endif #endif
//#define INCLUDE_DEPRECATED_FEATURES 1
#include <shlwapi.h> #include <shlwapi.h>
#include "Notepad_plus.h" #include "Notepad_plus.h"
#include "SysMsg.h" #include "SysMsg.h"
@ -59,7 +61,7 @@ struct SortTaskListPred
Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL), Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
_pMainSplitter(NULL), _isfullScreen(false), _pMainSplitter(NULL), _isfullScreen(false),
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(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(); _winVersion = getWindowsVersion();
@ -294,6 +296,9 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi
scnN.nmhdr.idFrom = 0; scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
if (_hideMenu)
::SetMenu(_hSelf, NULL);
::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); ::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE)) if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE))
{ {
@ -1804,19 +1809,6 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
break; 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: case SCN_SAVEPOINTREACHED:
notifyView->setCurrentDocState(false); notifyView->setCurrentDocState(false);
notifyDocTab->updateCurrentTabItem(); notifyDocTab->updateCurrentTabItem();
@ -2164,10 +2156,25 @@ BOOL Notepad_plus::notify(SCNotification *notification)
break; 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: case SCN_UPDATEUI:
braceMatch(); braceMatch();
//_pEditView->recalcHorizontalScrollbar(); markSelectedText();
// To update the line and the col status
updateStatusBar(); updateStatusBar();
break; break;
@ -7577,19 +7584,11 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
} }
return TRUE; return TRUE;
} }
/*
case WM_INITMENU:
_windowsMenu.initMenu((HMENU)wParam, _pEditView);
return TRUE;
*/
case WM_INITMENUPOPUP: case WM_INITMENUPOPUP:
_windowsMenu.initPopupMenu((HMENU)wParam, _pEditView); _windowsMenu.initPopupMenu((HMENU)wParam, _pEditView);
return TRUE; return TRUE;
/*
case WM_UNINITMENUPOPUP:
_windowsMenu.uninitPopupMenu((HMENU)wParam, _pEditView);
return TRUE;
*/
case NPPM_DMMSHOW: case NPPM_DMMSHOW:
{ {
_dockingManager.showDockableDlg((HWND)lParam, SW_SHOW); _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; 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: default:
{ {
if (Message == WDN_NOTIFY) if (Message == WDN_NOTIFY)
@ -7804,17 +7817,6 @@ LRESULT CALLBACK Notepad_plus::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM
switch(Message) 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 case WM_NCCREATE : // First message we get the ptr of instantiated object
// then stock it into GWL_USERDATA index in order to retrieve afterward // 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); 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 //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
currentMonitor = MonitorFromWindow(_hSelf, MONITOR_DEFAULTTONEAREST); //should always be valid monitor handle mi.cbSize = sizeof(MONITORINFO);
mi.cbSize = sizeof(MONITORINFO); if (GetMonitorInfo(currentMonitor, &mi) != FALSE)
if (GetMonitorInfo(currentMonitor, &mi) != FALSE) { {
fullscreenArea = mi.rcMonitor; fullscreenArea = mi.rcMonitor;
fullscreenArea.right -= fullscreenArea.left; fullscreenArea.right -= fullscreenArea.left;
fullscreenArea.bottom -= fullscreenArea.top; fullscreenArea.bottom -= fullscreenArea.top;
} }
// else {
//Error!, original RECT should serve as fallback
//}
//}
//Hide menu //Hide menu
::SetMenu(_hSelf, NULL); ::SetMenu(_hSelf, NULL);
@ -8011,24 +8009,6 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool
return false; 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) 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); typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
winVer getWindowsVersion() winVer getWindowsVersion()

View File

@ -219,6 +219,7 @@ private:
WindowsMenu _windowsMenu; WindowsMenu _windowsMenu;
HMENU _mainMenuHandle; HMENU _mainMenuHandle;
bool _hideMenu;
LONG_PTR _prevStyles; LONG_PTR _prevStyles;
// For FullScreen feature // For FullScreen feature
@ -345,7 +346,7 @@ private:
void enableMenu(int cmdID, bool doEnable) const { void enableMenu(int cmdID, bool doEnable) const {
int flag = doEnable?MF_ENABLED | MF_BYCOMMAND:MF_DISABLED | MF_GRAYED | MF_BYCOMMAND; 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 enableCommand(int cmdID, bool doEnable, int which) const;
void checkClipboard(); void checkClipboard();
@ -468,7 +469,7 @@ private:
}; };
void checkFolderMarginStyleMenu(int id2Check) const { 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 { int getFolderMaginStyleIDFrom(folderStyle fStyle) const {
@ -484,7 +485,7 @@ private:
}; };
void checkMenuItem(int itemID, bool willBeChecked) const { 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 charAdded(char chAdded);
void MaintainIndentation(char ch); void MaintainIndentation(char ch);
@ -636,7 +637,7 @@ private:
char menuLangName[ 16 ]; char menuLangName[ 16 ];
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ ) 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 ) ) if ( !strcmp( langName, menuLangName ) )
{ {
id = i; id = i;
@ -646,7 +647,7 @@ private:
if ( id == 0 ) if ( id == 0 )
{ {
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ ) 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 ) ) if ( !strcmp( langName, menuLangName ) )
{ {
id = i; id = i;
@ -668,7 +669,7 @@ private:
if ( ( id != IDM_LANG_USER ) || !( buf.isUserDefineLangExt() ) ) 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; userLangName = (char *)menuLangName;
} }
else else
@ -688,6 +689,8 @@ private:
void setFileOpenSaveDlgFilters(FileDialog & fDlg); void setFileOpenSaveDlgFilters(FileDialog & fDlg);
void reloadOnSwitchBack(); void reloadOnSwitchBack();
void markSelectedText();
}; };
#endif //NOTEPAD_PLUS_H #endif //NOTEPAD_PLUS_H

View File

@ -850,9 +850,13 @@ bool FindReplaceDlg::processReplace()
int FindReplaceDlg::markAll(const char *str2find) int FindReplaceDlg::markAll(const char *str2find)
{ {
_doStyleFoundToken = true; _doStyleFoundToken = true;
int nbFound = processAll(MARK_ALL, true, NULL, str2find); 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; return nbFound;
} }
@ -935,6 +939,10 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK); (*_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())); 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; 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) else if (op == COUNT_ALL)
{ {
startPosition = posFind + foundTextLen; startPosition = posFind + foundTextLen;

View File

@ -45,6 +45,7 @@ const int REPLACE_ALL = 0;
const int MARK_ALL = 1; const int MARK_ALL = 1;
const int COUNT_ALL = 2; const int COUNT_ALL = 2;
const int FIND_ALL = 3; const int FIND_ALL = 3;
const int MARK_ALL_2 = 4;
const int DISPLAY_POS_TOP = 2; const int DISPLAY_POS_TOP = 2;
const int DISPLAY_POS_MIDDLE = 1; const int DISPLAY_POS_MIDDLE = 1;
@ -223,6 +224,8 @@ public :
bool processReplace(); bool processReplace();
int markAll(const char *str2find); 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); int processAll(int op, bool isEntire = false, const char *dir2search = NULL, const char *str2find = NULL);
void replaceAllInOpenedDocs(); void replaceAllInOpenedDocs();
void findAllIn(InWhat op); void findAllIn(InWhat op);

View File

@ -624,6 +624,13 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE); int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE);
if (iFind != -1) 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); Style & styleFind = stylers.getStyler(iFind);
setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);

View File

@ -109,6 +109,7 @@
//For All lexer //For All lexer
#define SCE_UNIVERSAL_SELECT_STYLE 30 #define SCE_UNIVERSAL_SELECT_STYLE 30
#define SCE_UNIVERSAL_FOUND_STYLE 31 #define SCE_UNIVERSAL_FOUND_STYLE 31
#define SCE_UNIVERSAL_FOUND_STYLE_2 29
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
#define SCE_P_NUMBER 2 #define SCE_P_NUMBER 2