Skip to main content

TextView class

Namespace: Arlecchino.Widgets.Readouts · Assembly: Arlecchino

A block of text to read: wrapped to the width it is given, scrolled with the movement keys and the wheel. It is re-wrapped whenever the width changes, so resizing the terminal reflows it.

public sealed class TextView : IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Implements IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Constructors

MemberSummary
TextView(ArlecchinoKeymap)Creates the view.

Properties

MemberSummary
IsFocusedWhether the view has focus. Only a focused view answers keys.
LineCountHow many lines the text takes once wrapped to the last width it was drawn at.
OffsetFirst wrapped line shown.
ShowScrollBarWhether a scroll bar is drawn when the text does not fit.
StyleColor of the text. The theme's default when left alone.
TextThe text shown. Line breaks are kept; long lines wrap on spaces.

Methods

MemberSummary
Draw(SurfaceRegion)Wraps the text to the region and draws the part that fits. The view fills whatever it is given, so nothing is left underneath it.
Handle(KeyPress)Scrolls the text.
HandleMouse(MouseEvent)Scrolls with the wheel while the pointer is over the text.

Constructors in detail

TextView(ArlecchinoKeymap)

public TextView(ArlecchinoKeymap keymap);

Creates the view.

Parameters

NameTypeDescription
keymapArlecchinoKeymapKeys to obey, so scrolling follows the application's bindings.

Properties in detail

IsFocused

public bool IsFocused { get; set; }

Whether the view has focus. Only a focused view answers keys.

Type bool

LineCount

public int LineCount { get; }

How many lines the text takes once wrapped to the last width it was drawn at.

Type int

Offset

public int Offset { get; set; }

First wrapped line shown.

Type int

ShowScrollBar

public bool ShowScrollBar { get; init; }

Whether a scroll bar is drawn when the text does not fit.

Type bool

Style

public IArlecchinoColor? Style { get; set; }

Color of the text. The theme's default when left alone.

Type IArlecchinoColor

Text

public string Text { get; set; }

The text shown. Line breaks are kept; long lines wrap on spaces.

Type string

Methods in detail

Draw(SurfaceRegion)

public SurfaceRegion Draw(SurfaceRegion region);

Wraps the text to the region and draws the part that fits. The view fills whatever it is given, so nothing is left underneath it.

Parameters

NameTypeDescription
regionSurfaceRegionWhere to draw.

Returns SurfaceRegion — An empty region: the view uses every row it is handed.

Handle(KeyPress)

public FocusResult Handle(KeyPress key);

Scrolls the text.

Parameters

NameTypeDescription
keyKeyPressThe key that was pressed.

Returns FocusResult — Whether the view took it.

HandleMouse(MouseEvent)

public FocusResult HandleMouse(MouseEvent mouse);

Scrolls with the wheel while the pointer is over the text.

Parameters

NameTypeDescription
mouseMouseEventThe event that arrived.

Returns FocusResult — Whether the view took it.