- Posts: 2
- Thank you received: 2
gCode Highlighting with pygments
- bluebase
- Offline
- New Member
-
Less
More
6 years 11 months ago - 6 years 11 months ago #149497
by bluebase
gCode Highlighting with pygments was created by bluebase
Hi, a long-time lurker here.
I have written a small extension to the python library pygments which is used to highlight code.
The docs/src/source-highlighter for the asciidocs is known to me. And i know gedit is probably used by many users on their controllers. However, most UI for linuxcnc are written in python now. Tinkering with some UI features, I was looking for a way to highlight code with python tools.
Currently, pygments it is missing a lexer for gcode files, though. There is one repository which was addressing this task ( lexers_pygments ) which is likely related to a stackoverflow post .
However, these were quite rudimentary. They only recognized very basic syntax.
Dissatisfied with this condition, I started over to write my own lexer for gcode. You can find it on github .
I would like to discuss the current result with interested parties. Possibly, it could be an alternative to the currently used lexers in other guis.
In the attachments are a few examples with different pygments' styles.
As you see, I choose not to recognize full G-commands, but only the "G", and a likes.
I you have some thoughts about the lexer, I'd be happy to read about them.
Best,
Sebastian
I have written a small extension to the python library pygments which is used to highlight code.
The docs/src/source-highlighter for the asciidocs is known to me. And i know gedit is probably used by many users on their controllers. However, most UI for linuxcnc are written in python now. Tinkering with some UI features, I was looking for a way to highlight code with python tools.
Currently, pygments it is missing a lexer for gcode files, though. There is one repository which was addressing this task ( lexers_pygments ) which is likely related to a stackoverflow post .
However, these were quite rudimentary. They only recognized very basic syntax.
Dissatisfied with this condition, I started over to write my own lexer for gcode. You can find it on github .
I would like to discuss the current result with interested parties. Possibly, it could be an alternative to the currently used lexers in other guis.
In the attachments are a few examples with different pygments' styles.
As you see, I choose not to recognize full G-commands, but only the "G", and a likes.
I you have some thoughts about the lexer, I'd be happy to read about them.
Best,
Sebastian
Last edit: 6 years 11 months ago by bluebase.
The following user(s) said Thank You: andypugh, tommylight
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
-
Less
More
- Posts: 22011
- Thank you received: 7491
6 years 11 months ago #149502
by tommylight
Replied by tommylight on topic gCode Highlighting with pygments
Welcome and thank you, seems very useful.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
6 years 11 months ago #149514
by cmorley
Replied by cmorley on topic gCode Highlighting with pygments
I'm not familiar with pygments - is that a text stand alone editor?
I put together a basic lexer for qtvcp's gcode editor - I'd be happy for someone to work on a better won.
Chris
I put together a basic lexer for qtvcp's gcode editor - I'd be happy for someone to work on a better won.
Chris
Please Log in or Create an account to join the conversation.
- bluebase
- Offline
- New Member
-
Less
More
- Posts: 2
- Thank you received: 2
6 years 11 months ago #149555
by bluebase
Replied by bluebase on topic gCode Highlighting with pygments
No, pygments is not an editor, but a library designed to do syntax highlighting, as far as i understand.
I don't have an overview over qtvcp yet. Though, I did find the current lexer in the gcode_editor widget and did some research. This did yield some interesting contribution: stackoverflow.com/questions/55775837/pyg...-qscintilla/55873245
Maybe, we can derive a drop-in class for testing from the SO post. Do you think it would be worth a try, Chris?
Best,
Sebastian
I don't have an overview over qtvcp yet. Though, I did find the current lexer in the gcode_editor widget and did some research. This did yield some interesting contribution: stackoverflow.com/questions/55775837/pyg...-qscintilla/55873245
Maybe, we can derive a drop-in class for testing from the SO post. Do you think it would be worth a try, Chris?
Best,
Sebastian
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
6 years 11 months ago #149563
by cmorley
Replied by cmorley on topic gCode Highlighting with pygments
I am open to any ideas. I cobbled together the lexer out of necessity.
I have not tested it on huge files.
It sounds to me you are the resident expert now
Chris
I have not tested it on huge files.
It sounds to me you are the resident expert now
Chris
Please Log in or Create an account to join the conversation.
- colincci
- Offline
- New Member
-
Less
More
- Posts: 1
- Thank you received: 0
6 years 10 months ago #151761
by colincci
Replied by colincci on topic gCode Highlighting with pygments
This looks excellent. I have forked your code on github. Let me know if there is anything I can do to assist in getting your lexer ready for a pull request to the pygments repo.
Please Log in or Create an account to join the conversation.
Time to create page: 0.174 seconds