mouse

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mark

func Mark(name, content string) string

Mark wraps content with mouse-tracking markers using the default tracker.

func ParseCSIParam

func ParseCSIParam(s string) int

ParseCSIParam parses a single integer from a CSI parameter string.

func Resolve

func Resolve(x, y int) string

Resolve returns the innermost zone at (x, y) using the default tracker.

func Sweep

func Sweep(content string) string

Sweep strips markers and records screen coordinates using the default tracker.

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer tokenizes a string containing ANSI escape sequences.

func NewLexer

func NewLexer(input string) Lexer

NewLexer creates a new lexer for the given input.

func (*Lexer) Next

func (l *Lexer) Next() Token

Next returns the next token from the input.

type Token

type Token struct {
	Type   TokenType
	Text   string // The raw text of the token
	Params string // CSI: parameter bytes between ESC[ and final byte
	Final  byte   // CSI: command byte; ESC: second byte
}

Token represents a lexical token in an ANSI stream.

type TokenType

type TokenType int

TokenType identifies the kind of token.

const (
	TextToken TokenType = iota
	CSIToken
	OSCToken
	ESCToken
	EOFToken
)

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker tracks clickable regions in rendered content using zero-width ANSI markers. Mark wraps content with marker pairs during View, Sweep strips them and builds a coordinate map, and Resolve matches mouse clicks to the innermost marked region.

func (*Tracker) Mark

func (mt *Tracker) Mark(name, content string) string

Mark wraps content with a pair of zero-width CSI markers that will be resolved to screen coordinates during Sweep.

func (*Tracker) Resolve

func (mt *Tracker) Resolve(x, y int) string

Resolve returns the name of the innermost zone containing (x, y), or "" if no zone matches. Inner zones appear before outer zones in the list (their end markers are encountered first during Sweep), so the first match is the most deeply nested.

func (*Tracker) Sweep

func (mt *Tracker) Sweep(content string) string

Sweep scans rendered content, strips mouse-tracking markers, and records the screen coordinates of each marked region. Returns cleaned content suitable for screen rendering.

Jump to

Keyboard shortcuts

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