|format, macro, code, highlight|
|Saturday, 10 November, 2007 - 18:49|
|Week: 54 - Month: 219 - Year: 3,051 - Timeline|
If you want a response from me, it is faster to send me an email at email@example.com.
This add-on is able to colorize the following languages:
- Assembler (8085)
- Assembler (x86)
- C++ With QT names
- Object C
A block of code is assumed to be formatted based on the following paragraph styles: _OOoComputerCode, _OOoComputerCodeLastLine, _code, _code_first_line, _code_last_line, or _code_one_line.
Numerous color code examples are shown in AndrewMacro.odt, along with a complete description of the add-in.
This extension provides the ability to colorize code segments. There are two modes of operation. The first mode (the least used mode for me) is to select the code that you want to colorize, and then use the menu options under: Tools > Add-Ons > MacroFormatterADP
I use a specific paragraph style for my code. I usually use _OOoComputerCodeLastLine for the last line of code in a segment, and _OOoComputerCode for the rest. So, for four lines of code, the first three use _OOoComputerCode and then the last line uses _OOoComputerCodeLastLine. This group then defines an entire code snippet.
Character styles are used for each portion of the code; for example, there is a character style for keywords, and another for literals. This is how color is assigned.
The code that identifies the specific portions is certainly not complete. In other words, I did not write a complete grammar interpreter for each supported language. My intention is to provide something that is "close enough" for regular use.
When I say that I am only looking for "good enough" support, this means that I may fail under strange situations. An example of an untested, but expected failure is as follows:
Create a single line of code such as "a = 1; // line comment".
If you select the code inside the double quotes, I expect that the single line comment will continue to the end of the paragraph without verifying that this runs past the ends of the selected text. If this is tested and found to be in error, I will fix the problem.
Final note: although a later version of OOo is specified as required, this is only because of the method that the extension uses to set menus. If you must use an older version of OOo, feel free to download the extension, use "unzip" to extract the libraries, and then manually import the libraries; they should work just fine on most any version of OOo.
If a language that you desire to color code is not supported, feel free to contact me directly and ask. Some languages are easy to add.