mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ide: Log syntax highlighting now highlights 0x and 0b numbers
git-svn-id: svn://ultimatepp.org/upp/trunk@14553 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d55f46cbe8
commit
e0208d3590
3 changed files with 25 additions and 20 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<String> rws, sws;
|
||||
ONCELOCK {
|
||||
rws << "error" << "errors" << "warning" << "warnings" << "warn" << "failed" << "exit"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue