feat(help): open a searchable shortcuts panel from help

Running help without arguments in the kitty shell now opens a categorized,
searchable reference in a left dock instead of a pager. The new kitten collects
the effective bindings and hands them to the palette in read-only mode.
This commit is contained in:
BlackAngelTV committed 2026-11-12 12:43:46 +01:00
1 parent 45a16ea61c
commit 81df6f2d3a
3 files changed
+67 -4

No files matched your search

+19 -4
View File
@@ -97,6 +97,21 @@ func shell_loop(rl *readline.Readline, kill_if_signaled bool) (int, error) {
return 0, nil
}
// launch_shortcuts_panel opens the searchable keybinding reference in a dock,
// next to the terminal, instead of taking over the shell window.
func launch_shortcuts_panel() int {
kitty := utils.KittyExe()
if kitty == "" {
kitty = "kitty"
}
root := cli.NewRootCommand()
EntryPoint(root)
return root.ExecArgs([]string{
"kitten", "@", "launch", "--type=window-dock", "--dock-edge=left", "--dock-size=60",
kitty, "+kitten", "help",
})
}
func show_basic_help() {
output := strings.Builder{}
fmt.Fprintln(&output, "Control kitty by sending it commands.")
@@ -110,7 +125,7 @@ func show_basic_help() {
}
}
fmt.Fprintln(&output, " ", formatter.Green("help"))
fmt.Fprintln(&output, " ", "Show this help")
fmt.Fprintln(&output, " ", "Show keyboard shortcuts")
fmt.Fprintln(&output, " ", formatter.Green("exit"))
fmt.Fprintln(&output, " ", "Exit this shell")
cli.ShowHelpInPager(output.String())
@@ -136,14 +151,14 @@ func exec_command(at_root_command *cli.Command, rl *readline.Readline, cmdline s
hi.ExitCode = 0
defer rl.AddHistoryItem(hi)
if len(parsed_cmdline) == 1 {
show_basic_help()
hi.ExitCode = launch_shortcuts_panel()
return true
}
switch parsed_cmdline[1] {
case "exit":
fmt.Println("Exit this shell")
case "help":
fmt.Println("Show help")
fmt.Println("Show keyboard shortcuts")
default:
sc := at_root_command.FindSubCommand(parsed_cmdline[1])
if sc == nil {
@@ -190,7 +205,7 @@ func completions(before_cursor, after_cursor string) (ans *cli.Completions) {
}
x.ShortDescription = desc
}
add_sc("help", "Show help")
add_sc("help", "Show keyboard shortcuts")
add_sc("exit", "Exit the kitty shell")
root.Validate()
ans = root.GetCompletions(argv, nil)