I created four versions of a syntax highlighting wordfile for G-code based on what I read on Wikipedia page about G-code
and tested them on a file with the G-code posted by you combined with the example G-code on Wikipedia page. Please extract the attached ZIP file and copy the four *.uew
files into the directory %APPDATA%\IDMComp\UltraEdit\wordfiles
. Next start UltraEdit and open the four Test.gcode?
files which have identical contents. Then open in UltraEdit the Manage Themes
dialog window, select tab Syntax
and quickly configure for the four languages G-code v?
all the color groups with making sure that each color group with a name has a unique color which no other color group has.
What is common for all four wordfiles?
What is special on first wordfile?
- All four wordfiles are case-sensitive which means g0 is not syntax highlighted, just G0. I don't know if G-code is case-sensitive or not and I don't know if you prefer all G-code files without small letters.
The advantage with a case-sensitive syntax highlighting language definition is that there can be entered the letters in lower case and UltraEdit corrects them to upper case if the configuration setting Auto-correct keywords is checked at Advanced - Settings or Configuration - Editor display - Miscellaneous if that character is being a syntax highlighted "word". The auto-correction is not done on strings syntax highlighted using a substring definition.It is possible to insert after "G-code v?" in the first line a space character and the language keyword Nocase to make the syntax highlighting definition case-insensitive.
- The language keyword Noquote disables the default string highlighting as G-code definitely does not contain strings in single or double quotes.
- A set of three Perl regular expression search strings is used to get displayed in the Function List view on being opened the program name, the layers and the times elapsed in a hierarchical or a flat list. The type of the list can be changed by right clicking into the Function List view and clicking on context menu item Flat list to toggle this option.
- It is important for the first and fourth version that UltraEdit does not remove all comments before applying the syntax highlighting which is done by default since UltraEdit for Windows v24.20. The language term /Strip Comments = No is for that reason in all four wordfiles although really needed only in first and fourth wordfile.
That is the first reason why your fold string definition has not worked as expected.
- The percent sign is interpreted as open/close fold string in all four wordfiles. That is very important on first and fourth wordfile as the open/close comment fold strings are ignored if there are no open/close fold strings defined, too. I described that important fact in the template for creation of a wordfile.
That is the second reason why your fold string definition has not worked as expected.
- There can be used up to 20 color groups. So there is made use of nearly all of them.
It is of course possible to change the words/substrings assignments to the color groups to whatever is preferred.
- All four wordfiles contain /Word Select Include = +-. to interpret a plus and minus sign (in real hyphen) and a dot as word character on selecting a word with a double click or using the command Select word. Please note that this definition is only for selecting a word, not for syntax highlighting a word. But I suppose that feature will be very helpful for you in the future on selecting a floating point value on a G-code file with a double click or using the command to select a word.
The first wordfile defines a line comment. Everything from a semicolon to end of a line is syntax highlighted as a comment. Therefore it is not possible to get words or values syntax highlighted with a different color on a line after the semicolon. This is the reason why the first wordfile does not contain the color group 4 in comparison to the second and third wordfile.
If this version is preferred by you finally, it would be best to renumber the color groups 5 to 17 to 4 to 16 to avoid the gap in the color groups.
The list of /Delimiters =
is very short for this wordfile. There are only space, horizontal tab, colon and semicolon interpreted as word delimiters for syntax highlighting (not for selecting a word). This makes it possible to use substring definitions to syntax highlight all strings starting with a specific character with the color and font style settings as defined for the color group containing the appropriate syntax highlighting definitions. That is used for the color groups 5 to 16.
The first three color groups lists all possible values for instructions (hope this is a good name for this color group), macros and parameters. There are not used substring definitions for these three color groups. The reason is that a good syntax highlighting definition should highlight only strings being really valid for the interpreter of the code. So if this version is finally the one used by you, I recommend to look into the manual of the machine and make sure that the first three color groups contain only the "words" really supported by the machine. That would be in future helpful for you as you would visually see what is wrong in G-code on using a string starting with G
which is not syntax highlighted. The auto-completion feature is also only useful on getting only valid "words" suggested on making use of the auto-completion feature.
What is special on second wordfile?
The second wordfile does not define a semicolon as beginning of a line comment. That makes it possible to syntax highlight also strings in a line after a semicolon as done with color group 4 which I gave the name Keywords
as I don't know enough about G-code to find a better name for the words in this color group. I added also ;
as "words" to this color group. Please note that semicolon and colon are word delimiters for syntax highlighting and are therefore always interpreted as single character words by the syntax highlighting of UltraEdit. It is of course possible to use a separate color group for semicolon and colon if that is preferred by you on using this version of the G-code syntax highlighting.
Important here is that the color group with LAYER
has a lower number as the color group with the substring definition to highlight all words starting with L
to get this word really highlighted separately from all other words starting with L
. That rule is important also for the words SUPPORT
which I added also to color group 4.
Everything else to know about the second version for G-code syntax highlighting is identical to first version.
What is special on third wordfile?
The third wordfile has a different set of word delimiters in comparison to second wordfile. Every digit, plus sign, minus sign and dot is interpreted as word delimiter for syntax highlighting by this language definition. That changes the syntax highlighting completely. Now the numbers are always syntax highlighted with the predefined color group Numbers
and just the letter left to the number is syntax highlighted according to the color group.
The last color group with name Signs, dot
can have the same color and font style settings as the predefined color group Numbers
or can have different settings. That is up to you on using this wordfile.
The first three color groups contain now only the characters G
as word because of each digit is itself a single character word for syntax highlighting. So the syntax highlighting with third version gives the user no information about valid or invalid instruction, macro or parameter as it is not possible to define a "word" in a color group which consists of multiple "words" according to the word delimiters definition. That is of course a disadvantage of this wordfile, but you might like that syntax highlighting more than the two others.
What is special on four wordfile?
That wordfile is a combination of the first wordfile with a line comment definition and the third wordfile with the special word delimiters definition to syntax highlight all floating point numbers as numbers.
Some more notes:
The list of instructions, macros and parameters should be reduced finally to what the machine really supports according to its manual on using the first or the second version suggested by me.
The finally used wordfile should have no gap in numbering of the color groups as the first and the fourth version currently have.
The color groups can be redefined by you, for example by splitting up the first color group for the instructions into multiple color groups according to meaning of the instructions to have a visual indication what the appropriate G-code is for. But please note that more than 20 color groups are not possible.
Please let me know if you would like to see more in the Function List
view or if you need help to further enhance one of the four wordfiles after having decided which one is liked most by you.
The version information should be removed from the file name of the finally used G-code wordfile as well as from language name at beginning of the first line.
The file extension of finally used syntax highlighting wordfile should be changed to the file extension really used for G-code files at end of the first line.
The three not further used wordfiles should be removed from the wordfiles directory.
The color and font style settings of the the longer used wordfiles should be finally removed from the theme file which is in %APPDATA%\IDMComp\UltraEdit\themes
or its subdirectory overrides
depending on using a custom theme or override (extend) a standard theme with the color and font style settings for G-code syntax highlighting.