class
TermBuf::History
- TermBuf::History
- Reference
- Object
Overview
Lines entered earlier, and a walk back through them.
Off by default and bounded when on. What separates this from an array is the line being typed when the walk starts: it is put aside and restored on the way back down, which is what people expect and what most implementations forget.
Defined in:
termbuf/widgets/history.crConstructors
Instance Method Summary
-
#add(entry : String) : Nil
Records entry and ends any walk in progress.
-
#capacity : Int32
How many entries to keep.
-
#clear : Nil
Forgets everything.
-
#empty? : Bool
Whether nothing has been recorded.
-
#entries : Array(String)
Newest last, which is the order a history file is written in.
-
#load(io : IO) : Nil
Reads entries written by
#save, appending to whatever is already here. -
#next : String | Nil
Steps forward one entry.
-
#previous(current : String) : String | Nil
Steps back one entry, given the line currently being typed.
-
#reset : Nil
Abandons the walk, so the next
#previousstarts from the live line again. -
#save(io : IO) : Nil
Writes one entry per line.
-
#search : Search
Which entries
#previousvisits. -
#search=(search : Search)
Which entries
#previousvisits. -
#size : Int32
How many entries are held.
-
#walking? : Bool
Whether a walk is under way.
Constructor Detail
Instance Method Detail
Records entry and ends any walk in progress.
A blank line is not worth recalling, and neither is a line identical to the one before it: a history full of the same command is a history of one command.
Steps forward one entry. Returns what to put in its place, which at the end of the walk is the line that was being typed when it started.
Steps back one entry, given the line currently being typed. Returns what
to put in its place, or nil when there is nowhere further back.
Abandons the walk, so the next #previous starts from the live line
again. Anything that edits the line should do this.
Writes one entry per line. Where that goes, and whether it goes anywhere, is the application's business: the shard does not decide where a history file lives or what it is called.