highlight

package
v1.22.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package highlight provides text selection and highlighting utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(content string, area image.Rectangle, startLine, startCol, endLine, endCol int, h Highlighter) string

Apply applies highlighting to a region of rendered ANSI content.

func Buffer

func Buffer(content string, area image.Rectangle, startLine, startCol, endLine, endCol int, h Highlighter) *uv.ScreenBuffer

Buffer applies highlighting to a region and returns the screen buffer.

func Extract

func Extract(content string, area image.Rectangle, startLine, startCol, endLine, endCol int) string

Extract returns plain text from a region of rendered content.

Types

type Highlighter

type Highlighter func(x, y int, c *uv.Cell) *uv.Cell

Highlighter defines how to style a cell during highlighting.

var Default Highlighter = func(x, y int, c *uv.Cell) *uv.Cell {
	if c == nil {
		return c
	}
	c.Style.Attrs |= uv.AttrReverse
	return c
}

Default applies inverse style (reverse video) to cells.

func FromStyle

func FromStyle(s lipgloss.Style) Highlighter

FromStyle converts a lipgloss.Style to a Highlighter.

func WithColors

func WithColors(bg, fg color.Color) Highlighter

WithColors creates a highlighter using specific background and foreground colors.

Jump to

Keyboard shortcuts

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