From 3e7c3f1a5fd72874b925e4a57856476efb1a2c61 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 28 Aug 2011 17:13:36 +0000 Subject: [PATCH] ide: CodeEditor now regards accented characters as ID letters git-svn-id: svn://ultimatepp.org/upp/trunk@3793 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/CodeEditor.cpp | 32 +++++++++++++++---------------- uppsrc/CodeEditor/CodeEditor.h | 1 + uppsrc/CodeEditor/FindReplace.cpp | 10 +++++----- uppsrc/CodeEditor/Highlight.cpp | 2 +- uppsrc/CodeEditor/Syntax.cpp | 10 +++++----- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 767433b96..f3a2644dd 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -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; } diff --git a/uppsrc/CodeEditor/CodeEditor.h b/uppsrc/CodeEditor/CodeEditor.h index a8dcbfdce..66c5d0070 100644 --- a/uppsrc/CodeEditor/CodeEditor.h +++ b/uppsrc/CodeEditor/CodeEditor.h @@ -148,6 +148,7 @@ Array GetLineIdent(const char *line); Vector 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); } diff --git a/uppsrc/CodeEditor/FindReplace.cpp b/uppsrc/CodeEditor/FindReplace.cpp index 932c89201..8a2c41f0d 100644 --- a/uppsrc/CodeEditor/FindReplace.cpp +++ b/uppsrc/CodeEditor/FindReplace.cpp @@ -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)); diff --git a/uppsrc/CodeEditor/Highlight.cpp b/uppsrc/CodeEditor/Highlight.cpp index 6df0733f5..9082f167e 100644 --- a/uppsrc/CodeEditor/Highlight.cpp +++ b/uppsrc/CodeEditor/Highlight.cpp @@ -634,7 +634,7 @@ void CodeEditor::HighlightLine(int line, Vector& 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) diff --git a/uppsrc/CodeEditor/Syntax.cpp b/uppsrc/CodeEditor/Syntax.cpp index 819159500..89fc2f682 100644 --- a/uppsrc/CodeEditor/Syntax.cpp +++ b/uppsrc/CodeEditor/Syntax.cpp @@ -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; }