API Reference
CodeView
Source text with syntax highlighting: an optional title (a file name) on a panel, line numbers, highlighted line ranges marked in the gutter, long lines wrapped or truncated with the tier's ellipsis, and a line cap with "+n more lines". The text is literal: markup is not interpreted and control characters are dropped.
Inheritance
- Object
- CodeView
Usage
Explore 22 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 12
- Extension method CodeView.WithFirstLine
- Extension method CodeView.WithLineNumbers
- Extension method CodeView.WithMaxLines
- Extension method CodeView.WithTitle
- Extension method CodeView.WithWrap
- Method CodeView.For
- Method CodeView.HighlightLines
- Method CodeViewFluent.WithFirstLine
- Method CodeViewFluent.WithLineNumbers
- Method CodeViewFluent.WithMaxLines
- Method CodeViewFluent.WithTitle
- Method CodeViewFluent.WithWrap
Accepted by parameters 10
- Extension method CodeView.WithFirstLine
- Extension method CodeView.WithLineNumbers
- Extension method CodeView.WithMaxLines
- Extension method CodeView.WithTitle
- Extension method CodeView.WithWrap
- Method CodeViewFluent.WithFirstLine
- Method CodeViewFluent.WithLineNumbers
- Method CodeViewFluent.WithMaxLines
- Method CodeViewFluent.WithTitle
- Method CodeViewFluent.WithWrap
Constructors
public CodeView(String text, ITextHighlighter? highlighter = null) #Creates a view.
Parameters
- text System.String
- The text.
- highlighter ConsoleMonster.Highlighting.ITextHighlighter? = null
- The highlighter, or null for plain text.
Methods
public static CodeView For(String text, String? language, String? path = null) #CodeViewCreates a view for a language name or file extension ("json", "ps1"): "auto" (or null) detects the language from the path and the content, "text" or "plain" shows plain text.
Parameters
- text System.String
- The text.
- language System.String?
- The language, "auto", "text", or null for auto.
- path System.String? = null
- The file it came from (for detection), or null.
Returns
The view.
Exceptions
ArgumentException– The language is not registered.
public CodeView HighlightLines(Int32 from, Int32 to = 0) #CodeViewMarks lines (by their numbers) as highlighted.
Parameters
- from System.Int32
- The first line.
- to System.Int32 = 0
- The last line (default the same).
Returns
This view.
public CodeView HighlightLines(String range) #CodeViewMarks lines given as text: a number ("10") or a range ("10-14", "10..14").
Parameters
- range System.String
- The line or range.
Returns
This view.
Exceptions
ArgumentException– The text is not a line number or a range.
public Size Measure(Constraints constraints, RenderContext context) #SizeReturns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Returns
The desired size, never larger than the constraints.
public Void Render(Region region, RenderContext context) #VoidRenders into a region. The region may be smaller or larger than the measured size.
Parameters
- region ConsoleMonster.Canvas.Region
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public List<StyledLine> Rows(Int32 width, RenderContext context) #List<StyledLine>The display rows at a width: gutter and code, wrapped or truncated.
Parameters
- width System.Int32
- The width.
- context ConsoleMonster.Canvas.RenderContext
- The render context.
Returns
The rows.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Properties
public String? Title { get; set; } #A title (a file name) drawn on a panel around the code, or null for no panel.
public Int32 FirstLine { get; set; } #The number of the first line (default 1), for excerpts.
public Int32 MaxLines { get; set; } #The most lines shown (default 2000); the rest are counted.
Extension Methods
public static CodeView WithFirstLine(CodeView codeView, Int32 value) #CodeViewSets CodeView.FirstLine: The number of the first line (default 1), for excerpts.
Parameters
- codeView ConsoleMonster.Widgets.CodeView
- The instance.
- value System.Int32
- The value.
Returns
The same instance.
public static CodeView WithLineNumbers(CodeView codeView, Boolean value = true) #CodeViewSets CodeView.LineNumbers: Shows line numbers.
Parameters
- codeView ConsoleMonster.Widgets.CodeView
- The instance.
- value System.Boolean = true
- The value (default true).
Returns
The same instance.
public static CodeView WithMaxLines(CodeView codeView, Int32 value) #CodeViewSets CodeView.MaxLines: The most lines shown (default 2000); the rest are counted.
Parameters
- codeView ConsoleMonster.Widgets.CodeView
- The instance.
- value System.Int32
- The value.
Returns
The same instance.
public static CodeView WithTitle(CodeView codeView, String? value) #CodeViewSets CodeView.Title: A title (a file name) drawn on a panel around the code, or null for no panel.
Parameters
- codeView ConsoleMonster.Widgets.CodeView
- The instance.
- value System.String?
- The value.
Returns
The same instance.
public static CodeView WithWrap(CodeView codeView, Boolean value = true) #CodeViewSets CodeView.Wrap: Wraps long lines instead of truncating them.
Parameters
- codeView ConsoleMonster.Widgets.CodeView
- The instance.
- value System.Boolean = true
- The value (default true).
Returns
The same instance.