User forums > Using Code::Blocks
Syntax Highlighting -- Is it really this hard?
marphod:
Having looked, and not found, a comprehensive syntax highlighting theme for Code::Blocks, I decided to take a look at what would be involved in making one.
As far as I can tell, there is no 'simple' way to make a comprehensive theme. Either you go through the highlighting options item-for-item through the GUI, or you hand craft one by duplicating the highlight style sections for each lexer, dealing with each lexer separately.
There doesn't seem to bey a way to say 'This is the default background and foreground color, for ALL languages', 'This is the background and foreground color for all comments for all languages', etc. Each language has between 10 and 50 options, and each language has to be dealt with on its own.
(As it stands, the default theme is annoyingly inconsistent, but in some cases only by a little bit. For instance, comments are mostly fg #A0A0A0, except when they are #808080 or (...) #7F7F7F. Although there are a few outliers.)
Am I missing something?
And if it really is that hard, has anyone written up a script to make life easier? It shouldn't be that hard to write a perl (or python, or ruby, or whatever) script to slurp in the xml for each lexer and output a new one with a different theme.
It'd require some field-name matching, but that shouldn't be too hard. There should be about 50 basic field types and about 10 basic modifiers.
oBFusCATed:
--- Quote from: marphod on May 10, 2013, 06:37:01 am ---It'd require some field-name matching, but that shouldn't be too hard. There should be about 50 basic field types and about 10 basic modifiers.
--- End quote ---
Unfortunately it is not that simple. Look at the html/javascript/php lexer and you'll know why.
BTW: The latest nightly should have some gui, which should ease the setting of colours.
It allows you to copy colours from on language to another.
marphod:
--- Quote from: oBFusCATed on May 10, 2013, 09:25:12 am ---
--- Quote from: marphod on May 10, 2013, 06:37:01 am ---It'd require some field-name matching, but that shouldn't be too hard. There should be about 50 basic field types and about 10 basic modifiers.
--- End quote ---
Unfortunately it is not that simple. Look at the html/javascript/php lexer and you'll know why.
--- End quote ---
Unless I'm missing something, it really is.
<Embedded language> <foo> would map to the <Embedded language> Background and the <foo> foreground (Comment, Default, Number, whatever). If <foo> has a different background from default, do some color blending of it and the embed backrgound.
You'll need a embedded background for (IIRC) Python, Javascript, SGML, VBS, ASM (for C/C++), PHP, and the ASP versions of Python, VBS, and javascript.
It means doing some string parsing on top of simple string matches and an alias table.
oBFusCATed:
--- Quote from: marphod on May 11, 2013, 12:45:07 am ---Unless I'm missing something, it really is.
--- End quote ---
Patches welcome, but be prepared for bug fixing, I'll be happy to find lots of them ;D
marphod:
--- Quote from: oBFusCATed on May 11, 2013, 02:28:36 am ---Patches welcome, but be prepared for bug fixing, I'll be happy to find lots of them ;D
--- End quote ---
Fair enough. (I have always hated QA ;) (1) )
Although, my prototype is a stand-alone text-based perl script.
I'll post a link (or the code, if it remains short) when it is
at a working stage.
(1) - JOKE. I love QA, I just couldn't do it, professionally, myself(2).
(2) - Which is to say while I totally believe in unit tests, test-driven development, and rapid test cycles, I want to fix things rather than just note what's broken.
Navigation
[0] Message Index
[#] Next page
Go to full version