@@ -1225,36 +1225,77 @@ func max(a, b int) int {
12251225}
12261226
12271227func (m Model ) helpView () string {
1228- helpRequest := []struct {
1229- key , desc string
1230- }{
1231- {"?" , "Toggle Help" },
1232- {"q / esc" , "Quit / Close Help" },
1233- {"/" , "Filter Logs" },
1234- {"f" , "Toggle Follow" },
1235- {"j / k" , "Scroll Down / Up" },
1236- {"g / G" , "Scroll Top / Bottom" },
1237- {"m" , "Toggle Bookmark" },
1228+ // Define helper struct for keys
1229+ type helpEntry struct {
1230+ key , desc string
1231+ }
1232+
1233+ // Group keys
1234+ general := []helpEntry {
1235+ {"?" , "Close Help" },
1236+ {"q / esc" , "Quit / Close" },
1237+ {"ctrl+c" , "Quit" },
1238+ }
1239+
1240+ nav := []helpEntry {
1241+ {"j / k" , "Scroll Down / Up" },
1242+ {"g / G" , "Scroll Top / Bottom" },
1243+ {"f" , "Toggle Follow" },
12381244 {"J" , "Jump to Time" },
1245+ {"space" , "Page Down" },
1246+ {"b / u" , "PgUp / PgDown" },
1247+ }
1248+
1249+ filtering := []helpEntry {
1250+ {"/" , "Filter Logs" },
1251+ {"c" , "Clear Filters" },
1252+ {"R" , "Regex Toggle" },
1253+ {"s / e" , "Set Start / End (Time)" },
1254+ {"1-4" , "Toggle Levels (Err/Warn...)" },
1255+ }
1256+
1257+ viewing := []helpEntry {
1258+ {"w" , "Toggle Wrap" },
1259+ {"z" , "Fold Stack Traces" },
12391260 {"t" , "Toggle Timeline" },
1261+ {"m" , "Toggle Bookmark" },
1262+ {"l / h" , "Scroll Right / Left" },
12401263 {"r" , "Reload File" },
1241- {"c" , "Clear Filters" },
1242- }
1243-
1244- s := lipgloss .NewStyle ().
1245- Border (lipgloss .RoundedBorder ()).
1246- BorderForeground (lipgloss .Color ("62" )).
1247- Padding (1 , 2 )
1248-
1249- var b strings.Builder
1250- b .WriteString (lipgloss .NewStyle ().Bold (true ).Render ("Keyboard Shortcuts" ))
1251- b .WriteString ("\n \n " )
1264+ }
12521265
1253- for _ , h := range helpRequest {
1254- key := lipgloss .NewStyle ().Foreground (lipgloss .Color ("205" )).Width (12 ).Render (h .key )
1255- desc := lipgloss .NewStyle ().Foreground (lipgloss .Color ("240" )).Render (h .desc )
1256- b .WriteString (fmt .Sprintf ("%s %s\n " , key , desc ))
1257- }
1266+ // Styles
1267+ boxStyle := lipgloss .NewStyle ().
1268+ Border (lipgloss .RoundedBorder ()).
1269+ BorderForeground (lipgloss .Color ("62" )).
1270+ Padding (1 , 2 ).
1271+ Margin (1 )
1272+
1273+ headerStyle := lipgloss .NewStyle ().
1274+ Foreground (lipgloss .Color ("240" )).
1275+ Bold (true ).
1276+ Underline (true ).
1277+ MarginBottom (1 )
1278+
1279+ keyStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("205" ))
1280+ descStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("252" ))
1281+
1282+ // Helper to render a column
1283+ renderColumn := func (title string , entries []helpEntry ) string {
1284+ s := headerStyle .Render (title ) + "\n "
1285+ for _ , e := range entries {
1286+ k := keyStyle .Width (10 ).Render (e .key )
1287+ d := descStyle .Render (e .desc )
1288+ s += fmt .Sprintf ("%s %s\n " , k , d )
1289+ }
1290+ return s
1291+ }
1292+
1293+ // Layout
1294+ col1 := renderColumn ("General" , general ) + "\n " + renderColumn ("Navigation" , nav )
1295+ col2 := renderColumn ("Filtering" , filtering ) + "\n " + renderColumn ("View & Tools" , viewing )
1296+
1297+ // Join columns with gap
1298+ content := lipgloss .JoinHorizontal (lipgloss .Top , col1 , " " , col2 )
12581299
1259- return s .Render (b . String () )
1300+ return boxStyle .Render (content )
12601301}
0 commit comments