While the SyntaxEditor editor views have numerous built-in margins (line number, outlining, etc.), SyntaxEditor offers an extensibility point where custom margins can be created and added to editor views in any location.
Editor view margins all implement the IEditor
Margin Locations
Editor view margins surround the text area and fall into two categories: scrollable or fixed.
Scrollable margins appear inside of the scrollbars and scroll with the text area as it is scrolled. Fixed margins appear outside of the scrollbars and do not scroll when the text area is scrolled.
Custom margins that show the eight available margin placement locations
All in all, there are eight available margin placement locations. The screenshot above shows where each placement is located.
The IEditor
Since each IEditorKey
, and the interface also implements IOrderable, it has an Orderings property that returns an enumerable of Ordering objects. Each ordering indicates the string Key
of another margin and whether this margin comes before or after that one. When multiple margins are combined into a placement location, they are ordered based on the Orderings property values, where "after" means farther away from the text area.
For instance, the selection margin says it is not after anything, meaning it is placed closes to the text area. The line number margin says it is after the selection margin, and so on.
Built-In Margin Summary
These editor view margins are built-in to the product:
- Indicator margin
- Line number margin
- Selection margin
- Outlining margin
- Word wrap glyph margin
- Ruler margin
All of the built-in margins are scrollable margins, meaning they scroll with the text area.
Indicator Margin
The indicator margin, implemented by the Editor
Visibility
This margin is not visible by default, and can be made visible when the Syntaxtrue
.
Style
The SyntaxBrush
value to alter the display of the margin.
Line Number Margin
The line number margin, implemented by the Editor
Word wrapped lines do not display any line numbers.
Visibility
This margin is not visible by default, and can be made visible when the Syntaxtrue
.
Style
The SyntaxBrush
value to alter the display of the margin.
In addition, the Line
Customizing Line Numbers
The origin line number that defaults to 1
can be set via the IEditor
See the Line Number Provider topic for more information on implementing this kind of language service.
Selection Margin
The selection margin, implemented by the Editor
Visibility
This margin is visible by default, and can be made invisible when the Syntaxfalse
.
Style
The SyntaxBrush
value to alter the display of the margin.
Outlining Margin
The outlining margin, implemented by the Editor
Visibility
This margin is visible by default, and can be made invisible when the Syntaxfalse
.
Style
The SyntaxBrush
value to alter the display of the margin.
Word Wrap Glyph Margin
The word wrap glyph margin, implemented by the Editor
Visibility
This margin is not visible by default, and can be made visible when the Syntaxtrue
. The editor must also be in word wrap mode for this margin to be visible.
Style
The SyntaxBrush
value to alter the display of the margin.
Ruler Margin
The ruler margin, implemented by the Editor
Visibility
This margin is not visible by default, and can be made visible when the Syntaxtrue
.
Style
The SyntaxBrush
value to alter the display of the margin.
Margin Factories
Margin factories are used to tell SyntaxEditor which margins to display in an editor view. Margin factories are implementations of the IEditor
The Default
The Syntax
Custom Margins
Custom margins are pretty easy to create. These are the basic steps involved:
- First, make a margin
Control
that implements IEditorView .Margin - Second, make a custom IEditor
View that creates an instance of your margin class.Margin Factory - Third, add your custom margin factory to the Syntax
Editor .ViewMargin collection.Factories
At this point your margin should now be getting added to the view. Scrollable margins need to update when the text area is changed, so be sure to attach to the view's Text
For details on implementing a custom margin including several complete examples, please see the related QuickStarts in the samples.