occupied

package
v0.0.178 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 2 Imported by: 0

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 into real draft text. Both sides are newline-stripped first, then compared byte-by-byte.

Not occupied when:

  • before is empty
  • the space is inserted into an existing space run (padding)
  • the space is inserted immediately after a composer/chrome glyph (›»❯│…)

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 (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.

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