Documentation ¶
Index ¶
- func AutopairDelete(line *core.Line, cur *core.Cursor)
- func AutopairInsertOrJump(key rune, line *core.Line, cur *core.Cursor) (skipInsert bool)
- 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, ...)
- func UpdateInserted(eng *Engine)
- type Candidate
- type Completer
- type Engine
- func (e *Engine) AutoCompleting() bool
- func (e *Engine) Autocomplete()
- func (e *Engine) AutocompleteForce()
- func (e *Engine) Cancel(inserted, cached bool)
- func (e *Engine) ClearMenu(completions bool)
- func (e *Engine) CompleteSyntax(completer func([]rune, int) ([]rune, int))
- func (e *Engine) Generate(completions Values)
- func (e *Engine) GenerateWith(completer Completer)
- func (e *Engine) GetBuffer() (*core.Line, *core.Cursor, *core.Selection)
- func (e *Engine) IsActive() bool
- func (e *Engine) IsInserting() bool
- func (e *Engine) IsearchStart(name string, autoinsert, replaceLine bool)
- func (e *Engine) IsearchStop(revertLine bool)
- func (e *Engine) Line() (*core.Line, *core.Cursor)
- func (e *Engine) Matches() int
- func (e *Engine) NonIncrementallySearching() (searching, forward, substring bool)
- func (e *Engine) NonIsearchStart(name string, repeat, forward, substring bool)
- func (e *Engine) NonIsearchStop()
- func (e *Engine) Reset()
- func (e *Engine) ResetForce()
- func (e *Engine) Select(row, column int)
- func (e *Engine) SelectTag(next bool)
- func (e *Engine) SkipDisplay()
- func (e *Engine) TrimSuffix()
- func (e *Engine) UpdateIsearch()
- type Messages
- type RawValues
- type SuffixMatcher
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutopairDelete ¶
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.
func AutopairInsertOrJump ¶
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.
func Coordinates ¶
Coordinates returns the number of terminal rows used when displaying the completions with Display().
func Display ¶
Display prints the current completion list to the screen, respecting the current display and completion settings.
func Init ¶
func Init(eng *Engine, k *core.Keys, l *core.Line, cur *core.Cursor, s *core.Selection, comp Completer)
Init is used once at shell creation time to pass further parameters to the engine.
func UpdateInserted ¶
func UpdateInserted(eng *Engine)
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.
Types ¶
type Candidate ¶
type Candidate struct { Value string // Value is the value of the completion as actually inserted in the line Display string // When display is not nil, this string is used to display the completion in the menu. Description string // A description to display next to the completion candidate. Style string // An arbitrary string of color/text effects to use when displaying the completion. Tag string // All completions with the same tag are grouped together and displayed under the tag heading. // contains filtered or unexported fields }
Candidate represents a completion candidate.
type Completer ¶
type Completer func() 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.
type Engine ¶
type Engine struct { // Incremental search IsearchRegex *regexp.Regexp // Holds the current search regex match // contains filtered or unexported fields }
Engine is responsible for all completion tasks: generating, computing, displaying and updating completion values and inserted candidates.
func (*Engine) AutoCompleting ¶
AutoCompleting returns true if the completion engine is an autocompletion mode that has been triggered by a particular command (like history-search-forward/backward).
func (*Engine) Autocomplete ¶
func (e *Engine) Autocomplete()
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.
func (*Engine) AutocompleteForce ¶
func (e *Engine) AutocompleteForce()
AutocompleteForce forces as-you-type autocomplete on the real input line, even if the current cursor position is 0.
func (*Engine) Cancel ¶
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.
func (*Engine) ClearMenu ¶
ClearMenu exits the current completion keymap (if set) and clears the current list of generated completions (if completions is true).
func (*Engine) CompleteSyntax ¶
CompleteSyntax updates the line with either user-defined syntax completers, or with the builtin ones.
func (*Engine) Generate ¶
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.
func (*Engine) GenerateWith ¶
GenerateWith generates completions with a completer function, itself cached so that the next time it must update its results, it can reuse this completer.
func (*Engine) GetBuffer ¶
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.
func (*Engine) IsActive ¶
IsActive indicates if the engine is currently in possession of a non-empty list of generated completions (following all constraints).
func (*Engine) IsInserting ¶
IsInserting returns true if a candidate is currently virtually inserted.
func (*Engine) IsearchStart ¶
IsearchStart starts incremental search (fuzzy-finding) with values matching the isearch minibuffer as a regexp.
func (*Engine) IsearchStop ¶
IsearchStop exists the incremental search mode, and drops the currently used regexp matcher. If revertLine is true, the original line is restored.
func (*Engine) Line ¶
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.
func (*Engine) Matches ¶
Matches returns the number of completion candidates matching the current line/settings requirements.
func (*Engine) NonIncrementallySearching ¶
NonIncrementallySearching returns true if the completion engine is currently using a minibuffer for non-incremental search mode.
func (*Engine) NonIsearchStart ¶
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.
func (*Engine) NonIsearchStop ¶
func (e *Engine) NonIsearchStop()
NonIsearchStop exits the non-incremental search mode.
func (*Engine) Reset ¶
func (e *Engine) Reset()
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.
func (*Engine) ResetForce ¶
func (e *Engine) ResetForce()
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.
func (*Engine) Select ¶
Select moves the completion selector by some X or Y value, and updates the inserted candidate in the input line.
func (*Engine) SelectTag ¶
SelectTag allows to select the first value of the next tag (next=true), or the last value of the previous tag (next=false).
func (*Engine) SkipDisplay ¶
func (e *Engine) SkipDisplay()
SkipDisplay avoids printing completions below the input line, but still enables cycling through them.
func (*Engine) TrimSuffix ¶
func (e *Engine) TrimSuffix()
TrimSuffix removes the last inserted completion's suffix if the required constraints are satisfied (among which the index position, the suffix matching patterns, etc).
func (*Engine) UpdateIsearch ¶
func (e *Engine) UpdateIsearch()
UpdateIsearch recompiles the isearch buffer as a regex and filters matching candidates in the available completions.
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
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.
type RawValues ¶
type RawValues []Candidate
RawValues is a list of completion candidates.
func (RawValues) FilterPrefix ¶
FilterPrefix filters values with given prefix. If matchCase is false, the filtering is made case-insensitive. This function ensures that all spaces are correctly.
type SuffixMatcher ¶
type SuffixMatcher struct {
// contains filtered or unexported fields
}
SuffixMatcher is a type managing suffixes for a given list of completions.
func (*SuffixMatcher) Add ¶
func (sm *SuffixMatcher) Add(suffixes ...rune)
Add adds new suffixes to the matcher.
func (SuffixMatcher) Matches ¶
func (sm SuffixMatcher) Matches(s string) bool
Matches returns true if the given string matches one of the suffixes.
func (*SuffixMatcher) Merge ¶
func (sm *SuffixMatcher) Merge(other SuffixMatcher)
Merge merges two suffix matchers.
type Values ¶
type Values struct { Messages Messages NoSpace SuffixMatcher Usage string ListLong map[string]bool NoSort map[string]bool ListSep map[string]string Pad map[string]bool Escapes map[string]bool // 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. PREFIX string // 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. SUFFIX string // contains filtered or unexported fields }
Values is used internally to hold all completion candidates and their associated data.