Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions select.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type SelectKeys struct {

// Search is the key used to trigger the search mode for the list. Default to the "/" key.
Search Key

// Exit is the key used to correctly shutdown the process. Default to the "q" key.
Exit Key
}

// Key defines a keyboard code and a display representation for the help menu.
Expand Down Expand Up @@ -273,6 +276,12 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
} else {
searchMode = true
}
case key == s.Keys.Exit.Code:
clearScreen(sb)
rl.Write([]byte(showCursor))
rl.Clean()
rl.Close()
os.Exit(0)
case key == KeyBackspace:
if !canSearch || !searchMode {
break
Expand Down Expand Up @@ -578,6 +587,7 @@ func (s *Select) setKeys() {
PageUp: Key{Code: KeyBackward, Display: KeyBackwardDisplay},
PageDown: Key{Code: KeyForward, Display: KeyForwardDisplay},
Search: Key{Code: '/', Display: "/"},
Exit: Key{Code: 'q', Display: "q"},
}
}

Expand Down