- minor changes to the syntax highlighting in GCode Editor

This commit is contained in:
Marius Stanciu
2020-12-22 05:00:00 +02:00
committed by Marius
parent b7c2bc8fbd
commit b2035aca34
2 changed files with 40 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta
- made sure that the GCode Editor does not have a misleading Cancel option when closing the tab - made sure that the GCode Editor does not have a misleading Cancel option when closing the tab
- made sure that some other part of the program outputs the log messages to the Tcl Shell if the Verbose Log options is set in Preferences - made sure that some other part of the program outputs the log messages to the Tcl Shell if the Verbose Log options is set in Preferences
- minor changes to the syntax highlighting in GCode Editor
20.12.2020 20.12.2020

View File

@@ -4360,13 +4360,51 @@ class FCTextAreaLineNumber(QtWidgets.QFrame):
brush = QtGui.QBrush(Qt.blue, Qt.SolidPattern) brush = QtGui.QBrush(Qt.blue, Qt.SolidPattern)
keyword.setForeground(brush) keyword.setForeground(brush)
keyword.setFontWeight(QtGui.QFont.Bold) keyword.setFontWeight(QtGui.QFont.Bold)
keywords = ["F", "G", "M", "T"] keywords = ["G", "T"]
for word in keywords: for word in keywords:
# pattern = QtCore.QRegExp("\\b" + word + "\\b") # pattern = QtCore.QRegExp("\\b" + word + "\\b")
pattern = QtCore.QRegExp("\\b" + word + "\d+(\.\d*)?\s?" + "\\b") pattern = QtCore.QRegExp("\\b" + word + "\d+(\.\d*)?\s?" + "\\b")
rule = (pattern, keyword) rule = (pattern, keyword)
self.highlightingRules.append(rule) self.highlightingRules.append(rule)
keyword1 = QtGui.QTextCharFormat()
# keyword 1
brush = QtGui.QBrush(QtGui.QColor("teal"), Qt.SolidPattern)
keyword1.setForeground(brush)
keyword1.setFontWeight(QtGui.QFont.Bold)
keywords = ["F"]
for word in keywords:
# pattern = QtCore.QRegExp("\\b" + word + "\\b")
pattern = QtCore.QRegExp("\\b" + word + "\d+(\.\d*)?\s?" + "\\b")
rule = (pattern, keyword1)
self.highlightingRules.append(rule)
# keyword 2
keyword2 = QtGui.QTextCharFormat()
# SVG colors: https://doc.qt.io/qt-5/qml-color.html#svg-color-reference
brush = QtGui.QBrush(QtGui.QColor("coral"), Qt.SolidPattern)
keyword2.setForeground(brush)
keyword2.setFontWeight(QtGui.QFont.Bold)
keywords = ["M"]
for word in keywords:
# pattern = QtCore.QRegExp("\\b" + word + "\\b")
pattern = QtCore.QRegExp("\\b" + word + "\d+(\.\d*)?\s?" + "\\b")
rule = (pattern, keyword2)
self.highlightingRules.append(rule)
# keyword 3
keyword3 = QtGui.QTextCharFormat()
# SVG colors: https://doc.qt.io/qt-5/qml-color.html#svg-color-reference
brush = QtGui.QBrush(QtGui.QColor("purple"), Qt.SolidPattern)
keyword3.setForeground(brush)
keyword3.setFontWeight(QtGui.QFont.Bold)
keywords = ["Z"]
for word in keywords:
# pattern = QtCore.QRegExp("\\b" + word + "\\b")
pattern = QtCore.QRegExp("\\b" + word + "[\-|\+]?\d+(\.\d*)?\s?" + "\\b")
rule = (pattern, keyword3)
self.highlightingRules.append(rule)
# reservedClasses # reservedClasses
reservedClasses.setForeground(brush) reservedClasses.setForeground(brush)
reservedClasses.setFontWeight(QtGui.QFont.Bold) reservedClasses.setFontWeight(QtGui.QFont.Bold)