add a new API to set auto complete

This commit is contained in:
Lu Guanqun 2016-02-23 12:29:23 +08:00
parent 2978660421
commit d45b1ac5fc
2 changed files with 11 additions and 0 deletions

View File

@ -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
View File

@ -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)