ide: CodeEditor now regards accented characters as ID letters

git-svn-id: svn://ultimatepp.org/upp/trunk@3793 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-08-28 17:13:36 +00:00
parent fa1116fe3f
commit 3e7c3f1a5f
5 changed files with 28 additions and 27 deletions

View file

@ -189,12 +189,12 @@ void CodeEditor::CheckRightBracket(int pos)
void CodeEditor::CopyWord() {
int p = GetCursor();
if(iscid(GetChar(p)) || (p > 0 && iscid(GetChar(--p)))) {
if(iscidl(GetChar(p)) || (p > 0 && iscidl(GetChar(--p)))) {
int e = GetLength();
int f = p;
while(--p >= 0 && iscid(GetChar(p)));
while(--p >= 0 && iscidl(GetChar(p)));
++p;
while(++f < e && iscid(GetChar(f)));
while(++f < e && iscidl(GetChar(f)));
WString txt = GetW(p, f - p);
WriteClipboardUnicodeText(txt);
AppendClipboardText(txt.ToString());
@ -415,20 +415,20 @@ void CodeEditor::MakeTabsOrSpaces(bool maketabs) {
void CodeEditor::MoveNextWord(bool sel) {
int p = GetCursor();
int e = GetLength();
if(iscid(GetChar(p)))
while(p < e && iscid(GetChar(p))) p++;
if(iscidl(GetChar(p)))
while(p < e && iscidl(GetChar(p))) p++;
else
while(p < e && !iscid(GetChar(p))) p++;
while(p < e && !iscidl(GetChar(p))) p++;
PlaceCaret(p, sel);
}
void CodeEditor::MovePrevWord(bool sel) {
int p = GetCursor();
if(p == 0) return;
if(iscid(GetChar(p - 1)))
while(p > 0 && iscid(GetChar(p - 1))) p--;
if(iscidl(GetChar(p - 1)))
while(p > 0 && iscidl(GetChar(p - 1))) p--;
else
while(p > 0 && !iscid(GetChar(p - 1))) p--;
while(p > 0 && !iscidl(GetChar(p - 1))) p--;
PlaceCaret(p, sel);
}
@ -482,8 +482,8 @@ void CodeEditor::DeleteWord() {
int p = GetCursor();
int e = GetLength();
int c = GetChar(p);
if(iscid(c))
while(p < e && iscid(GetChar(p))) p++;
if(iscidl(c))
while(p < e && iscidl(GetChar(p))) p++;
else
if(isspctab(c))
while(p < e && isspctab(GetChar(p))) p++;
@ -499,8 +499,8 @@ void CodeEditor::DeleteWordBack() {
int p = GetCursor();
if(p < 1) return;
int c = GetChar(p - 1);
if(iscid(GetChar(p - 1)))
while(p > 1 && iscid(GetChar(p - 1))) p--;
if(iscidl(GetChar(p - 1)))
while(p > 1 && iscidl(GetChar(p - 1))) p--;
else
if(isspctab(c))
while(p > 1 && isspctab(GetChar(p - 1))) p--;
@ -551,9 +551,9 @@ void CodeEditor::TabLeft() {
bool CodeEditor::GetWordPos(int pos, int& l, int& h) {
l = h = pos;
if(!iscid(GetChar(pos))) return false;
while(l > 0 && iscid(GetChar(l - 1))) l--;
while(iscid(GetChar(h))) h++;
if(!iscidl(GetChar(pos))) return false;
while(l > 0 && iscidl(GetChar(l - 1))) l--;
while(iscidl(GetChar(h))) h++;
return true;
}

View file

@ -148,6 +148,7 @@ Array<IdentPos> GetLineIdent(const char *line);
Vector<Point> GetLineString(const wchar *wline, bool& is_begin, bool& is_end);
inline int CharFilterCIdent(int i) { return IsAlNum(i) || i == '_' ? i : 0; }
inline bool iscidl(int c) { return iscid(c) || IsLetter(c); }
inline bool islbrkt(int c) { return c == '{' || c == '[' || c == '('; }
inline bool isrbrkt(int c) { return c == '}' || c == ']' || c == ')'; }
inline bool isbrkt(int c) { return islbrkt(c) || isrbrkt(c); }

View file

@ -94,7 +94,7 @@ int CodeEditor::Match(const wchar *f, const wchar *s, int line, bool we, bool ig
const wchar *wb = s;
if(!iscib(*s)) return -1;
s++;
while(iscid(*s)) s++;
while(iscidl(*s)) s++;
SetFound(fi++, WILDID, WString(wb, s));
}
else
@ -110,7 +110,7 @@ int CodeEditor::Match(const wchar *f, const wchar *s, int line, bool we, bool ig
}
f++;
}
return we && iscid(*s) ? -1 : int(s - b) + n;
return we && iscidl(*s) ? -1 : int(s - b) + n;
}
bool CodeEditor::Find(bool back, const wchar *text, bool wholeword, bool ignorecase,
@ -149,8 +149,8 @@ bool CodeEditor::Find(bool back, const wchar *text, bool wholeword, bool ignorec
if(ft.IsEmpty()) return false;
if(notfoundfw) MoveTextBegin();
if(notfoundbk) MoveTextEnd();
bool wb = wholeword ? iscid(*ft) : false;
bool we = wholeword ? iscid(*ft.Last()) : false;
bool wb = wholeword ? iscidl(*ft) : false;
bool we = wholeword ? iscidl(*ft.Last()) : false;
int cursor, pos;
if(found)
GetSelection(pos, cursor);
@ -164,7 +164,7 @@ bool CodeEditor::Find(bool back, const wchar *text, bool wholeword, bool ignorec
s = l + pos;
for(;;) {
for(;;) {
if(!wb || (s == l || !iscid(s[-1]))) {
if(!wb || (s == l || !iscidl(s[-1]))) {
int n = Match(ft, s, line, we, ignorecase);
if(n >= 0) {
int pos = GetPos(line, int(s - l));

View file

@ -634,7 +634,7 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
if(iscib(*p)) {
const wchar *q = p;
StringBuffer id;
while(iscid(*q) && q < e)
while(iscidl(*q) && q < e)
id.Cat(*q++);
String iid = id;
if(highlight == HIGHLIGHT_SQL)

View file

@ -55,7 +55,7 @@ const wchar *isstmt(const wchar *p) {
const wchar *s = p;
for(;;) {
if(*k== '\0') {
if(!iscid(*s)) return s;
if(!iscidl(*s)) return s;
break;
}
if(*s != *k)
@ -142,7 +142,7 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e)
while(++p < e && (*p == ' ' || *p == '\t'))
p++;
const wchar *id = p;
while(p < e && iscid(*p))
while(p < e && iscidl(*p))
p++;
int idlen = int(p - id);
if(id[0] == 'i' && id[1] == 'f'
@ -226,16 +226,16 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e)
for(;;) {
if(p >= e) return;
const wchar *pp;
if(!iscid(pc) && (pp = isstmt(p)) != NULL) {
if(!iscidl(pc) && (pp = isstmt(p)) != NULL) {
stmtline = line;
spar = 0;
pc = 0;
p = pp;
}
else
if(!iscid(pc) && p[0] == 'n' && p[1] == 'a' && p[2] == 'm' && p[3] == 'e' &&
if(!iscidl(pc) && p[0] == 'n' && p[1] == 'a' && p[2] == 'm' && p[3] == 'e' &&
p[4] == 's' && p[5] == 'p' && p[6] == 'a' && p[7] == 'c' && p[8] == 'e' &&
!iscid(p[9])) {
!iscidl(p[9])) {
was_namespace = true;
p += 9;
}