KillRing
Ring buffer for Emacs-style kill/yank operations. The PHP port of pi-tui's `KillRing`. Tracks killed (deleted) text entries so the user can yank (paste) them back. Consecutive kills can accumulate into a single entry — backward deletion prepends, forward deletion appends — matching the Emacs behavior a `Ctrl+W` / `Ctrl+U` / `Alt+D` key handler chain expects. Pure state holder — not a renderer, not a contract. A `text-input` or `editor` key handler owns one instance and feeds it as the user deletes text; the yank handler reads from it. The ring is bounded only by usage; in practice a few entries are enough.
KillRing::push()
public function push(string $text, array $opts): voidAdds killed text to the ring. When `accumulate` is true and the ring is non-empty, merges with the most recent entry instead of pushing a new one — prepending for backward deletion, appending for forward deletion. Empty text is a no-op.
Parameters
| Name | Type | Description |
|---|---|---|
| $text | string | |
| $opts | array{prepend: bool, accumulate?: bool} |
KillRing::peek()
public function peek(): ?stringReturns the most recent entry without modifying the ring, or `null` when empty.
KillRing::rotate()
public function rotate(): voidRotates the last entry to the front so the next {@see peek()} returns the previous kill — the "yank-pop" cycle. A no-op when the ring holds fewer than two entries.
KillRing::length()
public function length(): intHow many entries the ring currently holds.
KillRing::clear()
public function clear(): void