Skip to content

Commit

Permalink
refactor: Quit on Ctrl-Q instead Ctrl-C
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Dec 10, 2023
1 parent 5c84b31 commit 82b348a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 56,7 @@ $ deepl-tui --auth-key=f63c02c5-f056...
| Focus input text area | `alt-i` | |
| Focus source language dropdown | `alt-s` | Hit `enter` to list options |
| Focus target language dropdown | `alt-t` | Hit `enter` to list options |
| Close the application | `ctrl-c` | |
| Quit the application | `ctrl-q` | |

## Changelog

Expand Down
9 changes: 9 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 107,14 @@ func NewUI() *UI {

func (ui *UI) registerKeybindings() {
ui.Application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyCtrlC:
// don't quit here
return nil
case tcell.KeyCtrlQ:
ui.Application.Stop()
}

if event.Modifiers() == tcell.ModAlt {
if event.Key() == tcell.KeyTab {
ui.cycePage()
Expand All @@ -119,6 127,7 @@ func (ui *UI) registerKeybindings() {
return nil
}
}

return event
})
}
Expand Down

0 comments on commit 82b348a

Please sign in to comment.