diff --git a/src/uxBlock/prompt.go b/src/uxBlock/prompt.go index 7a95fa8f..8495a5ff 100644 --- a/src/uxBlock/prompt.go +++ b/src/uxBlock/prompt.go @@ -67,24 +67,27 @@ func (m *promptModel) Init() tea.Cmd { func (m *promptModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg, ok := msg.(tea.KeyMsg); ok { - switch msg.String() { - case "ctrl+c": + //nolint:exhaustive + switch msg.Type { + case tea.KeyCtrlC: m.canceled = true return m, tea.Quit - case "left": + case tea.KeyLeft: if m.cursor > 0 { m.cursor-- } - case "right": + case tea.KeyRight: if m.cursor < len(m.choices)-1 { m.cursor++ } - case "enter": + + case tea.KeyEnter: m.quiting = true return m, tea.Quit + default: } } @@ -96,7 +99,7 @@ func (m *promptModel) View() string { return "" } - buttonsTexts := []string{} + var buttonsTexts []string for i, choice := range m.choices { if i == m.cursor { buttonsTexts = append(buttonsTexts, styles.ActiveDialogButton().Render(choice)) diff --git a/src/uxBlock/select.go b/src/uxBlock/select.go index 3495944e..bbdcec25 100644 --- a/src/uxBlock/select.go +++ b/src/uxBlock/select.go @@ -96,21 +96,36 @@ func (m *selectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if !ok { return m, nil } - switch keyMsg.String() { - case "ctrl+c": + + //nolint:exhaustive + switch keyMsg.Type { + case tea.KeyCtrlC: m.canceled = true return m, tea.Quit - case "up": + case tea.KeyUp: if m.cursor > 0 { m.cursor-- } - case "down": + case tea.KeyDown: if m.cursor < len(m.tableBody.rows)-1 { m.cursor++ } - case "enter": + + case tea.KeyPgUp: + m.cursor -= 5 + if m.cursor < 0 { + m.cursor = 0 + } + + case tea.KeyPgDown: + m.cursor += 5 + if lastItemIndex := len(m.tableBody.rows) - 1; m.cursor > lastItemIndex { + m.cursor = lastItemIndex + } + + case tea.KeyEnter: m.quiting = true if !m.cfg.multiSelect { diff --git a/src/uxBlock/spinner.go b/src/uxBlock/spinner.go index d7e74cc9..46874ceb 100644 --- a/src/uxBlock/spinner.go +++ b/src/uxBlock/spinner.go @@ -79,7 +79,7 @@ func (m *spinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit case tea.KeyMsg: - if msg.String() == "ctrl+c" { + if msg.Type == tea.KeyCtrlC { m.canceled = true m.quiting = true return m, tea.Quit