Bug 457754 - G-Code for 3D printers highlights commands incorrectly
Summary: G-Code for 3D printers highlights commands incorrectly
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (show other bugs)
Version: 5.96.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-11 10:53 UTC by gudvinr+kde
Modified: 2022-08-24 13:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.98


Attachments
sample file (483.87 KB, text/plain)
2022-08-11 10:54 UTC, gudvinr+kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gudvinr+kde 2022-08-11 10:53:47 UTC
SUMMARY

G-Code files for 3D printers that use commands not starting with letter G highlighted not highlight them as commands.

There is no any formal distinction between kinds of commands highlighted.
E.g. G0, G1, G2, G3 used for travel moves but commands like G90, G92 are control commands (used to set some state in firmware). Control commands can also start with letter M, like M106, M190, etc. Yet all commands starting with G are highlighted as commands (black) and commands starting with M highlighted with orange in default color scheme.

There are also commands starting with D, commonly used in Prusa printers which also rendered as fields rather than commands.

STEPS TO REPRODUCE
1. Open G-Code file
2. Check if syntax set to G-Code

OBSERVED RESULT
So-called RepRap-commands starting with M highlighted as fields rather than commands.

EXPECTED RESULT
Highlight commands starting with M as commands.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Graphics Platform: Wayland

ADDITIONAL CONTEXT
Common G-Code commands: https://reprap.org/wiki/G-code
Comment 1 gudvinr+kde 2022-08-11 10:54:16 UTC
Created attachment 151245 [details]
sample file
Comment 2 Bug Janitor Service 2022-08-18 21:43:17 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/342
Comment 3 Christoph Cullmann 2022-08-21 16:32:44 UTC
Git commit 29d174f194728ad934297d0c0a0fa6f4e251332a by Christoph Cullmann, on behalf of jonathan poelen.
Committed on 21/08/2022 at 16:32.
Pushed by cullmann into branch 'master'.

G-Code: fix number pattern, Mnnn as M-word or M-word (user), add String and...

G-Code: fix number pattern, Mnnn as M-word or M-word (user), add String and RepRapFirmware expression

Before:

```
G 1 3 0
^ G-word
      ^ Number

M100
^ M-word (user)

M1001
^ M-word (user)
    ^ Number

M200
^ M-word
 ^ Number
```

Now:

```
G 1 3 0
^ G-word

M100
^ M-word (user)

M1001
^ M-word

M200
^ M-word
```

M  +43   -0    autotests/folding/highlight.ngc.fold
M  +43   -0    autotests/html/highlight.ngc.dark.html
M  +43   -0    autotests/html/highlight.ngc.html
M  +43   -0    autotests/input/highlight.ngc
M  +43   -0    autotests/reference/highlight.ngc.ref
M  +126  -72   data/syntax/gcode.xml

https://invent.kde.org/frameworks/syntax-highlighting/commit/29d174f194728ad934297d0c0a0fa6f4e251332a