Highlighting styles store information about how text should be rendered within a SyntaxEditor, including fore/background, font styles, and more.
Styles have the capability of altering these formatting options:
- Foreground
- Background
- Border
- Bold
- Italic
- Font family
- Font size
- Strike-through
- Underline
Basic Concepts
Interface and Implementation
Highlighting styles are instances of the IHighlighting
This code creates a simple highlighting style with a foreground color of maroon:
Default Values and Inheritance
All the properties in Highlighting
In the code example above, however, we have assigned a Maroon
foreground Color
to the style. This means that the style defined above will only change the foreground of text that it is applied against. It will not alter the bold weight, font size, etc.
There are scenarios in SyntaxEditor where two or more styles may be merged together to create resolved formatting options. For instance, if the special Display
During the resolution process, any non-default property settings on the higher-priority style will be applied and will override any property settings on the lower-priority style. If the higher-priority style doesn't set a property value but the lower-priority style does, the lower-priority style's value will be used, thereby establishing inheritance.
Relationship Between Classifications and Styles
Taggers are objects that provide data (in the form of tags) over ranges of text. One such tag is the IClassification
Highlighting styles on the other hand purely deal with the user interface and how text is formatted.
There is a strong relationship that ties together classifications and highlighting styles, and that tie is made via highlighting style registries. These registries provide a mapping from classification types to highlighting styles.
As a SyntaxEditor prepares to draw text, it examines the logical classifications that have been on the text. Then it uses highlighting style registries to determine which highlighting styles apply. After that, it resolves styles (see above) and returns a list of resolved styles to the code that renders the text.
Formatting Options
Highlighting styles have a lot of options for changing the formatting of text.
Foreground and Background
The Foreground and Background properties are used to designate nullable Color
objects that should be used to render the foreground and background of text.
It is recommended to generally use Color
instances that have no transparency.
A null
reference value is considered the "default" value and will not alter formatting.
Background Spans Virtual Whitespace
The Backgroundtrue
, the background will be rendered to the right edge of the view, thereby covering virtual space.
It is a Boolean
type, where the default is false
. Since backgrounds are rendered in a layered fashion, a null
reference value is not needed for this property.
Bold and Italic
The Bold and Italic properties are used to designate whether the text should be bold and/or italic.
It is a nullable Boolean
type, where a null
reference value is considered the "default" value and will not alter formatting.
Border
Optional borders can be applied to text via highlighting styles. The Border
The Border
Borders render with square corners by default but the Border
Font Family
The Font
A null
reference value is considered the "default" value and will not alter formatting.
Font Size
The Font
A value of 0.0
is considered the "default" value and will not alter formatting.
Strike-through
Properties like Strikethrough
The default value is LineNone
, which will not render a strike-through line.
Underline
Properties like Underline
The default value is LineNone
, which will not render an underline.
Editable Properties
SyntaxEditor highlighting styles are designed to be editable by the end user via an options dialog. Therefore, styles include several options for designating which of the most common properties may be edited by the end user.
The Is
There are a number of cases however where certain properties don't make sense to be editable. As an example, the style for the special Display