Documentation ¶
Overview ¶
Package Complete provides functions for text completion
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendSeed ¶
func ExtendSeed(matches Completions, seed string) string
ExtendSeed tries to extend the current seed checking possible completions for a longer common seed e.g. if the current seed is "ab" and the completions are "abcde" and "abcdf" then Extend returns "cd" but if the possible completions are "abcde" and "abz" then Extend returns ""
func HasUpperCase ¶
HasUpperCase returns true if string has an upper-case letter
func MatchSeedString ¶
MatchSeed returns a list of matches given a list of string possibilities and a seed. The seed is basically a prefix.
func SeedWhiteSpace ¶
SeedWhiteSpace returns the text after the last whitespace
Types ¶
type Completion ¶
type Completion struct { Text string `desc:"completion text -- what will actually be inserted if selected"` Label string `desc:"label to show the user -- only used for menu display if non-empty -- otherwise Text is used"` Icon string `desc:"icon name"` Desc string `desc:"possible extra information, e.g. type, arguments, etc. - not currently used"` Extra map[string]string `desc:"lang specific or other, e.g. class or type"` }
Completion holds one potential completion
func MatchSeedCompletion ¶
func MatchSeedCompletion(completions []Completion, seed string) (matches []Completion)
MatchSeedCompletion returns a list of matching completion structs given a list of possibilities and a seed. The seed is basically a prefix.
type Completions ¶
type Completions []Completion
Completions is a full list (slice) of completion options
type EditData ¶
type EditData struct { NewText string `desc:"completion text after special edits"` ForwardDelete int `desc:"number of runes, past the cursor, to delete, if any"` CursorAdjust int `desc:"cursor adjustment if cursor should be placed in a location other than at end of newText"` }
EditData is returned from completion edit function to incorporate the selected completion
type EditFunc ¶
type EditFunc func(data interface{}, text string, cursorPos int, completion Completion, seed string) EditData
EditFunc is passed the current text and the selected completion for text editing. Allows for other editing, e.g. adding "()" or adding "/", etc.
type MatchData ¶
type MatchData struct { Matches Completions `desc:"the matches based on seed"` Seed string `desc:"seed is the prefix we use to find possible completions"` }
MatchData is used for passing completions around -- contains seed in addition to completions