ide: Global highlighting of selection IDs improved

git-svn-id: svn://ultimatepp.org/upp/trunk@7432 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-06-10 06:39:40 +00:00
parent c1c98e07d9
commit 1e50ea640b
6 changed files with 33 additions and 33 deletions

View file

@ -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<LineEdit::Highlight>& 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;
}
}
}

View file

@ -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;
}
}

View file

@ -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

View file

@ -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

View file

@ -564,6 +564,7 @@ void TextCtrl::Redo() {
void TextCtrl::ClearSelection() {
anchor = -1;
Refresh();
SelectionChanged();
WhenSel();
}

View file

@ -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); }