class
Crystallabs::Helpers::KillRing
- Crystallabs::Helpers::KillRing
- Reference
- Object
Overview
An emacs/readline-style kill ring: the shared text register that readline
editing keys push deleted text into (Ctrl-W / Ctrl-U / Ctrl-K /
Alt-D) and Ctrl-Y yanks back.
As in emacs, consecutive kills accumulate into one entry (so Ctrl-K Ctrl-K
yanks both lines, and a backward kill prepends) until a non-kill action calls
#interrupt. Older entries are retained up to #capacity for a future
yank-pop.
Defined in:
crystallabs-helpers.crConstructors
-
.default : KillRing
Shared default ring (all inputs of a program, unless overridden).
- .new(capacity : Int32 = 60)
Class Method Summary
-
.default=(default : KillRing)
Shared default ring (all inputs of a program, unless overridden).
Instance Method Summary
-
#capacity : Int32
Maximum number of entries kept (older ones are dropped).
-
#capacity=(capacity : Int32)
Maximum number of entries kept (older ones are dropped).
-
#clear : Nil
Drops all entries (and resets the accumulation flag).
-
#entries : Array(String)
Kill entries, oldest first; the last is what
#yankreturns. -
#interrupt : Nil
Marks that a non-kill action happened, so the next kill starts a new entry.
-
#kill(text : String, *, prepend : Bool = false) : Nil
Records text as a kill.
-
#yank : String | Nil
The most-recently killed text (what
Ctrl-Yyanks), ornilwhen empty.
Constructor Detail
Shared default ring (all inputs of a program, unless overridden).
Class Method Detail
Shared default ring (all inputs of a program, unless overridden).
Instance Method Detail
Records text as a kill. A backward kill (prepend true — Ctrl-W /
Ctrl-U) joins the front of the current entry; a forward kill (prepend
false — Ctrl-K / Alt-D) joins the back. Consecutive kills merge; an
intervening #interrupt starts a fresh entry. Empty text is ignored.