Skip to content

Commit

Permalink
CodeEditor: Fixed 1u literal highlighting
Browse files Browse the repository at this point in the history
git-svn-id: svn://ultimatepp.org/upp/trunk@10708 f0d560ea-af0d-0410-9eb7-867de7ffcac7
  • Loading branch information
cxl committed Jan 15, 2017
1 parent b97af94 commit 24c46ca
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions uppsrc/CodeEditor/CHighlight.cpp
Expand Up @@ -65,13 +65,14 @@ const wchar *HighlightNumber(HighlightOutput& hls, const wchar *p, bool ts, bool
if(*p == 'e' || *p == 'E') {
c = HighlightSetup::INK_CONST_FLOAT;
p++;
}
if(c == HighlightSetup::INK_CONST_FLOAT) {
p += *p == '-' || *p == '+';
while(IsDigit(*p)) p++;
if(*p == 'f' || *p == 'F')
p++;
}
else
if(*p == 'u' && c != HighlightSetup::INK_CONST_FLOAT)
p++;
if(c == HighlightSetup::INK_CONST_OCT && p - t == 1)
c = HighlightSetup::INK_CONST_INT;
int n = int(p - t);
Expand Down Expand Up @@ -194,37 +195,42 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls
int lbrace = -1;
int lbclose = -1;
Color lbcolor = Null;
bool is_comment = false;
while(p < e) {
int pair = MAKELONG(p[0], p[1]);
if(linecomment && linecont || pair == MAKELONG('/', '/') &&
highlight != HIGHLIGHT_CSS && highlight != HIGHLIGHT_JSON ||
highlight == HIGHLIGHT_PHP && *p == '#') {
if(pair == MAKELONG('/', '*') && highlight != HIGHLIGHT_JSON || comment) {
if(!comment) {
hls.Put(2, hl_style[INK_COMMENT]);
p += 2;
}
for(const wchar *ce = p; ce < e - 1; ce++)
if(ce[0] == '*' && ce[1] == '/') {
while(p < ce)
p = DoComment(hls, p, ce);
hls.Put(2, hl_style[INK_COMMENT]);
p += 2;
comment = false;
goto comment_ended;
}
while(p < e)
p = DoComment(hls, p, e);
comment = true;
comment = is_comment = true;
break;
comment_ended:;
}
else
if(comment && highlight != HIGHLIGHT_JSON) {
if(pair == MAKELONG('*', '/')) {
hls.Put(2, hl_style[INK_COMMENT]);
p += 2;
comment = false;
}
else
if(linecomment && linecont || pair == MAKELONG('/', '/') &&
highlight != HIGHLIGHT_CSS && highlight != HIGHLIGHT_JSON ||
highlight == HIGHLIGHT_PHP && *p == '#') {
while(p < e)
p = DoComment(hls, p, e);
is_comment = true;
break;
}
else
if((*p == '\"' || *p == '\'') || linecont && string)
p = hls.CString(p);
else
if(pair == MAKELONG('/', '*') && highlight != HIGHLIGHT_JSON) {
hls.Put(2, hl_style[INK_COMMENT]);
p += 2;
comment = true;
comment = true;
}
else
if(*p == '(') {
brk.Add(')');
Bracket(int(p - ltext) + pos, hls, editor);
Expand Down Expand Up @@ -341,7 +347,7 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls
p++;
}
}
if(hilite_ifdef && !IsNull(cppid) && !comment) {
if(hilite_ifdef && !IsNull(cppid) && !is_comment) {
if((cppid == "else" || cppid == "elif" || cppid == "endif") && !ifstack.IsEmpty()) {
WStringBuffer ifln;
ifln.Cat(" // ");
Expand Down

0 comments on commit 24c46ca

Please sign in to comment.