program

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 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 program is the in-program half of rexuikit/surface: what a bubbletea program running inside a surface needs to see focus the way Rex delivers it. It is the only part of surface that imports bubbletea, so a placer that never runs a TUI does not link it.

Rex forwards terminal focus reports (DECSET 1004) to the focused block, but how many depends on the app: the live tests saw exactly one ESC[I and one ESC[O per change with no app drawing the window, and one in plus two out with the app drawing it (rex-behaviors.md; livetest TestFocusReportsForwarded). Dedupe therefore collapses identical consecutive reports that arrive close together and never pair-counts, so a Rex that sends each report once, twice, or unevenly all read the same.

Index

Constants

View Source
const DefaultDedupeWindow = 50 * time.Millisecond

DefaultDedupeWindow is how close two identical focus reports must be to count as one. Rex's duplicates arrive back to back; a real focus change back to the same state needs a different report in between anyway.

Variables

This section is empty.

Functions

func Unwrap

func Unwrap(m tea.Model) tea.Model

Unwrap returns the inner model of a Model, or m itself.

Types

type Dedupe

type Dedupe struct {
	Window time.Duration
	Now    func() time.Time
	// contains filtered or unexported fields
}

Dedupe drops a focus report identical to the previous one when it arrives within Window of it. The zero value uses DefaultDedupeWindow and the wall clock.

func (*Dedupe) Duplicate

func (d *Dedupe) Duplicate(msg tea.Msg) bool

Duplicate reports whether msg is a FocusMsg or BlurMsg repeating the previous report within the window, and records it otherwise. Any other message passes through and leaves the state alone: a keypress between two identical reports does not make the second one a new change.

type Model

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

Model wraps a program's model: it turns on focus reporting, drops duplicate focus reports before the inner model sees them, and applies the surface's BlurPolicy.

func Wrap

func Wrap(m tea.Model, opts Options) Model

Wrap returns m wrapped. Run the result with tea.NewProgram and Unwrap the final model.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update forwards msg unless it is a duplicate focus report. Under CloseOnBlur a blur still reaches the inner model first, so it can tidy up, and the program quits after its command.

func (Model) View

func (m Model) View() tea.View

View is the inner view with focus reporting on: bubbletea v2 enables DECSET 1004 from the view, not from a program option.

type Options

type Options struct {
	Blur surface.BlurPolicy
	// Dedupe overrides the duplicate filter's window and clock (tests).
	Dedupe Dedupe
}

Options configure Wrap.

Jump to

Keyboard shortcuts

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