@@ -10,60 +10,47 @@ import (
10// QuitDialogID is the identifier for the quit dialog.
10// QuitDialogID is the identifier for the quit dialog.
11const QuitDialogID = "quit"
11const QuitDialogID = "quit"
13−// QuitDialogKeyMap represents key bindings for the quit dialog.
14−type QuitDialogKeyMap struct {
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"),
30− EnterSpace: key.NewBinding(
31− key.WithKeys("enter", " "),
32− key.WithHelp("enter/space", "confirm"),
35− key.WithKeys("y", "Y", "ctrl+c"),
36− key.WithHelp("y/Y/ctrl+c", "yes"),
39− key.WithKeys("n", "N"),
40− key.WithHelp("n/N", "no"),
44− key.WithHelp("tab", "switch options"),
46− Close: key.NewBinding(
47− key.WithKeys("esc", "alt+esc"),
48− key.WithHelp("esc", "cancel"),
53// Quit represents a confirmation dialog for quitting the application.
13// Quit represents a confirmation dialog for quitting the application.
54type Quit struct {
14type Quit struct {
55 com *common.Common
15 com *common.Common
56− keyMap QuitDialogKeyMap
57 selectedNo bool // true if "No" button is selected
16 selectedNo bool // true if "No" button is selected
60// NewQuit creates a new quit confirmation dialog.
27// NewQuit creates a new quit confirmation dialog.
61func NewQuit(com *common.Common) *Quit {
28func NewQuit(com *common.Common) *Quit {
62 q := &Quit{
29 q := &Quit{
64− keyMap: DefaultQuitKeyMap(),
65 selectedNo: true,
31 selectedNo: true,
33+ q.keyMap.LeftRight = key.NewBinding(
34+ key.WithKeys("left", "right"),
35+ key.WithHelp("←/→", "switch options"),
37+ q.keyMap.EnterSpace = key.NewBinding(
38+ key.WithKeys("enter", " "),
39+ key.WithHelp("enter/space", "confirm"),
41+ q.keyMap.Yes = key.NewBinding(
42+ key.WithKeys("y", "Y", "ctrl+c"),
43+ key.WithHelp("y/Y/ctrl+c", "yes"),
45+ q.keyMap.No = key.NewBinding(
46+ key.WithKeys("n", "N"),
47+ key.WithHelp("n/N", "no"),
49+ q.keyMap.Tab = key.NewBinding(
51+ key.WithHelp("tab", "switch options"),
53+ q.keyMap.Close = CloseKey