Skip to content

Commit

Permalink
Make ctrl+c not quit wander in exec session (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 authored Nov 12, 2023
1 parent 15cfb6c commit d256856
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/tui/components/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ func (m *Model) handleKeyMsg(msg tea.KeyMsg) tea.Cmd {
saving := m.currentPageViewportSaving()
enteringInput := currentPageModel != nil && currentPageModel.EnteringInput()
typingQLegitimately := msg.String() == "q" && (addingQToFilter || saving || enteringInput || m.inPty)
if !typingQLegitimately || m.err != nil {
ctrlCInPty := m.inPty && msg.String() == "ctrl+c"
if (!ctrlCInPty && !typingQLegitimately) || m.err != nil {
return m.cleanupCmd()
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/tui/nomad/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func GetKeypress(msg tea.KeyMsg) (keypress string) {
}
case tea.KeyCtrlD:
keypress = string(rune(4))
case tea.KeyCtrlC:
keypress = string(rune(3))
case tea.KeyTab:
keypress = string(rune(9))
case tea.KeyUp:
Expand Down
9 changes: 7 additions & 2 deletions internal/tui/nomad/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ func GetPageKeyHelp(
changeKeyHelp(&keymap.KeyMap.Compact, "compact")
}

if filterFocused || enteringInput {
keymap.KeyMap.Exit.SetHelp("ctrl+c", "exit")
} else {
keymap.KeyMap.Exit.SetHelp("q/ctrl+c", "exit")
}

firstRow := []key.Binding{keymap.KeyMap.Exit}

if !saving && !filterFocused {
Expand Down Expand Up @@ -446,8 +452,7 @@ func GetPageKeyHelp(
}
if inPty {
changeKeyHelp(&keymap.KeyMap.Back, "disable input")
secondRow = []key.Binding{keymap.KeyMap.Back}
return getShortHelp(firstRow) + "\n" + getShortHelp(secondRow)
return getShortHelp([]key.Binding{keymap.KeyMap.Back})
} else {
if webSocketConnected {
changeKeyHelp(&keymap.KeyMap.Forward, "enable input")
Expand Down

0 comments on commit d256856

Please sign in to comment.