buildHelpText constructs the formatted and aligned help text.
(keys config.KeyBindings)
| 56 | |
| 57 | // buildHelpText constructs the formatted and aligned help text. |
| 58 | func buildHelpText(keys config.KeyBindings) string { |
| 59 | globalMenuBinding := "Esc" |
| 60 | if strings.TrimSpace(keys.GlobalMenu) != "" { |
| 61 | globalMenuBinding = fmt.Sprintf("Esc / %s", keys.GlobalMenu) |
| 62 | } |
| 63 | |
| 64 | // Define all help items in sections for clarity |
| 65 | items := []struct { |
| 66 | Cat, Key, Desc string |
| 67 | }{ |
| 68 | {Cat: "[warning]Navigation[-]"}, |
| 69 | {Key: "Arrow Keys / hjkl", Desc: "Navigate lists and panels"}, |
| 70 | {Key: fmt.Sprintf("%s / %s", keys.SwitchView, keys.SwitchViewReverse), Desc: "Switch between views (forward/reverse, including Storage)"}, |
| 71 | {Key: keys.NodesPage, Desc: "Switch to Nodes tab"}, |
| 72 | {Key: keys.GuestsPage, Desc: "Switch to Guests tab"}, |
| 73 | {Key: keys.TasksPage, Desc: "Switch to Tasks tab"}, |
| 74 | {Key: keys.StoragePage, Desc: "Switch to Storage tab"}, |
| 75 | {Key: "gg / G", Desc: "Jump to top/bottom in focused list"}, |
| 76 | {Key: "Tab / Shift+Tab", Desc: "Switch focus between fields and panels"}, |
| 77 | {Cat: ""}, // Spacer |
| 78 | {Cat: "[warning]Actions[-]"}, |
| 79 | {Key: keys.Search, Desc: "Search/Filter current list"}, |
| 80 | {Key: keys.Menu, Desc: "Open context menu"}, |
| 81 | {Key: globalMenuBinding, Desc: "Open global menu"}, |
| 82 | {Key: keys.Refresh, Desc: "Manual refresh"}, |
| 83 | {Key: keys.AutoRefresh, Desc: "Toggle auto-refresh (10s interval)"}, |
| 84 | {Key: keys.Quit, Desc: "Quit application"}, |
| 85 | {Cat: ""}, |
| 86 | {Cat: "[warning]Nodes/Guests Page[-]"}, |
| 87 | {Key: keys.Shell, Desc: "Open SSH shell (when on Nodes/Guests page)"}, |
| 88 | {Key: keys.VNC, Desc: "Open VNC shell/console (when on Nodes/Guests page)"}, |
| 89 | {Key: keys.AdvancedGuestFilter, Desc: "Advanced guest filter modal (Guests page)"}, |
| 90 | {Cat: ""}, |
| 91 | {Cat: "[warning]Storage Page[-]"}, |
| 92 | {Key: "a/0 d i t s b", Desc: "Filter storage content: All, Guest volumes, ISO, Templates, Snippets, Backups"}, |
| 93 | {Key: "r", Desc: "Refresh selected storage content"}, |
| 94 | {Key: "Tab / Shift+Tab", Desc: "Toggle focus between storage details and content"}, |
| 95 | {Key: fmt.Sprintf("%s (tree/details)", keys.Menu), Desc: "Open storage actions (refresh/download/filter)"}, |
| 96 | {Key: fmt.Sprintf("%s (content row)", keys.Menu), Desc: "Open storage content actions (delete/restore where supported)"}, |
| 97 | {Cat: ""}, |
| 98 | {Cat: "[warning]Tasks Page[-]"}, |
| 99 | {Key: keys.TasksToggleQueue, Desc: "Toggle active queue panel visibility"}, |
| 100 | {Key: fmt.Sprintf("%s (Active queue)", keys.TaskStopCancel), Desc: "Cancel queued task / stop running task"}, |
| 101 | {Cat: ""}, |
| 102 | {Cat: "[warning]Tips & Usage[-]"}, |
| 103 | {Desc: fmt.Sprintf("• Use search ([primary]%s[-]) to quickly find nodes or guests.", keys.Search)}, |
| 104 | {Desc: fmt.Sprintf("• The context menu ([primary]%s[-]) provides quick access to actions.", keys.Menu)}, |
| 105 | {Desc: "• Press [primary]Esc[-] to open the global menu for app-wide actions."}, |
| 106 | {Desc: "• When focused in Nodes/Guests/Tasks/Storage lists, use [primary]gg[-]/[primary]G[-] for top/bottom navigation."}, |
| 107 | {Desc: "• VNC opens in your default web browser."}, |
| 108 | {Desc: "• SSH sessions suspend the UI until the session is closed."}, |
| 109 | } |
| 110 | |
| 111 | // Calculate the maximum width of the key column to align descriptions |
| 112 | maxKeyWidth := 0 |
| 113 | |
| 114 | for _, item := range items { |
| 115 | if item.Key != "" { |
no test coverage detected