package history

Import Path
	github.com/reeflective/readline/internal/history (on go.dev)

Dependency Relation
	imports 14 packages, and imported by 2 packages

Involved Source Files file.go history.go sources.go undo.go
Package-Level Type Names (total 3)
/* sort by: | */
Item is the structure of an individual item in the History.list slice. Block string DateTime time.Time Index int
Source is an interface to allow you to write your own history logging tools. By default readline will just use the dummyLineHistory interface which only logs the history to memory ([]string to be precise). Dump returns everything in readline. The return is an interface{} because not all LineHistory implementations will want to structure the history in the same way. And since Dump() is not actually used by the readline API internally, this methods return can be structured in whichever way is most convenient for your own applications (or even just create an empty function which returns `nil` if you don't require Dump() either) GetLine takes the historic line number and returns the line or an error Len returns the number of history lines Append takes the line and returns an updated number of lines or an error *github.com/pancsta/asyncmachine-go/tools/repl.History func NewInMemoryHistory() Source func NewSourceFromFile(file string) (Source, error) func (*Sources).Current() Source func (*Sources).Add(name string, hist Source)
Sources manages and serves all history sources for the current shell. Accept is used to signal the line has been accepted by the user and must be returned to the readline caller. If hold is true, the line is preserved and redisplayed on the next loop. If infer, the line is not written to the history, but preserved as a line to match against on the next loop. If infer is false, the line is automatically written to active sources. Add adds a source of history lines bound to a given name (printed above this source when used). If the shell currently has only an in-memory (default) history source available, the call will drop this source and replace it with the provided one. Following calls add to the list. AddFromFile adds a command history source from a file path. The name is used when using/searching the history source. Current returns the current/active history source. Cycle checks for the next history source (if any) and makes it the active one. The active one is used in completions, and all history-related commands. If next is false, the engine cycles to the previous source. Delete deletes one or more history source by name. If no arguments are passed, all currently bound sources are removed. Fetch fetches the history event at the provided index position and makes it the current buffer. GetLast returns the last saved history line in the active history source. InferNext finds a line matching the current line in the history, then finds the line event following it and, if any, inserts it. InsertMatch replaces the buffer with the first history line matching the provided buffer, either as a substring (if regexp is true), or as a prefix. If the line argument is nil, the current line buffer is used to match against. Last returns the last command ran by the shell. LineAccepted returns true if the user has accepted the line, signaling that the shell must return from its loop. The error can be nil, but may indicate a CtrlC/CtrlD style error. Name returns the name of the currently active history source. OnLastSource returns true if the currently active history source is the last one in the list. Pos returns the current position in the undo history, which is equal to its length minus the number of previous undo calls. Redo cancels an undo action if any has been made, or if at the begin of the undo history, restores the original line's contents as their were before starting undoing. Reset will reset the current position in the list of undo items, but will not delete any of them. Revert goes back to the initial state of the line, which is what it was like when the shell started reading user input. Note that this state might be a line that was inferred, accept-and-held from the previous readline run. Save saves the current line and cursor position as an undo state item. If this was called while the shell was in the middle of its undo history (eg. the caller has undone one or more times), all undone steps are dropped. SaveWithCommand is only meant to be called in the main readline loop of the shell, and not from within commands themselves: it does the same job as Save(), but also keeps the command that has just been executed. SkipSave will not save the current line when the target command is done (more precisely, the next call to h.Save() will have no effect). This function is not useful is most cases, as call to saves will efficiently compare the line with the last saved state, and will not add redundant ones. Suggest returns the first line matching the current line buffer, so that caller can use for things like history autosuggestion. If no line matches the current line, it will return the latter. Undo restores the line and cursor position to their last saved state. Walk goes to the next or previous history line in the active source. If at the beginning of the history, the first history line is kept. If at the end of it, the main input buffer and cursor position is restored. Write writes the accepted input line to all available sources. If infer is true, the next history initialization will automatically insert the next history line event after the first match of the line, which one is then NOT written. *Sources : github.com/polarsignals/frostdb/query/logicalplan.Named func NewSources(line *core.Line, cur *core.Cursor, hint *ui.Hint, opts *inputrc.Config) *Sources func Complete(h *Sources, forward, filter bool, maxLines int, regex *regexp.Regexp) completion.Values func Init(hist *Sources) func github.com/reeflective/readline/internal/display.NewEngine(k *core.Keys, s *core.Selection, h *Sources, p *ui.Prompt, i *ui.Hint, c *completion.Engine, opts *inputrc.Config) *display.Engine
Package-Level Functions (total 5)
Complete returns completions with the current history source values. If forward is true, the completions are proposed from the most ancient line in the history source to the most recent. If filter is true, only lines that match the current input line as a prefix are given.
Init initializes the history sources positions and buffers at the start of each readline loop. If the last command asked to infer a command line from the history, it is performed now.
NewInMemoryHistory creates a new in-memory command history source.
NewSourceFromFile returns a new history source writing to and reading from a file.
NewSources is a required constructor for the history sources manager type.