Skip to content

Commit

Permalink
Change KeyBindMode to a numeric type
Browse files Browse the repository at this point in the history
  • Loading branch information
Verseth committed Jul 12, 2023
1 parent 0465814 commit 14a5059
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions key_bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type ASCIICodeBind struct {
}

// KeyBindMode to switch a key binding flexibly.
type KeyBindMode string
type KeyBindMode uint8

const (
// CommonKeyBind is a mode without any keyboard shortcut
CommonKeyBind KeyBindMode = "common"
CommonKeyBind KeyBindMode = iota
// EmacsKeyBind is a mode to use emacs-like keyboard shortcut
EmacsKeyBind KeyBindMode = "emacs"
EmacsKeyBind
)

var commonKeyBindings = []KeyBind{
Expand Down
3 changes: 2 additions & 1 deletion prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ func (p *Prompt) handleKeyBinding(key Key) bool {
}
}

if p.keyBindMode == EmacsKeyBind {
switch p.keyBindMode {
case EmacsKeyBind:
for i := range emacsKeyBindings {
kb := emacsKeyBindings[i]
if kb.Key == key {
Expand Down

0 comments on commit 14a5059

Please sign in to comment.