Description
How often would we like to insert coloured code in our documents? I know it's not
that important but, first, it looks much nicer and, second, it's much easy to understand
a piece of source code when it is coloured. At least for me.
What this little application does is exporting Rich Text Format syntax coloured code.
To do that, special text files are used defining the each of the languages that the
application will handle and colour. These files are found in the application folder.
Language files
Let's have now a look into this language files. From all the sections, only the first
one is not optional, the rest of them are, though it doesn't make a lot of sense not
including them.
Section | Description |
§ Language extensions | File extensions for which the language file will be used |
§ Comment line | Comment line indicator (e.g.: // in C++) |
§ Comment block | Opening and closing comment block symbols (in different lines) |
§ String marks | Characters that can enclose a string (e.g.: ") |
§ Operators | Single characters that act as operators in the described language in a single line.
(blank spaces can be added) |
§ Keywords | Language keywords. |
§ Colours (normal, comment, string, keyword, operator) | Colour in hexadecimal that will be used. One per line. |
Note that an empty line is required after the last element of each section and the section
names must be exactly like they appear in the table above.
Notes
First of all, saying that the application may have bugs. I'm not speaking about
memory leaks or something like that, just pointing out the possibility that somebody
gets a bad coloured output for a given source file. I haven't so far anyway.
I've only tested the app under Windows 2000, but it should work as well under Windows 98
and I guess also in WindowsXP (?)
Two of those language files are included in both of the downloads. One for C/C++
and the other one for Visual Basic
The code to transfer the rtf information to a CString
object was borrowed from the
article Painless streaming with CRichEditCtrl
, that can be found in the Docs
sections in http://www.calcaria.net.
I'm posting the source code along with the application. I hope this article helps,
in the same way many of the articles found here, in the Code Project, helped me.
Salu2, Samuel.
I studied Telecommunication with spezialization in Sound & Image. I was always very interested in programming at university as well and that is how I earn a living.
Since some years ago, I am also succesfully involved in software architecture and design.