mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-12 06:12:46 -06:00
theide: Fix of syntax highlighting of namespace
git-svn-id: svn://ultimatepp.org/upp/trunk@1207 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6195905f5b
commit
b8638d7b37
3 changed files with 37 additions and 19 deletions
|
|
@ -1,4 +1,4 @@
|
|||
description "The source files edit, derived from CtrlLib's LineEdit";
|
||||
description "The source files edit, derived from CtrlLib's LineEdit\377";
|
||||
|
||||
optimize_speed;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ uses
|
|||
file
|
||||
CodeEditor.h,
|
||||
hl_color.i,
|
||||
Syntax.cpp,
|
||||
EditorBar.cpp,
|
||||
Syntax.cpp,
|
||||
Highlight.cpp,
|
||||
FindReplace.cpp,
|
||||
Lang.cpp,
|
||||
|
|
|
|||
|
|
@ -251,12 +251,12 @@ void CodeEditor::InitKeywords()
|
|||
if(keyword[0].GetCount() == 0)
|
||||
{
|
||||
static const char *cpp[] = {
|
||||
"__asm", "else", "struct",
|
||||
"namespace", "__asm", "else", "struct",
|
||||
"enum", "switch", "auto", "__except", "template",
|
||||
"explicit", "this",
|
||||
"bool", "extern", "mutable", "thread",
|
||||
"break", "false", "throw",
|
||||
"case", "__fastcall", "namespace", "true",
|
||||
"case", "__fastcall", "true",
|
||||
"catch", "__finally", "new", "try",
|
||||
"__cdecl", "float", "__try",
|
||||
"char", "for", "operator", "typedef",
|
||||
|
|
@ -493,10 +493,15 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
}
|
||||
else
|
||||
if(*p == '{') {
|
||||
ss.brk.Add('}');
|
||||
ss.brk.Add(ss.was_namespace ? 0 : '}');
|
||||
Bracket(int(p - text) + pos, hls);
|
||||
hls.Put(hl_style[INK_PAR0 + max(ss.cl++, 0) % 4]);
|
||||
++block_level;
|
||||
hls.Put(hl_style[INK_PAR0 + max(ss.cl, 0) % 4]);
|
||||
if(ss.was_namespace)
|
||||
ss.was_namespace = false;
|
||||
else {
|
||||
++block_level;
|
||||
++ss.cl;
|
||||
}
|
||||
if(hls.pos < text.GetCount())
|
||||
hls.SetPaper(hls.pos, text.GetCount() - hls.pos + 1, BlockColor(block_level));
|
||||
p++;
|
||||
|
|
@ -510,17 +515,21 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
}
|
||||
else
|
||||
if(*p == ')' || *p == '}' || *p == ']') {
|
||||
if(*p == '}' && hilite_scope && block_level > 0)
|
||||
int bl = ss.brk.GetCount();
|
||||
int bc = bl ? ss.brk.Pop() : 0;
|
||||
if(*p == '}' && hilite_scope && block_level > 0 && bc)
|
||||
hls.SetPaper(hls.pos, text.GetLength() + 1 - hls.pos, BlockColor(--block_level));
|
||||
Bracket(int(p - text) + pos, hls);
|
||||
int& l = *p == ')' ? ss.pl : *p == '}' ? ss.cl : ss.bl;
|
||||
if(ss.brk.IsEmpty() || ss.brk.Pop() != *p || l <= 0) {
|
||||
if(bl == 0 || bc && (bc != *p || l <= 0) || !bc && *p != '}') {
|
||||
hls.Put(p == ~text ? hl_style[INK_PAR0] : hl_style[INK_ERROR]);
|
||||
ss.brk.Clear();
|
||||
ss.cl = ss.bl = ss.pl = 0;
|
||||
}
|
||||
else
|
||||
hls.Put(1, hl_style[INK_PAR0 + --l % 4]);
|
||||
else {
|
||||
if(bc) --l;
|
||||
hls.Put(1, hl_style[INK_PAR0 + l % 4]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else
|
||||
|
|
@ -580,7 +589,8 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
id.Cat(*q++);
|
||||
String iid = id;
|
||||
int uq = kw_upp.Find(iid);
|
||||
hls.Put(int(q - p), keyword[highlight].Find(iid) >= 0 ? hl_style[INK_KEYWORD] :
|
||||
int nq;
|
||||
hls.Put(int(q - p), (nq = keyword[highlight].Find(iid)) >= 0 ? hl_style[INK_KEYWORD] :
|
||||
name[highlight].Find(iid) >= 0 ? hl_style[INK_UPP] :
|
||||
uq >= 0 ? uq < kw_macros ? hl_style[INK_UPPMACROS] :
|
||||
uq < kw_logs ? hl_style[INK_UPPLOGS] :
|
||||
|
|
@ -590,8 +600,12 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
IsUpperString(iid) && !sm.macro ? hl_style[INK_UPPER] :
|
||||
hl_style[INK_NORMAL]);
|
||||
p = q;
|
||||
if(nq == 0)
|
||||
ss.was_namespace = true;
|
||||
}
|
||||
else {
|
||||
if(*p == ';')
|
||||
ss.was_namespace = false;
|
||||
hls.Put(strchr("!+-*^/%~&|=[]:?<>.", *p) ? hl_style[INK_OPERATOR] : hl_style[INK_NORMAL]);
|
||||
p++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,27 +258,31 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e)
|
|||
}
|
||||
else
|
||||
if(c == '{') {
|
||||
if(was_namespace)
|
||||
if(was_namespace) {
|
||||
brk.Add(0);
|
||||
was_namespace = false;
|
||||
}
|
||||
else {
|
||||
cl++;
|
||||
brk.Add('}');
|
||||
blk.Add() = line;
|
||||
bid.Add(lindent + 1);
|
||||
stmtline = -1;
|
||||
par.Clear();
|
||||
}
|
||||
blk.Add() = line;
|
||||
stmtline = -1;
|
||||
par.Clear();
|
||||
}
|
||||
else
|
||||
if(c == '}') {
|
||||
if(brk.GetCount()) {
|
||||
cl--;
|
||||
if(brk.Top() == '}') {
|
||||
cl--;
|
||||
if(bid.GetCount() > 1)
|
||||
bid.Drop();
|
||||
}
|
||||
brk.Drop();
|
||||
}
|
||||
if(blk.GetCount())
|
||||
blk.Drop();
|
||||
if(bid.GetCount() > 1)
|
||||
bid.Drop();
|
||||
stmtline = -1;
|
||||
par.Clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue