keywrites

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 6 Imported by: ? 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 keywrites runs the writes a tab's keys start: off the screen's loop, queued in the order the keys started them and run one at a time, on the strip while they run and on the footer once each ends, and awaited by quitting. It keeps each row a write is pending on until a read begun after the write shows it, so a tab refuses a second key on that row.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ended

type Ended struct {
	Said   string
	Failed bool
}

Ended is how one write ended: what its Run answered, or why it did not land.

type Pending

type Pending struct {
	Doing   string
	Running bool
	Ended   time.Time
	Fault   string
}

Pending is a row's newest write, from the key that queued it until a read begun after it ended lands, or for good where it failed. Running says it left the queue. Ended is when it landed, and Fault why it failed.

func (Pending) Refusal

func (p Pending) Refusal() string

Refusal is why a key on the row refuses while its write is pending, or empty where it does not. A failed write refuses nothing, so the row takes its next key.

type Write

type Write struct {
	Doing string
	Run   func() (string, error)
	Row   string
}

Write is one write a key started. Row is the key of the one row the write acts on, which then stays pending, or empty for a write that reaches no one row.

type Writes

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

Writes is a tab's queue of writes. One runs at a time, because two on one row would each act on what the other moved. A key never waits on the queue, so the next key starts at once.

func (*Writes) Await

func (w *Writes) Await(announce func(doing []string)) []Ended

Await waits for every write running or queued to end, then answers how each ended, in order. announce hears what it waits for before the wait starts, in the same step that finds them, so no write ends unheard between the two. Nothing under way returns nil and announces nothing. Quitting calls it, so the process never exits under a write half done or one a key queued and nothing ran.

func (*Writes) Line

func (w *Writes) Line(now time.Time) gotermboard.Line

Line is the strip's line about the writes: what runs and for how long in yellow, red once it is overdue, with how many wait behind it, then what the newest did, for saidFor, or why it was refused in red. The footer says the whole answer when a write ends, so here an answer of several lines reads as one, and the screen's edge cuts it.

func (*Writes) Pending

func (w *Writes) Pending(row string) (Pending, bool)

Pending is row's pending write, if it has one.

func (*Writes) PendingRows

func (w *Writes) PendingRows() map[string]Pending

PendingRows is every row a write is pending on, by its key.

func (*Writes) SayEnded

func (w *Writes) SayEnded()

SayEnded puts the newest ended write's whole answer on the footer, wrapped, which the strip's one line cuts. It runs as the frame is built, on the screen's loop.

func (*Writes) Settle

func (w *Writes) Settle(readFrom time.Time)

Settle lets go of every row whose write landed before a read that began at readFrom, because that read shows what the write did. A failed row stays until the next write on it.

func (*Writes) Start

func (w *Writes) Start(m *gotermboard.Model, write Write, reread func()) tea.Cmd

Start queues write, and returns the drain that runs the queue where none runs yet. A drain already running takes the write once those ahead of it end, so Start then returns nil.

func (*Writes) Writing

func (w *Writes) Writing() bool

Writing says a write runs or waits in the queue, without waiting for it.

Jump to

Keyboard shortcuts

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