forked from mirror/readline
add a new API to set auto complete
This commit is contained in:
parent
2978660421
commit
d45b1ac5fc
|
@ -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()`
|
// so if we use it next time, we need to reopen it by `InitHistory()`
|
||||||
op.history.Init()
|
op.history.Init()
|
||||||
|
|
||||||
|
if op.cfg.AutoComplete != nil {
|
||||||
|
op.opCompleter = newOpCompleter(op.buf.w, op)
|
||||||
|
}
|
||||||
|
|
||||||
op.opSearch = cfg.opSearch
|
op.opSearch = cfg.opSearch
|
||||||
return old, nil
|
return old, nil
|
||||||
}
|
}
|
||||||
|
|
7
std.go
7
std.go
|
@ -33,6 +33,13 @@ func SetHistoryPath(fp string) {
|
||||||
ins.SetConfig(cfg)
|
ins.SetConfig(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetAutoComplete(completer AutoCompleter) {
|
||||||
|
ins := getInstance()
|
||||||
|
cfg := ins.Config.Clone()
|
||||||
|
cfg.AutoComplete = completer
|
||||||
|
ins.SetConfig(cfg)
|
||||||
|
}
|
||||||
|
|
||||||
func AddHistory(content string) error {
|
func AddHistory(content string) error {
|
||||||
ins := getInstance()
|
ins := getInstance()
|
||||||
return ins.SaveHistory(content)
|
return ins.SaveHistory(content)
|
||||||
|
|
Loading…
Reference in New Issue