svg2plot.GcodeRegexHighlighter#

Implementation of a G-Code highlighter.

The GcodeHighlighter class defines regular expressions to match different elements in G-code files and applies specific styles to them, making the stream of commands sent to the plotter nicer to look at and easier to read.

Classes

GcodeHighlighter(*args, **kwargs)

Apply highlight style to anything that looks like gcode.

class GcodeHighlighter(*args: Any, **kwargs: Any)[source]#

Bases: RegexHighlighter

Apply highlight style to anything that looks like gcode.

base_style = 'gcode.'#
highlights = ['(?P<g>([Gg][0-9][0-9]))', '(?P<m2>(M2))', '(?P<setting>(\\$[A-Z]))', '(?P<speed>(F\\d+.0))', '(?P<ok>(ok))', '(?P<close>(\\]))', '(?P<in>(\\[))', '(?P<out>(:\\[RTN:))', '(?P<error>(error:[0-9]))', '(?P<end>(MSG:Pgm End))', '(?P<comment>(\\(([^]]+)\\)))', '(?P<x>(([Xx]) *(-?\\d+.?\\d*)))', '(?P<y>(([Yy]) *(-?\\d+.?\\d*)))', '(?P<z>(([Zz]) *([-+]?\\d+.?\\d*)))']#
theme = {'gcode.close': 'deep_pink4', 'gcode.comment': 'light_slate_grey', 'gcode.end': 'bright_black', 'gcode.error': 'blink', 'gcode.g': 'bright_yellow', 'gcode.in': 'deep_pink4', 'gcode.m2': 'bright_yellow', 'gcode.ok': 'bright_black', 'gcode.out': 'deep_pink4', 'gcode.setting': 'bright_yellow', 'gcode.speed': 'bright_yellow', 'gcode.x': 'bright_red', 'gcode.y': 'bright_green', 'gcode.z': 'bright_blue'}#