ansis

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StylesEqual

func StylesEqual(a, b lipgloss.Style) bool

StylesEqual compares two lipgloss.Style objects for equality. This is a simple comparison that checks if the rendered output would be the same.

Types

type StyleEditor

type StyleEditor struct{}

StyleEditor handles applying style transformations to ANSI-styled text. It preserves existing ANSI styling while adding new styling to specific character ranges. It can be used for search highlighting, error marking, syntax emphasis, or any other inline style modifications.

func NewStyleEditor

func NewStyleEditor() *StyleEditor

NewStyleEditor creates a new StyleEditor.

func (*StyleEditor) ApplyStyles

func (ise *StyleEditor) ApplyStyles(text string, ranges []StyleRange) string

ApplyStyles applies style ranges to ANSI-styled text while preserving existing styling. The ranges are applied in priority order, with higher priority ranges overriding lower ones.

type StyleRange

type StyleRange struct {
	Style    lipgloss.Style // The style to apply to this range.
	Start    int            // 0-based character position within the line (inclusive).
	End      int            // 0-based character position within the line (exclusive).
	Priority int            // Priority for overlapping ranges (higher priority wins).
}

StyleRange represents a range of text that should have a specific style applied.

Jump to

Keyboard shortcuts

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