forked from mirror/readline
Merge pull request #32 from guanqun/add-api-for-set-completion
add a new API to set auto complete
This commit is contained in:
commit
a0bb3f70e4
|
@ -405,6 +405,10 @@ func (op *Operation) SetConfig(cfg *Config) (*Config, error) {
|
|||
// so if we use it next time, we need to reopen it by `InitHistory()`
|
||||
op.history.Init()
|
||||
|
||||
if op.cfg.AutoComplete != nil {
|
||||
op.opCompleter = newOpCompleter(op.buf.w, op)
|
||||
}
|
||||
|
||||
op.opSearch = cfg.opSearch
|
||||
return old, nil
|
||||
}
|
||||
|
|
7
std.go
7
std.go
|
@ -33,6 +33,13 @@ func SetHistoryPath(fp string) {
|
|||
ins.SetConfig(cfg)
|
||||
}
|
||||
|
||||
func SetAutoComplete(completer AutoCompleter) {
|
||||
ins := getInstance()
|
||||
cfg := ins.Config.Clone()
|
||||
cfg.AutoComplete = completer
|
||||
ins.SetConfig(cfg)
|
||||
}
|
||||
|
||||
func AddHistory(content string) error {
|
||||
ins := getInstance()
|
||||
return ins.SaveHistory(content)
|
||||
|
|
Loading…
Reference in New Issue