diff --git a/src/Mod/Path/PathScripts/PathInspect.py b/src/Mod/Path/PathScripts/PathInspect.py index ddc749cd7..9ceb76fef 100644 --- a/src/Mod/Path/PathScripts/PathInspect.py +++ b/src/Mod/Path/PathScripts/PathInspect.py @@ -58,20 +58,41 @@ class GCodeHighlighter(QtGui.QSyntaxHighlighter): def __init__(self, parent=None): + + def convertcolor(c): + return QtGui.QColor(int((c>>24)&0xFF),int((c>>16)&0xFF),int((c>>8)&0xFF)) super(GCodeHighlighter, self).__init__(parent) + p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Editor") + colors = [] + c = p.GetUnsigned("Number") + if c: + colors.append(convertcolor(c)) + else: + colors.append(QtCore.Qt.red) + c = p.GetUnsigned("Keyword") + if c: + colors.append(convertcolor(c)) + else: + colors.append(QtGui.QColor(0,170,0)) + c = p.GetUnsigned("Define name") + if c: + colors.append(convertcolor(c)) + else: + colors.append(QtGui.QColor(160,160,164)) + self.highlightingRules = [] numberFormat = QtGui.QTextCharFormat() - numberFormat.setForeground(QtGui.QColor(0,90,175)) + numberFormat.setForeground(colors[0]) self.highlightingRules.append((QtCore.QRegExp("[\\-0-9\\.]"),numberFormat)) keywordFormat = QtGui.QTextCharFormat() - keywordFormat.setForeground(QtCore.Qt.darkCyan) + keywordFormat.setForeground(colors[1]) keywordFormat.setFontWeight(QtGui.QFont.Bold) keywordPatterns = ["\\bG[0-9]+\\b", "\\bM[0-9]+\\b"] self.highlightingRules.extend([(QtCore.QRegExp(pattern), keywordFormat) for pattern in keywordPatterns]) speedFormat = QtGui.QTextCharFormat() speedFormat.setFontWeight(QtGui.QFont.Bold) - speedFormat.setForeground(QtCore.Qt.green) + speedFormat.setForeground(colors[2]) self.highlightingRules.append((QtCore.QRegExp("\\bF[0-9\\.]+\\b"),speedFormat)) def highlightBlock(self, text): @@ -96,9 +117,10 @@ class GCodeEditorDialog(QtGui.QDialog): # nice text editor widget for editing the gcode self.editor = QtGui.QTextEdit() font = QtGui.QFont() - font.setFamily("Courier") + p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Editor") + font.setFamily(p.GetString("Font","Courier")) font.setFixedPitch(True) - font.setPointSize(11) + font.setPointSize(p.GetInt("FontSize",10)) self.editor.setFont(font) self.editor.setText("G01 X55 Y4.5 F300.0") self.highlighter = GCodeHighlighter(self.editor.document())