occupied

package
v0.0.232 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 occupied classifies live composer occupancy by injecting a space and comparing before/after snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExactlyOneMoreSpace

func ExactlyOneMoreSpace(before, after []byte) bool

ExactlyOneMoreSpace reports whether after is before with exactly one ASCII space (0x20) inserted. Both sides are newline-stripped first, then compared byte-by-byte.

Occupied when: len(after)==len(before)+1, the extra byte is ' ', and removing that byte yields before. Empty before is never occupied.

func StripNewlines

func StripNewlines(b []byte) []byte

StripNewlines removes \n and \r so compares ignore line breaks.

Types

type IO

type IO struct {
	Snapshot func() (string, error)
	Inject   func(text string) error // no-submit; Probe sends " " then "\x7f"
	// Before is an optional resting snapshot. When non-empty, Probe skips the
	// first Snapshot call (avoids a duplicate SnapshotText under idle Tick).
	Before string
	// Settle is how long to wait after injecting the space before reading
	// after, and between post-DEL stabilize polls (0 → defaultProbeSettle).
	Settle time.Duration
}

IO is the injectable snapshot/inject surface for Probe.

type Status

type Status string

Status is composer occupancy from a space probe.

const (
	Empty    Status = "empty"
	Occupied Status = "occupied"
	Unknown  Status = "unknown"
)

func Probe

func Probe(io IO) Status

Probe types one space, waits Settle, snapshots, classifies with ExactlyOneMoreSpace, then always DELs the space and waits until Snapshot matches the pre-probe resting text again (or attempts are exhausted).

exactly +1 draft space → Occupied any other / no change → Empty snapshot fail → Unknown inject fail → Empty (cannot prove occupancy; callers that need a hard hold should check Ready/writable separately)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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