User forums > Using Code::Blocks
Syntax Highlighting -- Is it really this hard?
marphod:
I think I would be code-complete on my proof of concept, EXCEPT I've made the fun discovery that the various Lexer XML files' XML is non-complaint in a number of ways.
(Unquoted attributes, using a raw Ampersand and Open angle brace in strings, and possibly other issues.)
Blah. Off to find a more permissive Perl XML parser than LibXML.
oBFusCATed:
--- Quote from: marphod on May 15, 2013, 05:28:18 pm ---(Unquoted attributes, using a raw Ampersand and Open angle brace in strings, and possibly other issues.)
--- End quote ---
Why don't you fix them and provide a patch?
marphod:
--- Quote from: oBFusCATed on May 15, 2013, 06:20:49 pm ---Why don't you fix them and provide a patch?
--- End quote ---
I've no idea where in the source tree I'd find them.
For that matter, are they a Code::Blocks thing, or are they sourced from Scintilla?
(and I've had issues logging on to http://developer.berlios.de -- it keeps telling me to turn cookies on, but I've allowed them for their domain, and quite a few others.)
(Heck, I really hope they aren't hand-generated, but programmatically created. But probably not.)
- - -
Regardless: Why submit a patch of a few XML files when I have a working prototype, which can fix the XML automagically. =)
(Well, except for the weird spacing in attributes; I maintained that, as it helps readability and the fix may be beyond the scope of the XML.)
(If you want to do so, comment out the line "SetThemeForNode( $theme_map, $style_node, @theme_names );"; line 423. It will regenerate the .xml files in a more
standard's compliant format.)
This is a PROTOTYPE.
It creates new versions of the lexer_<foo>.xml files with the new syntax highlighting styles.
The program works buy slurping in the existing lexer files and regenerating them (in another location) with the new style settings.
You need to replace the .xml files (/usr/share/codeblocks/lexer/*.xml on fedora 18, and probably most other unix/linux installs). BACK THE ORIGINALS UP FIRST.
You have to set the theme settings (colors, bold, etc.) by hand in the cb_theme.xml file (sample attached); well, assuming you don't want to use my semi-random/semi-use-based settings. You will also probably disagree with some of the name/alias mappings I made in the cb_theme.xml files. That's fine, the XML file is fairly straight-forward.
There are known issues (the program will abort if it finds the same theme-type name/alt-name multiple times in the config file. The program will abort if it finds a style name in a lexer file it does not recognize, rather than treating it as 'no style attributes'. The Pretty-print output has occasional issues (some nodes being more indented than they should; some less; most attributes are one-per-line, but not all).
Cavaet Emptor.
- - -
(Future versions will create themes that can be imported, rather than change the theme file. This is a proof of concept prototype. Future versions will also have README, CHANGES, etc., rather than just the perl code and sample config file.)
Requires:
libxml2
perl 5.014
Perl Modules:
Getopt::Long::Descriptive
XML::LibXML
Alpha:
--- Quote from: marphod on May 16, 2013, 06:12:55 am ---I've no idea where in the source tree I'd find them.
For that matter, are they a Code::Blocks thing, or are they sourced from Scintilla?
--- End quote ---
They are Code::Blocks specific, located in src/sdk/resources/lexers/ (if you check out the source tree). There is also some information about the purpose of these files.
marphod:
--- Quote from: Alpha on May 16, 2013, 04:54:32 pm ---They are Code::Blocks specific, located in src/sdk/resources/lexers/ (if you check out the source tree). There is also some information about the purpose of these files.
--- End quote ---
Noted. I'll take a look at them as soon as I manage to check out the source tree.
(. . . So which of the various SCM plugins is the most useable at this point? )
- - -
Also, for the ... 2 of you who downloaded the prototype, here's the next version.
The only important change to the command line is there are now --lexerstyle and --configstyle flags (defaults to configstyle), which controls the type of output generated. lexerstyle is the same as the previous version (new versions of the lexer files, which is more robust against accidental changes, but requires root to install, as I understand it). configstyle creates an xml (.conf) file with various colour_style settings for each language.
--configstyle also can take an optional string, to be the name of the new theme and will be used in the created file name; it defaults to newTheme (so the file will be newTheme.conf)
(These flags are mutually exclusive, although the error message from Getopts::Long::Descriptive isn't terribly helpful in explaining that.)
I'm probably going to put futher feature work on this project on indefinate hiatus, at least until/unless I get some actual commentary and feedback. It isn't perfect, but it works for my needs. I'll try to respond to bug reports, and I plan on putting it up on sourceforge or github in the near future. (I'll add a link here when that's done.)
- - -
Attached file contents:
LICENSE
README
TODO
CHANGES
createCBTheme.pl
cb-theme.xml
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version