Merge pull request #141 from VonC/arrow
Down Arrow for first completion
This commit is contained in:
commit
b662637d18
|
@ -206,6 +206,14 @@ func OptionSwitchKeyBindMode(m KeyBindMode) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OptionCompletionOnDown allows for Down arrow key to trigger completion.
|
||||||
|
func OptionCompletionOnDown() Option {
|
||||||
|
return func(p *Prompt) error {
|
||||||
|
p.completionOnDown = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SwitchKeyBindMode to set a key bind mode.
|
// SwitchKeyBindMode to set a key bind mode.
|
||||||
// Deprecated: Please use OptionSwitchKeyBindMode.
|
// Deprecated: Please use OptionSwitchKeyBindMode.
|
||||||
var SwitchKeyBindMode = OptionSwitchKeyBindMode
|
var SwitchKeyBindMode = OptionSwitchKeyBindMode
|
||||||
|
|
|
@ -25,6 +25,7 @@ type Prompt struct {
|
||||||
keyBindings []KeyBind
|
keyBindings []KeyBind
|
||||||
ASCIICodeBindings []ASCIICodeBind
|
ASCIICodeBindings []ASCIICodeBind
|
||||||
keyBindMode KeyBindMode
|
keyBindMode KeyBindMode
|
||||||
|
completionOnDown bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec is the struct contains user input context.
|
// Exec is the struct contains user input context.
|
||||||
|
@ -148,7 +149,7 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) {
|
||||||
func (p *Prompt) handleCompletionKeyBinding(key Key, completing bool) {
|
func (p *Prompt) handleCompletionKeyBinding(key Key, completing bool) {
|
||||||
switch key {
|
switch key {
|
||||||
case Down:
|
case Down:
|
||||||
if completing {
|
if completing || p.completionOnDown {
|
||||||
p.completion.Next()
|
p.completion.Next()
|
||||||
}
|
}
|
||||||
case Tab, ControlI:
|
case Tab, ControlI:
|
||||||
|
|
Loading…
Reference in New Issue