Skip to content

Fix help menu key binding - enable both Ctrl+? and Ctrl+H #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ The output format is implemented as a strongly-typed `OutputFormat` in the codeb
| Shortcut | Action |
| -------- | ------------------------------------------------------- |
| `Ctrl+C` | Quit application |
| `Ctrl+?` | Toggle help dialog |
| `Ctrl+?` / `Ctrl+H` | Toggle help dialog |
| `?` | Toggle help dialog (when not in editing mode) |
| `Ctrl+L` | View logs |
| `Ctrl+A` | Switch session |
| `Ctrl+S` | Switch session |
| `Ctrl+K` | Command dialog |
| `Ctrl+O` | Toggle model selection dialog |
| `Esc` | Close current overlay/dialog or return to previous mode |
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/components/core/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var helpWidget = ""
// getHelpWidget returns the help widget with current theme colors
func getHelpWidget() string {
t := theme.CurrentTheme()
helpText := "ctrl+? help"
helpText := "ctrl+?/ctrl+h help"

return styles.Padded().
Background(t.TextMuted()).
Expand Down
11 changes: 9 additions & 2 deletions internal/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var keys = keyMap{
key.WithHelp("ctrl+c", "quit"),
),
Help: key.NewBinding(
key.WithKeys("ctrl+_", "ctrl+h"),
key.WithHelp("ctrl+?", "toggle help"),
key.WithKeys("ctrl+?", "ctrl+/", "ctrl+_", "ctrl+h", "delete", "backspace"),
key.WithHelp("ctrl+?/ctrl+h", "toggle help"),
),

SwitchSession: key.NewBinding(
Expand Down Expand Up @@ -443,6 +443,13 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, nil

case tea.KeyMsg:
// Special handling for Ctrl+? which might be interpreted as ESC in some terminals
if msg.Type == tea.KeyEsc && !a.showQuit && !a.showHelp && !a.showSessionDialog && !a.showCommandDialog && !a.showFilepicker && !a.showModelDialog && !a.showMultiArgumentsDialog {
// If ESC is pressed and no dialogs are open, treat it as potential Ctrl+? for help
a.showHelp = !a.showHelp
return a, nil
}

// If multi-arguments dialog is open, let it handle the key press first
if a.showMultiArgumentsDialog {
args, cmd := a.multiArgumentsDialog.Update(msg)
Expand Down