From 64b83139c742ac96770505eefe56f59d43cc6790 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 10 Apr 2015 23:38:29 +0200 Subject: [PATCH] + fix highlighting of words with numbers --- src/Mod/Fem/Gui/AbaqusHighlighter.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/Gui/AbaqusHighlighter.cpp b/src/Mod/Fem/Gui/AbaqusHighlighter.cpp index 62a7caee4c26..93fa63aed38f 100644 --- a/src/Mod/Fem/Gui/AbaqusHighlighter.cpp +++ b/src/Mod/Fem/Gui/AbaqusHighlighter.cpp @@ -49,7 +49,7 @@ void AbaqusHighlighter::highlightBlock(const QString &text) // Find a syntax file for the Abaqus format here // http://notepad-plus.sourceforge.net/commun/userDefinedLang/userDefineLang_Abaqus.xml // - enum { NormalState = -1, Definition, BeforeKey, InideKey, BeforeValue, InsideValue, Number }; + enum { NormalState = -1, Definition, BeforeKey, InideKey, BeforeValue, InsideValue, Text, Number }; int state = NormalState; int start = 0; @@ -112,7 +112,7 @@ void AbaqusHighlighter::highlightBlock(const QString &text) } // Number else if (state == Number) { - if (!text[i].isNumber()) { + if (!text[i].isNumber() && text[i] != QLatin1Char('.')) { QTextCharFormat numberFormat; numberFormat.setForeground(numberColor); setFormat(start, i - start, numberFormat); @@ -121,7 +121,7 @@ void AbaqusHighlighter::highlightBlock(const QString &text) state = NormalState; } } - else if (text[i].isNumber()) { + else if (text[i].isNumber() || text[i] == QLatin1Char('-')) { if (state == NormalState) { start = i; state = Number; @@ -140,6 +140,15 @@ void AbaqusHighlighter::highlightBlock(const QString &text) start = i; state = Definition; } + else if (text[i].isLetterOrNumber()) { + if (state == NormalState) { + start = i; + state = Text; + } + } + else { + state = NormalState; + } } if (state == Definition) {