From 59e387aad83aabbd678644b174dc17e48ff1686d Mon Sep 17 00:00:00 2001 From: jogo- Date: Fri, 2 Jul 2021 15:32:37 +0200 Subject: [PATCH] Update jsedit.cpp * Highlight hexadecimal numbers --- jsedit.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jsedit.cpp b/jsedit.cpp index 99aabd8..4784219 100644 --- a/jsedit.cpp +++ b/jsedit.cpp @@ -266,7 +266,8 @@ void JSHighlighter::highlightBlock(const QString &text) Identifier = 2, String = 3, Comment = 4, - Regex = 5 + Regex = 5, + HexNumber = 6 }; QList bracketPositions; @@ -291,6 +292,10 @@ void JSHighlighter::highlightBlock(const QString &text) start = i; if (ch.isSpace()) { ++i; + } else if (ch == '0' && (next == 'x' || next == 'X')) { + ++i; + ++i; + state = HexNumber; } else if (ch.isDigit()) { ++i; state = Number; @@ -334,6 +339,15 @@ void JSHighlighter::highlightBlock(const QString &text) } break; + case HexNumber: + if (ch.isSpace() || !(ch.isDigit() || QString("ABCDEF").contains(ch.toUpper()))) { + setFormat(start, i - start, m_colors[JSEdit::Number]); + state = Start; + } else { + ++i; + } + break; + case Identifier: if (ch.isSpace() || !(ch.isDigit() || ch.isLetter() || ch == '_')) { QString token = text.mid(start, i - start).trimmed();