TextModel class

A high-level text component that supports selection, scrolling, and wrapping. It is built on top of ViewportModel but defaults to auto-height and soft-wrap.

Inheritance

Constructors

TextModel(String content, {int width = 80})
factory
TextModel.withOptions({int width = 80, int? height = 24, int gutter = 0, int yOffset = 0, int xOffset = 0, bool mouseWheelEnabled = true, int mouseWheelDelta = 3, int horizontalStep = 0, bool softWrap = true, bool fillHeight = false, bool showLineNumbers = false, GutterFunc? leftGutterFunc, Style? style, Style? highlightStyle, Style? selectedHighlightStyle, Style styleLineFunc(int lineIndex)?, List<HighlightInfo>? highlights = const [], int currentHighlightIndex = -1, (int, int)? selectionStart, (int, int)? selectionEnd, DateTime? lastClickTime, (int, int)? lastClickPos, DateTime nowProvider()?, ViewportKeyMap? keyMap, List<String>? lines, List<String>? wrappedLines, List<String>? originalLines, List<StyleRange> styleRanges = const []})

Properties

atBottom → bool
Whether the viewport is at the bottom.
no setterinherited
atTop → bool
Whether the viewport is at the top.
no setterinherited
currentHighlightIndex → int
The index of the currently focused highlight.
finalinherited
fillHeight → bool
Whether to fill to the height of the viewport with empty lines.
finalinherited
gutter → int
Left gutter (spaces) applied to each rendered line. Also reduces available content width.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
height → int?
Height of the viewport in rows. If null, the viewport will show all lines and will not scroll vertically.
finalinherited
highlights → List<HighlightInfo>
Returns the current highlights.
no setterinherited
highlightStyle → Style
HighlightStyle highlights the ranges set with copyWith(highlights: ...).
finalinherited
horizontalScrollPercent → double
Returns the horizontal scroll percentage (0.0 to 1.0).
no setterinherited
horizontalStep → int
Number of columns to scroll left/right. 0 disables horizontal scrolling.
finalinherited
internalLines → List<String>
Internal lines (unwrapped).
no setterinherited
internalOriginalLines → List<String>
Internal original lines (before styling).
no setterinherited
internalWrappedLines → List<String>
Internal wrapped lines.
no setterinherited
keyMap → ViewportKeyMap
Key bindings for navigation.
finalinherited
lastClickPos → (int, int)?
The position of the last mouse click.
finalinherited
lastClickTime → DateTime?
The time of the last mouse click.
finalinherited
leftGutterFunc → GutterFunc?
A function that returns the gutter for a given line index. If provided, gutter is ignored for rendering but still used for width calculations.
finalinherited
lines → List<String>
The content lines.
no setterinherited
mouseWheelDelta → int
Number of lines to scroll per mouse wheel tick.
finalinherited
mouseWheelEnabled → bool
Whether mouse wheel scrolling is enabled.
finalinherited
pastBottom → bool
Whether the viewport is scrolled past the bottom.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scrollPercent → double
Returns the scroll percentage (0.0 to 1.0).
no setterinherited
selectedHighlightStyle → Style
SelectedHighlightStyle highlights the highlight range focused during navigation.
finalinherited
selectionEnd → (int, int)?
The end of the selection (x, y) in content coordinates.
finalinherited
selectionStart → (int, int)?
The start of the selection (x, y) in content coordinates.
finalinherited
showLineNumbers → bool
Whether to show line numbers in the gutter.
finalinherited
softWrap → bool
Whether to wrap lines that exceed the viewport width.
finalinherited
style → Style
Style applies a lipgloss style to the viewport. Realistically, it's most useful for setting borders, margins and padding.
finalinherited
styleLineFunc → Style Function(int lineIndex)?
StyleLineFunc allows to return a Style for each line. The argument is the line index.
finalinherited
styleRanges → List<StyleRange>
final
totalLineCount → int
Total number of lines in the content.
no setterinherited
visibleLineCount → int
Number of visible lines.
no setterinherited
width → int
Width of the viewport in columns.
finalinherited
xOffset → int
Horizontal scroll offset (0 = left).
finalinherited
yOffset → int
Vertical scroll offset (0 = top).
finalinherited

Methods

calculateLine(int yoffset) → (int, int, int)
calculateLine taking soft wrapping into account, returns the total viewable lines and the real-line index for the given yoffset, as well as the virtual line offset.
inherited
clearHighlights() → ViewportModel
Clears previously set highlights.
inherited
clearSelection() → ViewportModel
Clears the current selection.
inherited
copyWith({int? width, int? height, int? yOffset, int? xOffset, bool? mouseWheelEnabled, int? mouseWheelDelta, int? horizontalStep, ViewportKeyMap? keyMap, List<String>? lines, int? gutter, bool? softWrap, bool? fillHeight, bool? showLineNumbers, GutterFunc? leftGutterFunc, Style? style, Style? highlightStyle, Style? selectedHighlightStyle, Style styleLineFunc(int lineIndex)?, List<HighlightInfo>? highlights, int? currentHighlightIndex, Object? selectionStart = undefined, Object? selectionEnd = undefined, DateTime? lastClickTime, (int, int)? lastClickPos, DateTime nowProvider()?, List<String>? wrappedLines, List<String>? originalLines, List<StyleRange>? styleRanges}) → TextModel
Creates a copy with the given fields replaced.
override
ensureVisible(int line, int colstart, int colend) → ViewportModel
Ensures that the given line and column are in the viewport.
inherited
getSelectedText() → String
Returns the currently selected text.
inherited
gotoBottom() → ViewportModel
Goes to the bottom of the content.
inherited
gotoTop() → ViewportModel
Goes to the top of the content.
inherited
halfPageDown() → ViewportModel
Moves down by half a page.
inherited
halfPageUp() → ViewportModel
Moves up by half a page.
inherited
highlightNext() → ViewportModel
Moves the viewport to the next highlight.
inherited
highlightPrev() → ViewportModel
Moves the viewport to the previous highlight.
inherited
init() → Cmd?
Returns an optional command to execute on program startup.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pageDown() → ViewportModel
Moves down by one page.
inherited
pageUp() → ViewportModel
Moves up by one page.
inherited
scrollDown(int n) → ViewportModel
Scrolls down by the given number of lines.
inherited
scrollLeft(int n) → ViewportModel
Scrolls left by the given number of columns.
inherited
scrollRight(int n) → ViewportModel
Scrolls right by the given number of columns.
inherited
scrollUp(int n) → ViewportModel
Scrolls up by the given number of lines.
inherited
selectAll() → ViewportModel
Selects all text in the viewport.
inherited
setContent(String content) → TextModel
Sets the content of the viewport.
override
setHighlights(List<List<int>> matches) → ViewportModel
Sets ranges of characters to highlight. For instance, [[2, 10], [20, 30]] will highlight characters 2 to 10 and 20 to 30. Note that highlights are not expected to transpose each other, and are also expected to be in order.
inherited
setXOffset(int n) → ViewportModel
Sets the X offset (clamped to valid range).
inherited
setYOffset(int n) → ViewportModel
Sets the Y offset (clamped to valid range).
inherited
toString() → String
A string representation of this object.
inherited
update(Msg msg) → (TextModel, Cmd?)
Updates the component state in response to a message.
override
view() → String
Renders the current model state for display.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited