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
| Member | Summary |
|---|---|
TextView(ArlecchinoKeymap) | Creates the view. |
Properties
| Member | Summary |
|---|---|
IsFocused | Whether the view has focus. Only a focused view answers keys. |
LineCount | How many lines the text takes once wrapped to the last width it was drawn at. |
Offset | First wrapped line shown. |
ShowScrollBar | Whether a scroll bar is drawn when the text does not fit. |
Style | Color of the text. The theme's default when left alone. |
Text | The text shown. Line breaks are kept; long lines wrap on spaces. |
Methods
| Member | Summary |
|---|---|
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
| Name | Type | Description |
|---|---|---|
keymap | ArlecchinoKeymap | Keys 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
| Name | Type | Description |
|---|---|---|
region | SurfaceRegion | Where 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
| Name | Type | Description |
|---|---|---|
key | KeyPress | The 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
| Name | Type | Description |
|---|---|---|
mouse | MouseEvent | The event that arrived. |
Returns FocusResult — Whether the view took it.