Candidate represents a completion candidate. // A description to display next to the completion candidate. // When display is not nil, this string is used to display the completion in the menu. // An arbitrary string of color/text effects to use when displaying the completion. // All completions with the same tag are grouped together and displayed under the tag heading. // Value is the value of the completion as actually inserted in the line
func AddRaw(values []Candidate) Values
Completer is a function generating completions.
This is generally used so that a given completer function
(history, registers, etc) can be cached and reused by the engine.
func Init(eng *Engine, k *core.Keys, l *core.Line, cur *core.Cursor, s *core.Selection, comp Completer)
func (*Engine).GenerateWith(completer Completer)
Engine is responsible for all completion tasks: generating, computing,
displaying and updating completion values and inserted candidates. Incremental search // Holds the current search regex match AutoCompleting returns true if the completion engine is an
autocompletion mode that has been triggered by a particular
command (like history-search-forward/backward). Autocomplete generates the correct completions in autocomplete mode.
We don't do it when we are currently in the completion keymap,
since that means completions have already been computed. AutocompleteForce forces as-you-type autocomplete on the
real input line, even if the current cursor position is 0. Cancel exits the current completions with the following behavior:
- If inserted is true, any inserted candidate is removed.
- If cached is true, any cached completer function is dropped.
This function does not exit the completion keymap, so
any active completion menu will still be kept/displayed. ClearMenu exits the current completion keymap (if set) and clears
the current list of generated completions (if completions is true). CompleteSyntax updates the line with either user-defined syntax completers, or with the builtin ones. Generate uses a list of completions to group/order and prepares completions before printing them.
If either no completions or only one is available after all constraints are applied, the engine
will automatically insert/accept and/or reset itself. GenerateCached simply recomputes the grid of completions with the pool
of completions already in memory. This might produce a bigger/smaller/
different completion grid, for example if it's called on terminal resize. GenerateWith generates completions with a completer function, itself cached
so that the next time it must update its results, it can reuse this completer. GetBuffer returns the correct input line buffer (and its cursor/
selection) depending on the context and active components:
- If in non/incremental-search mode, the minibuffer.
- If a completion is currently inserted, the completed line.
- If neither of the above, the normal input line. IsActive indicates if the engine is currently in possession of a
non-empty list of generated completions (following all constraints). IsInserting returns true if a candidate is currently virtually inserted. IsearchStart starts incremental search (fuzzy-finding)
with values matching the isearch minibuffer as a regexp. IsearchStop exists the incremental search mode,
and drops the currently used regexp matcher.
If revertLine is true, the original line is restored. Line returns the relevant input line at the time this function is called:
if a candidate is currently selected, the line returned is the one containing
the candidate. If no candidate is selected, the normal input line is returned.
When the line returned is the completed one, the corresponding, adjusted cursor. Matches returns the number of completion candidates
matching the current line/settings requirements. NonIncrementallySearching returns true if the completion engine
is currently using a minibuffer for non-incremental search mode. NonIsearchStart starts a non-incremental, fake search mode:
it does not produce or tries to match against completions,
but uses a minibuffer similarly to incremental search mode. NonIsearchStop exits the non-incremental search mode. Reset accepts the currently inserted candidate (if any), clears the current
list of completions and exits the incremental-search mode if active.
If the completion engine was not active to begin with, nothing will happen. ResetForce drops any currently inserted candidate from the line,
drops any cached completer function and generated list, and exits
the incremental-search mode.
All those steps are performed whether or not the engine is active.
If revertLine is true, the line will be reverted to its original state. Select moves the completion selector by some X or Y value,
and updates the inserted candidate in the input line. SelectTag allows to select the first value of the next tag (next=true),
or the last value of the previous tag (next=false). SkipDisplay avoids printing completions below the
input line, but still enables cycling through them. TrimSuffix removes the last inserted completion's suffix if the required constraints
are satisfied (among which the index position, the suffix matching patterns, etc). UpdateIsearch recompiles the isearch buffer as a regex and
filters matching candidates in the available completions.
func NewEngine(h *ui.Hint, km *keymap.Engine, o *inputrc.Config) *Engine
func Coordinates(e *Engine) int
func Display(eng *Engine, maxRows int)
func Init(eng *Engine, k *core.Keys, l *core.Line, cur *core.Cursor, s *core.Selection, comp Completer)
func UpdateInserted(eng *Engine)
func github.com/reeflective/readline/internal/display.NewEngine(k *core.Keys, s *core.Selection, h *history.Sources, p *ui.Prompt, i *ui.Hint, c *Engine, opts *inputrc.Config) *display.Engine
Messages is a list of messages to be displayed
below the input line, above completions. It is
used to show usage and/or error status hints. Add adds a message to the list of messages. Get returns the list of messages to display. IsEmpty returns true if there are no messages to display. Merge merges the given messages into the current list of messages. Suppress removes messages matching the given regular expressions from the list of messages.
func (*Messages).Merge(other Messages)
RawValues is a list of completion candidates. EachTag iterates over each tag and runs a function for each group. Filter filters values. FilterPrefix filters values with given prefix.
If matchCase is false, the filtering is made case-insensitive.
This function ensures that all spaces are correctly.( RawValues) Len() int( RawValues) Less(i, j int) bool( RawValues) Swap(i, j int)
RawValues : sort.Interface
func RawValues.Filter(values ...string) RawValues
func RawValues.FilterPrefix(prefix string, matchCase bool) RawValues
SuffixMatcher is a type managing suffixes for a given list of completions. Add adds new suffixes to the matcher. Matches returns true if the given string matches one of the suffixes. Merge merges two suffix matchers.
func (*SuffixMatcher).Merge(other SuffixMatcher)
Values is used internally to hold all completion candidates and their associated data.Escapesmap[string]boolListLongmap[string]boolListSepmap[string]stringMessagesMessagesNoSortmap[string]boolNoSpaceSuffixMatcher Initially this will be set to the part of the current word
from the beginning of the word up to the position of the cursor.
It may be altered to give a prefix for all matches.Padmap[string]bool Initially this will be set to the part of the current word,
starting from the cursor position up to the end of the word.
It may be altered so that inserted completions don't overwrite
entirely any suffix when completing in the middle of a word.Usagestring Merge merges a set of values with the current ones,
include usage/message strings, meta settings, etc.
func AddRaw(values []Candidate) Values
func github.com/reeflective/readline/internal/editor.(*Buffers).Complete() Values
func github.com/reeflective/readline/internal/history.Complete(h *history.Sources, forward, filter bool, maxLines int, regex *regexp.Regexp) Values
func (*Engine).Generate(completions Values)
func (*Values).Merge(other Values)
Package-Level Functions (total 8)
AddRaw adds completion values in bulk.
AutopairDelete checks if the character under the cursor is an opening pair
character which is immediately followed by its closing equivalent. If yes,
the closing character is removed.
AutopairInsertOrJump checks if the character to be inserted in the line is a pair character.
If the character is an opening one, its inserted along with its closing equivalent.
If it's a closing one and the next character in line is the same, the cursor jumps over it.
Coordinates returns the number of terminal rows used
when displaying the completions with Display().
Display prints the current completion list to the screen,
respecting the current display and completion settings.
Init is used once at shell creation time to pass further parameters to the engine.
NewEngine initializes a new completion engine with the shell operating parameters.
UpdateInserted should be called only once in between the two shell keymaps
(local/main) in the main readline loop, to either drop or confirm a virtually
inserted candidate.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.