diff --git a/uppsrc/CodeEditor/CHighlight.cpp b/uppsrc/CodeEditor/CHighlight.cpp index 402e4e25d..ceb2674f5 100644 --- a/uppsrc/CodeEditor/CHighlight.cpp +++ b/uppsrc/CodeEditor/CHighlight.cpp @@ -91,6 +91,21 @@ const wchar *HighlightNumber(HighlightOutput& hls, const wchar *p, bool ts, bool return p; } +const wchar *HighlightHexBin(HighlightOutput& hls, const wchar *p, int plen, bool thousands_separator) +{ + hls.Put(plen, HighlightSetup::hl_style[HighlightSetup::INK_CONST_HEX]); + p += plen; + const wchar *t = p; + while(IsXDigit(*p)) + p++; + int n = int(p - t); + for(int i = 0; i < n; i++) { + hls.Put(HighlightSetup::hl_style[HighlightSetup::INK_CONST_HEX], + thousands_separator && ((n - i) & 1) ? LineEdit::SHIFT_L : 0); + } + return p; +} + const wchar *CSyntax::DoComment(HighlightOutput& hls, const wchar *p, const wchar *e) { WString w; @@ -333,19 +348,8 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls p++; } else - if(highlight == HIGHLIGHT_CSS ? *p == '#' : findarg(pair, MAKELONG('0', 'x'), MAKELONG('0', 'X'), MAKELONG('0', 'b'), MAKELONG('0', 'B')) >= 0) { - int pn = 1 + (highlight != HIGHLIGHT_CSS); - hls.Put(pn, hl_style[INK_CONST_HEX]); - p += pn; - const wchar *t = p; - while(IsXDigit(*p)) - p++; - int n = int(p - t); - for(int i = 0; i < n; i++) { - hls.Put(hl_style[INK_CONST_HEX], - thousands_separator && ((n - i) & 1) ? LineEdit::SHIFT_L : 0); - } - } + if(highlight == HIGHLIGHT_CSS ? *p == '#' : findarg(pair, MAKELONG('0', 'x'), MAKELONG('0', 'X'), MAKELONG('0', 'b'), MAKELONG('0', 'B')) >= 0) + p = HighlightHexBin(hls, p, 1 + (highlight != HIGHLIGHT_CSS), thousands_separator); else if(IsDigit(*p)) p = HighlightNumber(hls, p, thousands_separator, *p == '0', highlight == HIGHLIGHT_CSS); diff --git a/uppsrc/CodeEditor/CSyntax.h b/uppsrc/CodeEditor/CSyntax.h index 364836cc9..76b0f82c8 100644 --- a/uppsrc/CodeEditor/CSyntax.h +++ b/uppsrc/CodeEditor/CSyntax.h @@ -85,3 +85,4 @@ public: }; const wchar *HighlightNumber(HighlightOutput& hls, const wchar *p, bool ts, bool octal, bool css); +const wchar *HighlightHexBin(HighlightOutput& hls, const wchar *p, int plen, bool thousands_separator); diff --git a/uppsrc/CodeEditor/LogSyntax.cpp b/uppsrc/CodeEditor/LogSyntax.cpp index 299520157..491a32a92 100644 --- a/uppsrc/CodeEditor/LogSyntax.cpp +++ b/uppsrc/CodeEditor/LogSyntax.cpp @@ -21,16 +21,17 @@ void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls bool sep_line = false; while(s < end) { int c = *s; - if(s + 3 <= end && (Is3(s, '-') || Is3(s, '*') || Is3(s, '=') || Is3(s, '+') || - Is3(s, '#') || Is3(s, ':') || Is3(s, '%') || Is3(s, '$'))) + dword pair = MAKELONG(s[0], s[1]); + #define P2(x) MAKELONG(x, x) + if(s + 3 <= end && findarg(pair, P2('-'), P2('*'), P2('='), P2('+'), P2('#'), P2(':'), P2('%'), P2('$')) >= 0 && s[2] == c) sep_line = true; - if(IsDigit(c)) { - LTIMING("A"); + if(findarg(pair, MAKELONG('0', 'x'), MAKELONG('0', 'X'), MAKELONG('0', 'b'), MAKELONG('0', 'B')) >= 0) + s = HighlightHexBin(hls, s, 2, thousands_separator); + else + if(IsDigit(c)) s = HighlightNumber(hls, s, thousands_separator, false, false); - } else if(c == '\'' || c == '\"') { - LTIMING("B"); const wchar *s0 = s; s++; for(;;) { @@ -45,7 +46,6 @@ void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls } else if(IsAlpha(c) || c == '_') { - LTIMING("C"); static Index rws, sws; ONCELOCK { rws << "error" << "errors" << "warning" << "warnings" << "warn" << "failed" << "exit"