Quit with Ctrl+C only; q is an ordinary key everywhere
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
+2
-29
@@ -25,9 +25,6 @@ type view struct {
|
||||
onShow, onHide func()
|
||||
// hints lists the keys that work in this view (shown in the status bar).
|
||||
hints func() string
|
||||
// captureKeys makes the global single-key shortcut (q) stands back
|
||||
// while this view is shown, because its fields take typed text.
|
||||
captureKeys bool
|
||||
}
|
||||
|
||||
// App is the top-level arr-tui application.
|
||||
@@ -160,7 +157,7 @@ func New(cfg *config.Config) *App {
|
||||
{key: '3', name: "Library", body: library.root, onShow: library.activate, hints: libraryHints},
|
||||
{key: '4', name: "Downloads", body: downloads.root, onShow: downloads.activate, onHide: downloads.deactivate, hints: downloads.hints},
|
||||
{key: '5', name: "Calendar", body: calendar.root, onShow: calendar.activate, hints: calendarHints},
|
||||
{key: '6', name: "Config", body: settings.root, onShow: settings.activate, hints: settingsHints, captureKeys: true},
|
||||
{key: '6', name: "Config", body: settings.root, onShow: settings.activate, hints: settingsHints},
|
||||
{key: '7', name: "Log", body: a.logs.root, onShow: a.logs.onShow, hints: logHints},
|
||||
}
|
||||
for i, v := range a.views {
|
||||
@@ -439,11 +436,7 @@ func (a *App) renderStatus() {
|
||||
if v.hints != nil {
|
||||
parts = append(parts, v.hints())
|
||||
}
|
||||
if v.captureKeys { // q is text there
|
||||
parts = append(parts, "F9 help · F1-F7 views")
|
||||
} else {
|
||||
parts = append(parts, "F9 help · F1-F7 · q quit")
|
||||
}
|
||||
parts = append(parts, "F9 help · F1-F7 · Ctrl+C quit")
|
||||
hints = strings.Join(parts, " · ")
|
||||
}
|
||||
a.status.SetText("[gray]" + hints)
|
||||
@@ -533,16 +526,6 @@ func (a *App) onlyFullOverlays() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// typing reports whether keystrokes belong to a text field or dialog and must
|
||||
// not trigger global shortcuts.
|
||||
func (a *App) typing() bool {
|
||||
if len(a.overlays) > 0 || a.views[a.active].captureKeys {
|
||||
return true
|
||||
}
|
||||
_, isInput := a.app.GetFocus().(*tview.InputField)
|
||||
return isInput
|
||||
}
|
||||
|
||||
func (a *App) handleKey(ev *tcell.EventKey) *tcell.EventKey {
|
||||
if ev.Key() == tcell.KeyCtrlC {
|
||||
a.app.Stop()
|
||||
@@ -563,16 +546,6 @@ func (a *App) handleKey(ev *tcell.EventKey) *tcell.EventKey {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if a.typing() {
|
||||
return ev
|
||||
}
|
||||
switch ev.Key() {
|
||||
case tcell.KeyRune:
|
||||
if ev.Rune() == 'q' {
|
||||
a.app.Stop()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return ev
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user