textedit

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteOffsetForColumn

func ByteOffsetForColumn(line string, col int) int

ByteOffsetForColumn returns the byte offset of the grapheme boundary in line whose display column is the greatest not exceeding col (clamped to len).

func ByteOffsetForWrappedCell

func ByteOffsetForWrappedCell(line string, targetRow, col, width int) int

func DisplayColumnAtOrAfter

func DisplayColumnAtOrAfter(line string, col int) int

func HorizontalWindowLine

func HorizontalWindowLine(line string, offset, width int) string

func HorizontalWindowLineWithSelection

func HorizontalWindowLineWithSelection(line string, offset, width int, selStart, selEnd int, hasSelection bool, render func(text string, selected bool) string) string

func HorizontalWindowLines

func HorizontalWindowLines(lines []string, offset, width int) string

func PositionForVisualCell

func PositionForVisualCell(lines []string, visualRow, col, width int) (row, byteCol int)

func RenderLineWithSelection

func RenderLineWithSelection(line string, selStart, selEnd int, hasSelection bool, render func(text string, selected bool) string) string

func SoftWrapLine

func SoftWrapLine(line string, width int) []string

func SoftWrapLineWithSelection

func SoftWrapLineWithSelection(line string, width int, selStart, selEnd int, hasSelection bool, render func(text string, selected bool) string) []string

func TotalWrappedRows

func TotalWrappedRows(lines []string, width int) int

func VisibleWrappedLines

func VisibleWrappedLines(lines []string, width, height, offset int) string

func VisualCursorRow

func VisualCursorRow(lines []string, row, col, width int) int

func VisualRowsBefore

func VisualRowsBefore(lines []string, row, width int) int

func WrappedCursorCell

func WrappedCursorCell(line string, col, width int) (x, y int)

Types

type Area

type Area struct {
	Lines         []string
	Row, Col      int
	Width, Height int
	Wrap          bool
}

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

func (a Area) CursorCell(s Scroll) (x, y int)

CursorCell is the cursor's cell relative to the window scrolled by s.

func (Area) KeepVisible

func (a Area) KeepVisible(s Scroll) Scroll

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.

type Scroll

type Scroll struct{ Offset, XOffset, WrapOffset int }

Scroll is a text window's scroll state: the first visible line (without wrapping), the first visible display column (without wrapping), and the first visible visual row (with wrapping).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL