Color Scheme XML Structure

Top  Previous  Next

Color scheme used to assign font attributes to tokens. Color scheme XML document is separated from syntax scheme XML document for easer coloring styles changing. Color scheme documents are contained in TLMDEditDocument.ColorSchemes collection.

 

XML document for color scheme structure:

 

Element: <Attributes>

 

Root of the color scheme XML file.

 

Sub-elements:

 

Element: <Token>

 

Assigns text attributes to given token.

Attribute: name, type: string, case-sensitive
name attribute should be unique for color scheme document.
Attribute: textColor, type: string, color specification
Here you can use color names from Delphi color names, but lowercase and without ‘cl’ prefix: red, white, black, etc...
Or, you can use html-like color encoding: #RRBBGG, where RR, BB, GG are hex numbers from 00 to FF for Red, Blue, and Green color parts respectively.
Attribute: backgroundColor, type: string, color specification
Same rules as for textColor, but used for text background color.
Attribute: fontStyle, type: string, font style specification, case-sensitive
May have any number of font style attributes, separated by commas and spaces.
Attributes are: bold, italic, underline, strikeOut.

 

Element: <CustomAttributes>

 

Assigns custom attributes collection to given token.

For example, we can use this ability for TRichEdit content colorization, to set different font sizes for different tokens and sub-schemes.

 

And, custom attributes which set as default for some scheme, gets overlapped by correspondent attributes when those are defined for tokens produced by this scheme.

For example, in CustomAttrsDemo application:

 

We use 'font-name' attribute to set the font for some tokens:

 

for 'default' token, we set 'Arial' font. This means, default token will use Arial.
for 'comment' token, we set 'Courier New' font. So, all text inside 'Comment' subscheme will use courier, and this will overlap Arial font, set for outer scheme.
For 'email' token we set 'Comic Sans MS' font. So, all emails in 'Comment' subscheme will overlap parent scheme font.

 

See example below for syntax of <CustomAttributes> sub-elements.

 

Example of color scheme:

 

<?xml version="1.0" encoding="UTF-8"?>

<Attributes>

    <CustomAttributes>

      <SomeCustomName>Value</SomeCustomName>

      <font-name>Arial</font-name>

      <font-size>12</font-size>

      <border-width>1</border-width>

      <border-color>red</border-color>

    </CustomAttributes>

 

    <Token name="default" textColor="#0" />

    <Token name="defaultEmbed" backgroundColor="#ECE9D8"  />

    <Token name="comment" textColor="#008000" />

    <Token name="commentStart" textColor="#008000" />

    <Token name="commentEnd" textColor="#008000" />

    <Token name="keyword" fontStyle="bold" />

    <Token name="email" fontStyle="bold" />

    <Token name="number" textColor="Blue"  />

    <Token name="symbol" textColor="Blue" />

    <Token name="string" textColor="Blue" />

    <Token name="badString" textColor="Red" />    

    <Token name="preprocessor" textColor="#008080" />

    <Token name="badPreprocessor" textColor="red" />

</Attributes>