Documentation
¶
Overview ¶
Package textedit lays out editable text in terminal cells: soft wrapping by grapheme clusters, horizontal windows, selection runs, and the scroll that keeps a cursor visible. flatui.Textarea and the multi-line layout.Input share it, so the widget and the node cannot render differently.
Index ¶
- func ByteOffsetForColumn(line string, col int) int
- func ByteOffsetForWrappedCell(line string, targetRow, col, width int) int
- func DisplayColumnAtOrAfter(line string, col int) int
- func HorizontalWindowLine(line string, offset, width int) string
- func HorizontalWindowLineWithSelection(line string, offset, width int, selStart, selEnd int, hasSelection bool, ...) string
- func HorizontalWindowLines(lines []string, offset, width int) string
- func PositionForVisualCell(lines []string, visualRow, col, width int) (row, byteCol int)
- func RenderLineWithSelection(line string, selStart, selEnd int, hasSelection bool, ...) string
- func SoftWrapLine(line string, width int) []string
- func SoftWrapLineWithSelection(line string, width int, selStart, selEnd int, hasSelection bool, ...) []string
- func TotalWrappedRows(lines []string, width int) int
- func VisibleWrappedLines(lines []string, width, height, offset int) string
- func VisualCursorRow(lines []string, row, col, width int) int
- func VisualRowsBefore(lines []string, row, width int) int
- func WrappedCursorCell(line string, col, width int) (x, y int)
- type Area
- type Scroll
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteOffsetForColumn ¶
ByteOffsetForColumn returns the byte offset of the grapheme boundary in line whose display column is the greatest not exceeding col (clamped to len).
func DisplayColumnAtOrAfter ¶
func HorizontalWindowLine ¶
func HorizontalWindowLines ¶
func PositionForVisualCell ¶
func RenderLineWithSelection ¶
func SoftWrapLine ¶
func TotalWrappedRows ¶
func VisibleWrappedLines ¶
func VisualCursorRow ¶
func VisualRowsBefore ¶
func WrappedCursorCell ¶
Types ¶
type Area ¶
Area is lines shown in a window width×height cells (0: unbounded), soft wrapped or not, with the cursor at (Row, Col), Col a byte offset.
func (Area) CursorCell ¶
CursorCell is the cursor's cell relative to the window scrolled by s.
func (Area) KeepVisible ¶
KeepVisible returns s scrolled so the cursor's row and column are inside the window, moving it as little as possible.
func (Area) Render ¶
func (a Area) Render(s Scroll, selection func(row int) (start, end int, ok bool), render func(text string, selected bool) string) string
Render returns the window scrolled by s, one row per line. selection reports the selected byte range of a line (ok false: none); render styles each run of selected or unselected text.