[NEW_FEATURE] Smart HighLighting uses indicator instead of style.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@174 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-04-21 20:05:02 +00:00
parent 52ebeee049
commit 4a6ca982e1
7 changed files with 63 additions and 15 deletions

View File

@ -130,7 +130,6 @@ public:
private: private:
NppData _nppData; NppData _nppData;
HMENU _hPluginsMenu; HMENU _hPluginsMenu;
vector<PluginInfo *> _pluginInfos; vector<PluginInfo *> _pluginInfos;

View File

@ -8248,7 +8248,7 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
return true; return true;
} }
/*
void Notepad_plus::markSelectedText() void Notepad_plus::markSelectedText()
{ {
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
@ -8283,7 +8283,39 @@ void Notepad_plus::markSelectedText()
op._isWholeWord = false; op._isWholeWord = false;
_findReplaceDlg.markAll2(text2Find); _findReplaceDlg.markAll2(text2Find);
} }
*/
void Notepad_plus::markSelectedText()
{
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
if (!nppGUI._enableSmartHilite)
return;
//Get selection
CharacterRange range = _pEditView->getSelection();
//Dont mark if the selection has not changed.
if (range.cpMin == _prevSelectedRange.cpMin && range.cpMax == _prevSelectedRange.cpMax)
{
return;
}
_prevSelectedRange = range;
//Clear marks
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_2);
//If nothing selected, dont mark anything
if (range.cpMin == range.cpMax)
{
return;
}
char text2Find[MAX_PATH];
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
FindOption op;
op._isWholeWord = false;
_findReplaceDlg.markAll2(text2Find);
}
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);

View File

@ -939,10 +939,6 @@ 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()));
@ -1009,9 +1005,9 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons
} }
else if (op == MARK_ALL_2) else if (op == MARK_ALL_2)
{ {
(*_ppEditView)->execute(SCI_STARTSTYLING, start, STYLING_MASK); (*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
(*_ppEditView)->execute(SCI_SETSTYLING, end - start, SCE_UNIVERSAL_FOUND_STYLE_2); (*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
(*_ppEditView)->execute(SCI_COLOURISE, start, end+1);
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen; startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
} }
else if (op == COUNT_ALL) else if (op == COUNT_ALL)

View File

@ -110,6 +110,10 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
execute(SCI_SETFOLDFLAGS, 16); execute(SCI_SETFOLDFLAGS, 16);
execute(SCI_SETSCROLLWIDTHTRACKING, true); execute(SCI_SETSCROLLWIDTHTRACKING, true);
// smart hilighting
execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_2, INDIC_ROUNDBOX);
execute(SCI_INDICSETFORE, SCE_UNIVERSAL_FOUND_STYLE_2, blue);
_pParameter = NppParameters::getInstance(); _pParameter = NppParameters::getInstance();
_codepage = ::GetACP(); _codepage = ::GetACP();
@ -191,6 +195,14 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
} }
return _callWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam); return _callWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam);
} }
void ScintillaEditView::setSpecialIndicator(Style & styleToSet)
{
//execute(SCI_INDICSETSTYLE, styleToSet._styleID, INDIC_ROUNDBOX);
execute(SCI_INDICSETFORE, styleToSet._styleID, styleToSet._bgColor);
}
void ScintillaEditView::setSpecialStyle(Style & styleToSet) void ScintillaEditView::setSpecialStyle(Style & styleToSet)
{ {
int styleID = styleToSet._styleID; int styleID = styleToSet._styleID;
@ -655,7 +667,8 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
if (iFind != -1) if (iFind != -1)
{ {
Style & styleFind = stylers.getStyler(iFind); Style & styleFind = stylers.getStyler(iFind);
setSpecialStyle(styleFind); //setSpecialStyle(styleFind);
setSpecialIndicator(styleFind);
} }
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE); iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE);

View File

@ -669,6 +669,14 @@ protected:
void setStyle(Style styleToSet); //NOT by reference (style edited) void setStyle(Style styleToSet); //NOT by reference (style edited)
void setSpecialStyle(Style & styleToSet); //by reference void setSpecialStyle(Style & styleToSet); //by reference
void setSpecialIndicator(Style & styleToSet);
void clearIndicator(int indicatorNumber) {
int docStart = 0;
int docEnd = getCurrentDocLen();
execute(SCI_SETINDICATORCURRENT, indicatorNumber);
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
};
void setCppLexer(LangType type); void setCppLexer(LangType type);
void setXmlLexer(LangType type); void setXmlLexer(LangType type);
void setUserLexer(); void setUserLexer();

View File

@ -35,7 +35,7 @@ const COLORREF darkBlue = RGB(0, 0, 0x80);
const COLORREF blue = RGB(0, 0, 0xFF); const COLORREF blue = RGB(0, 0, 0xFF);
const COLORREF black = RGB(0, 0, 0); const COLORREF black = RGB(0, 0, 0);
const COLORREF white = RGB(0xFF, 0xFF, 0xFF); const COLORREF white = RGB(0xFF, 0xFF, 0xFF);
const COLORREF darkGrey = RGB(64, 64, 64); const COLORREF darkGrey = RGB(64, 64, 64);
const COLORREF grey = RGB(128, 128, 128); const COLORREF grey = RGB(128, 128, 128);
const COLORREF liteGrey = RGB(192, 192, 192); const COLORREF liteGrey = RGB(192, 192, 192);
const COLORREF veryLiteGrey = RGB(224, 224, 224); const COLORREF veryLiteGrey = RGB(224, 224, 224);

View File

@ -576,10 +576,6 @@
RelativePath="..\src\MISC\RegExt\regExtDlgRc.h" RelativePath="..\src\MISC\RegExt\regExtDlgRc.h"
> >
</File> </File>
<File
RelativePath="..\src\resource.h"
>
</File>
<File <File
RelativePath="..\src\WinControls\Preference\resource.h" RelativePath="..\src\WinControls\Preference\resource.h"
> >
@ -588,6 +584,10 @@
RelativePath="..\src\MISC\RegExt\resource.h" RelativePath="..\src\MISC\RegExt\resource.h"
> >
</File> </File>
<File
RelativePath="..\src\resource.h"
>
</File>
<File <File
RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h" RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h"
> >