@@ -10,60 +10,47 @@ import (
1010// QuitDialogID is the identifier for the quit dialog.
1111const QuitDialogID = "quit"
1212
13−// QuitDialogKeyMap represents key bindings for the quit dialog.
14−type QuitDialogKeyMap struct {
15− LeftRight,
16− EnterSpace,
17− Yes,
18− No,
19− Tab,
20− Close key.Binding
21−}
22−
23−// DefaultQuitKeyMap returns the default key bindings for the quit dialog.
24−func DefaultQuitKeyMap() QuitDialogKeyMap {
25− return QuitDialogKeyMap{
26− LeftRight: key.NewBinding(
27− key.WithKeys("left", "right"),
28− key.WithHelp("←/→", "switch options"),
29− ),
30− EnterSpace: key.NewBinding(
31− key.WithKeys("enter", " "),
32− key.WithHelp("enter/space", "confirm"),
33− ),
34− Yes: key.NewBinding(
35− key.WithKeys("y", "Y", "ctrl+c"),
36− key.WithHelp("y/Y/ctrl+c", "yes"),
37− ),
38− No: key.NewBinding(
39− key.WithKeys("n", "N"),
40− key.WithHelp("n/N", "no"),
41− ),
42− Tab: key.NewBinding(
43− key.WithKeys("tab"),
44− key.WithHelp("tab", "switch options"),
45− ),
46− Close: key.NewBinding(
47− key.WithKeys("esc", "alt+esc"),
48− key.WithHelp("esc", "cancel"),
49− ),
50− }
51−}
52−
5313// Quit represents a confirmation dialog for quitting the application.
5414type Quit struct {
5515 com *common.Common
56− keyMap QuitDialogKeyMap
5716 selectedNo bool // true if "No" button is selected
17+ keyMap struct {
18+ LeftRight,
19+ EnterSpace,
20+ Yes,
21+ No,
22+ Tab,
23+ Close key.Binding
24+ }
5825}
5926
6027// NewQuit creates a new quit confirmation dialog.
6128func NewQuit(com *common.Common) *Quit {
6229 q := &Quit{
6330 com: com,
64− keyMap: DefaultQuitKeyMap(),
6531 selectedNo: true,
6632 }
33+ q.keyMap.LeftRight = key.NewBinding(
34+ key.WithKeys("left", "right"),
35+ key.WithHelp("←/→", "switch options"),
36+ )
37+ q.keyMap.EnterSpace = key.NewBinding(
38+ key.WithKeys("enter", " "),
39+ key.WithHelp("enter/space", "confirm"),
40+ )
41+ q.keyMap.Yes = key.NewBinding(
42+ key.WithKeys("y", "Y", "ctrl+c"),
43+ key.WithHelp("y/Y/ctrl+c", "yes"),
44+ )
45+ q.keyMap.No = key.NewBinding(
46+ key.WithKeys("n", "N"),
47+ key.WithHelp("n/N", "no"),
48+ )
49+ q.keyMap.Tab = key.NewBinding(
50+ key.WithKeys("tab"),
51+ key.WithHelp("tab", "switch options"),
52+ )
53+ q.keyMap.Close = CloseKey
6754 return q
6855}
6956