selection

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteClipboard

func WriteClipboard(content string) tea.Cmd

WriteClipboard writes content to the system clipboard via OSC 52.

func WriteClipboardTarget

func WriteClipboardTarget(content string, target ClipboardTarget) tea.Cmd

WriteClipboardTarget writes content to a specific clipboard target via OSC 52.

Types

type ClipboardTarget

type ClipboardTarget string

ClipboardTarget represents the OSC 52 clipboard target.

const (
	// ClipboardSystem is the system clipboard target.
	ClipboardSystem ClipboardTarget = "c"
	// ClipboardPrimary is the primary selection target (X11).
	ClipboardPrimary ClipboardTarget = "p"
)

type ClipboardWriteMsg

type ClipboardWriteMsg struct {
	Content string
	Target  ClipboardTarget
	Err     error
}

ClipboardWriteMsg is returned after attempting to write clipboard content.

type SelectableRegion

type SelectableRegion struct {
	StartRow     int
	EndRow       int
	GutterWidth  int
	ContentLines []string
}

SelectableRegion defines the content area that can be selected.

type Selection

type Selection struct {
	Active         bool
	StartX, StartY int
	EndX, EndY     int
}

Selection stores the current selection coordinates.

type SelectionManager

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

SelectionManager handles mouse-based text selection.

func NewSelectionManager

func NewSelectionManager(opts ...SelectionOption) *SelectionManager

NewSelectionManager creates a new selection manager.

func (*SelectionManager) ClearSelection

func (sm *SelectionManager) ClearSelection()

ClearSelection resets the selection state.

func (*SelectionManager) CopySelection

func (sm *SelectionManager) CopySelection() tea.Cmd

CopySelection returns a command that copies selected text to clipboard.

func (*SelectionManager) GetSelectedText

func (sm *SelectionManager) GetSelectedText() string

GetSelectedText returns the selected text content.

func (*SelectionManager) HandleMouse

func (sm *SelectionManager) HandleMouse(msg tea.MouseMsg) bool

HandleMouse handles mouse events for selection.

func (*SelectionManager) HasSelection

func (sm *SelectionManager) HasSelection() bool

HasSelection reports whether there is a finalized selection.

func (*SelectionManager) IsSelected

func (sm *SelectionManager) IsSelected(row, col int) bool

IsSelected reports whether the content-relative position is selected.

func (*SelectionManager) SetOffset

func (sm *SelectionManager) SetOffset(x, y int)

SetOffset sets the screen offset of the component.

func (*SelectionManager) SetRegion

func (sm *SelectionManager) SetRegion(region SelectableRegion)

SetRegion sets the selectable region.

func (*SelectionManager) StyledLine

func (sm *SelectionManager) StyledLine(line string, row int) string

StyledLine applies highlighting to selected spans on a line.

type SelectionOption

type SelectionOption func(*SelectionManager)

SelectionOption configures a SelectionManager.

func WithSelectionDesignTokens

func WithSelectionDesignTokens(tokens *design.DesignTokens) SelectionOption

WithSelectionDesignTokens applies design tokens to selection rendering.

func WithSelectionTheme

func WithSelectionTheme(theme string) SelectionOption

WithSelectionTheme applies a named design-system theme.

Jump to

Keyboard shortcuts

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