From 1e50ea640bfc60eb8bc1fc3158ea990b257e08ff Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 10 Jun 2014 06:39:40 +0000 Subject: [PATCH] ide: Global highlighting of selection IDs improved git-svn-id: svn://ultimatepp.org/upp/trunk@7432 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/CodeEditor.cpp | 45 ++++++++++++++++++++----------- uppsrc/CodeEditor/FindReplace.cpp | 14 ---------- uppsrc/CodeEditor/Style.cpp | 2 +- uppsrc/CodeEditor/init | 2 +- uppsrc/CtrlLib/Text.cpp | 1 + uppsrc/CtrlLib/TextEdit.h | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 8d9c03d69..024439d85 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -213,10 +213,25 @@ void CodeEditor::Periodic() void CodeEditor::SelectionChanged() { - if(selword.GetCount()) { - Refresh(); - selword.Clear(); + int l, h; + WString nselword; + if(GetSelection(l, h) && h - l < 128 && + (l == 0 || !iscid(GetChar(l - 1))) && + (h >= GetLength() || !iscid(GetChar(h)))) { + for(int i = l; i < h; i++) { + int c = GetChar(i); + if(!iscid(c)) { + nselword.Clear(); + break; + } + nselword.Cat(c); + } } + if(selword != nselword) { + selword = nselword; + Refresh(); + } + DDUMP(foundsel); if(!foundsel) { CloseFindReplace(); found = false; @@ -512,13 +527,8 @@ String CodeEditor::GetWord() void CodeEditor::LeftDouble(Point p, dword keyflags) { int l, h; int pos = GetMousePos(p); - if(GetWordPos(pos, l, h)) { + if(GetWordPos(pos, l, h)) SetSelection(l, h); - if(h - l < 50) { - selword = GetW(l, h - l); - Refresh(); - } - } else SetSelection(pos, pos + 1); } @@ -885,19 +895,22 @@ void CodeEditor::HighlightLine(int line, Vector& hl, int po HighlightOutput hls(hl); WString l = GetWLine(line); GetSyntax(line)->Highlight(l.Begin(), l.End(), hls, this, line, pos); + DLOG("HL " << selword); if(selword.GetCount()) { int q = 0; for(;;) { q = l.Find(selword, q); if(q < 0) break; - for(int i = 0; i < selword.GetCount() && i + q < hl.GetCount(); i++) { - const HlStyle& st = hl_style[PAPER_SELWORD]; - hl[i + q].paper = st.color; - if(st.bold) - hl[i + q].font.Bold(); - } - q += selword.GetCount(); + int h = q + selword.GetCount(); + if((q == 0 || !iscid(l[q - 1])) && (h >= l.GetCount() || !iscid(l[h]))) + for(int i = 0; i < selword.GetCount() && i + q < hl.GetCount(); i++) { + const HlStyle& st = hl_style[PAPER_SELWORD]; + hl[i + q].paper = st.color; + if(st.bold) + hl[i + q].font.Bold(); + } + q = h; } } } diff --git a/uppsrc/CodeEditor/FindReplace.cpp b/uppsrc/CodeEditor/FindReplace.cpp index 86c16a2aa..9df5f15f2 100644 --- a/uppsrc/CodeEditor/FindReplace.cpp +++ b/uppsrc/CodeEditor/FindReplace.cpp @@ -195,16 +195,6 @@ bool CodeEditor::FindFrom(int pos, bool back, const wchar *text, bool wholeword, SetSelection(pos, pos + n); foundsel = false; CenterCursor(); - if(!ignorecase) { - int n = 0; - for(const wchar *s = text; *s; s++) { - if(!iscid(*s) || ++n > 60) - goto no; - } - selword = text; - Refresh(); - } - no:; } foundpos = pos; foundsize = n; @@ -271,10 +261,6 @@ bool CodeEditor::Find(bool back, bool blockreplace, bool replace) } else { CloseFindReplace(); - if(selword.GetCount()) { - selword.Clear(); - Refresh(); - } return false; } } diff --git a/uppsrc/CodeEditor/Style.cpp b/uppsrc/CodeEditor/Style.cpp index ed79021b1..60c83accd 100644 --- a/uppsrc/CodeEditor/Style.cpp +++ b/uppsrc/CodeEditor/Style.cpp @@ -153,7 +153,7 @@ void HighlightSetup::DefaultHlStyles() SetHlStyle(PAPER_READONLY, SColorFace); SetHlStyle(PAPER_SELECTED, SColorHighlight); - SetHlStyle(PAPER_SELWORD, SColorInfo); + SetHlStyle(PAPER_SELWORD, Blend(SColorHighlight(), White(), 215)); } END_UPP_NAMESPACE diff --git a/uppsrc/CodeEditor/init b/uppsrc/CodeEditor/init index 10cfbc151..ed5b8df8a 100644 --- a/uppsrc/CodeEditor/init +++ b/uppsrc/CodeEditor/init @@ -1,7 +1,7 @@ #ifndef _CodeEditor_icpp_init_stub #define _CodeEditor_icpp_init_stub #include "CtrlLib/init" -#define BLITZ_INDEX__ Fd579c6629af5990c016d4bd1dc2b4c20 +#define BLITZ_INDEX__ Fa19bf999ba2b201492446aa335bd578e #include "CRegister.icpp" #undef BLITZ_INDEX__ #endif diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index 74f9342d9..c5dbabfb5 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -564,6 +564,7 @@ void TextCtrl::Redo() { void TextCtrl::ClearSelection() { anchor = -1; Refresh(); + SelectionChanged(); WhenSel(); } diff --git a/uppsrc/CtrlLib/TextEdit.h b/uppsrc/CtrlLib/TextEdit.h index 2bb199956..05269f674 100644 --- a/uppsrc/CtrlLib/TextEdit.h +++ b/uppsrc/CtrlLib/TextEdit.h @@ -147,7 +147,7 @@ public: WString GetSelectionW() const; void ClearSelection(); bool RemoveSelection(); - void SetCursor(int cursor) { PlaceCaret(cursor); } + void SetCursor(int cursor) { PlaceCaret(cursor); } int Paste(const WString& text); int Insert(int pos, const WString& txt) { return Insert(pos, txt, false); }