Skip to content
ConsoleMonster
Class

HighlightStyles

ConsoleMonster.Highlighting

Namespace
ConsoleMonster.Highlighting
Assembly
ConsoleMonster
Modifiers
static

Maps highlight roles to theme roles, so highlighted text follows the theme and the colour depth like every other widget: keywords Series5, strings Series2, numbers Series3, keys Series1, types and identifiers Series6, variables Accent2, comments Muted italic, punctuation Muted, links Accent underlined, levels and diff lines by status.

Inheritance

  • object
  • HighlightStyles

Methods

public static Style For(HighlightRole role, RenderContext context) #

The style of a role.

Parameters

role ConsoleMonster.Highlighting.HighlightRole required
The role.
context ConsoleMonster.Canvas.RenderContext required
The render context.

Returns

Style The style.
ToLines 2 overloads
public static List<StyledLine> ToLines(string text, ITextHighlighter? highlighter, RenderContext context, int maxLines = 0) #

Highlighted text as styled lines: tokens take their role's style, the rest plain. The text is literal (never markup); tabs become spaces to the next multiple of four and other control characters are dropped.

Parameters

text string required
The text.
highlighter ConsoleMonster.Highlighting.ITextHighlighter? required
The highlighter, or null for plain text.
context ConsoleMonster.Canvas.RenderContext required
The render context.
maxLines int = 0 optional
The most lines to return (0 for all).

Returns

List<StyledLine> The lines.
public static List<StyledLine> ToLines(string text, ITextHighlighter? highlighter, RenderContext context, int maxLines, ThemeToken? typeTone) #

Highlights literal lines with an optional tone override for type tokens.

Parameters

text string required
The literal source text.
highlighter ConsoleMonster.Highlighting.ITextHighlighter? required
The language highlighter, or null for plain text.
context ConsoleMonster.Canvas.RenderContext required
The theme and terminal context.
maxLines int required
The line limit, or zero for every line.
typeTone ConsoleMonster.Styling.ThemeToken? required
The type-token tone, or null for the language default.

Returns

List<StyledLine> The styled lines without interpreting source text as markup.
public static string ToMarkup(string text, ITextHighlighter highlighter) #

Highlighted text as markup with theme role names (for log regions and other markup sinks). The text is escaped, so nothing in it is read as markup; control characters other than line breaks are dropped.

Parameters

text string required
The text.
highlighter ConsoleMonster.Highlighting.ITextHighlighter required
The highlighter.

Returns

string The markup.