Skip to main content

sql_cli/
help_text.rs

1use ratatui::style::{Color, Modifier, Style};
2use ratatui::text::Line;
3
4/// Manages help text content for the TUI
5/// Extracted from the monolithic `enhanced_tui.rs`
6pub struct HelpText;
7
8impl HelpText {
9    /// Get the left column content for help display
10    #[must_use]
11    pub fn left_column() -> Vec<Line<'static>> {
12        vec![
13            Line::from("SQL CLI Help - Enhanced Features").style(
14                Style::default()
15                    .fg(Color::Cyan)
16                    .add_modifier(Modifier::BOLD),
17            ),
18            Line::from(""),
19            Line::from("COMMAND MODE").style(
20                Style::default()
21                    .fg(Color::Yellow)
22                    .add_modifier(Modifier::BOLD),
23            ),
24            Line::from("  Enter    - Execute query"),
25            Line::from("  Tab      - Auto-complete"),
26            Line::from("  F2       - Switch to Results mode"),
27            Line::from("  Ctrl+R   - Search history"),
28            Line::from("  Ctrl+P   - Previous command in history"),
29            Line::from("  Ctrl+N   - Next command in history"),
30            Line::from("  Alt+↑    - Previous command (alternative)"),
31            Line::from("  Alt+↓    - Next command (alternative)"),
32            Line::from("  Ctrl+X   - Expand SELECT * to all columns"),
33            Line::from("  Alt+X    - Expand SELECT * to visible columns only"),
34            Line::from("  F3       - Show pretty-printed query"),
35            Line::from(""),
36            Line::from("NAVIGATION").style(
37                Style::default()
38                    .fg(Color::Yellow)
39                    .add_modifier(Modifier::BOLD),
40            ),
41            Line::from("  Ctrl+A   - Beginning of line"),
42            Line::from("  Ctrl+E   - End of line"),
43            Line::from("  Ctrl+←   - Move backward word"),
44            Line::from("  Ctrl+→   - Move forward word"),
45            Line::from("  Alt+B    - Move backward word (bash-style)"),
46            Line::from("  Alt+F    - Move forward word (bash-style)"),
47            Line::from(""),
48            Line::from("EDITING").style(
49                Style::default()
50                    .fg(Color::Yellow)
51                    .add_modifier(Modifier::BOLD),
52            ),
53            Line::from("  Ctrl+W   - Delete word backward"),
54            Line::from("  Alt+D    - Delete word forward"),
55            Line::from("  Ctrl+K   - Kill to end of line"),
56            Line::from("  Ctrl+U   - Kill to beginning of line"),
57            Line::from("  F9       - Kill to end (Ctrl+K alternative)"),
58            Line::from("  F10      - Kill to beginning (Ctrl+U alternative)"),
59            Line::from("  Ctrl+Y   - Yank (paste from kill ring)"),
60            Line::from("  Ctrl+V   - Paste from system clipboard"),
61            Line::from("  Ctrl+Z   - Undo"),
62            Line::from("  Alt+,    - Jump to previous SQL token (Alt+[ if terminal allows)"),
63            Line::from("  Alt+.    - Jump to next SQL token (or Alt+])"),
64            Line::from(""),
65            Line::from("BUFFER MANAGEMENT (works in Command & Results modes)").style(
66                Style::default()
67                    .fg(Color::Yellow)
68                    .add_modifier(Modifier::BOLD),
69            ),
70            Line::from("  F11           - Previous buffer"),
71            Line::from("  Ctrl+PgUp     - Previous buffer (alternative)"),
72            Line::from("  Ctrl+PgDn     - Next buffer"),
73            Line::from("  Ctrl+6        - Quick switch (toggle last two)"),
74            Line::from("  Alt+N         - New buffer"),
75            Line::from("  Alt+W         - Close buffer"),
76            Line::from("  Alt+B         - List buffers"),
77            Line::from("  Alt+1-9       - Switch to buffer N"),
78            Line::from(""),
79            Line::from("VIEW MODES").style(
80                Style::default()
81                    .fg(Color::Yellow)
82                    .add_modifier(Modifier::BOLD),
83            ),
84            Line::from("  F1/?     - Toggle this help"),
85            Line::from("  F5       - Debug info"),
86            Line::from("  F6       - Toggle row numbers"),
87            Line::from("  F8       - Case-insensitive"),
88            Line::from("  ↓        - Enter results mode"),
89            Line::from("  Ctrl+C/q - Exit"),
90            Line::from(""),
91            Line::from("FEATURES").style(
92                Style::default()
93                    .fg(Color::Magenta)
94                    .add_modifier(Modifier::BOLD),
95            ),
96            Line::from("  • Column statistics (S key)"),
97            Line::from("  • Column pinning (p/P keys)"),
98            Line::from("  • Dynamic column sizing"),
99            Line::from("  • Compact mode (C key)"),
100            Line::from("  • Rainbow parentheses"),
101            Line::from("  • Auto-execute CSV/JSON"),
102            Line::from("  • Multi-source indicators"),
103            Line::from("  • LINQ-style null checking"),
104            Line::from("  • Row numbers (N key)"),
105            Line::from("  • Jump to row (: key)"),
106        ]
107    }
108
109    /// Get the right column content for help display
110    #[must_use]
111    pub fn right_column() -> Vec<Line<'static>> {
112        vec![
113            Line::from("Use ↓/↑ or j/k to scroll help").style(Style::default().fg(Color::DarkGray)),
114            Line::from(""),
115            Line::from("RESULTS NAVIGATION").style(
116                Style::default()
117                    .fg(Color::Yellow)
118                    .add_modifier(Modifier::BOLD),
119            ),
120            Line::from("  j/↓      - Next row"),
121            Line::from("  k/↑      - Previous row"),
122            Line::from("  h/←      - Previous column"),
123            Line::from("  l/→      - Next column"),
124            Line::from("  5j       - Move down 5 rows (vim counts)"),
125            Line::from("  3k       - Move up 3 rows (vim counts)"),
126            Line::from("  10l      - Move right 10 columns"),
127            Line::from("  g        - First row"),
128            Line::from("  G        - Last row"),
129            Line::from("  H        - Top of viewport"),
130            Line::from("  M        - Middle of viewport"),
131            Line::from("  L        - Bottom of viewport"),
132            Line::from("  0/^      - First column"),
133            Line::from("  $        - Last column"),
134            Line::from("  PgDn     - Page down"),
135            Line::from("  PgUp     - Page up"),
136            Line::from(""),
137            Line::from("RESULTS FEATURES").style(
138                Style::default()
139                    .fg(Color::Yellow)
140                    .add_modifier(Modifier::BOLD),
141            ),
142            Line::from("  C        - Toggle compact (binary on/off)"),
143            Line::from("  Alt+S    - Cycle column packing"),
144            Line::from("             (Balanced / Data Focus / Header Focus)"),
145            Line::from("  N        - Toggle row nums"),
146            Line::from("  :        - Jump to row"),
147            Line::from("  Space    - Toggle viewport lock"),
148            Line::from("  Ctrl+Space - Toggle viewport lock (alternative)"),
149            Line::from("  x/X      - Toggle cursor lock"),
150            Line::from("  p        - Pin/unpin column"),
151            Line::from("  P        - Clear all pins"),
152            Line::from("  -        - Hide current column"),
153            Line::from("  e/E      - Hide empty columns"),
154            Line::from("  +/=      - Unhide all columns"),
155            Line::from("  <        - Move column left"),
156            Line::from("  >        - Move column right"),
157            Line::from("  /        - Vim search (type, Enter to confirm)"),
158            Line::from("  n        - Next search match"),
159            Line::from("  N        - Previous search match"),
160            Line::from("  \\        - Search column names"),
161            Line::from("  Shift+F  - Filter rows (regex)"),
162            Line::from("  f        - Fuzzy filter rows"),
163            Line::from("  'text    - Exact match filter"),
164            Line::from("             (matches highlighted)"),
165            Line::from("  v        - Toggle cell/row mode"),
166            Line::from("  s        - Sort by column"),
167            Line::from("  S        - Column statistics"),
168            Line::from("  y        - Yank (cell mode: yank cell)"),
169            Line::from("    yy     - Yank current row (row mode)"),
170            Line::from("    yc     - Yank current column"),
171            Line::from("    yv     - Yank current cell (any mode)"),
172            Line::from("    ya     - Yank all data"),
173            Line::from("    yq     - Yank current query"),
174            Line::from("  c        - SQL clause navigation:"),
175            Line::from("    cw     - Jump to WHERE clause"),
176            Line::from("    cs     - Jump to SELECT clause"),
177            Line::from("    cf     - Jump to FROM clause"),
178            Line::from("    co     - Jump to ORDER BY"),
179            Line::from("    cg     - Jump to GROUP BY"),
180            Line::from("    ch     - Jump to HAVING clause"),
181            Line::from("    cl     - Jump to LIMIT clause"),
182            Line::from("  i/F2/Esc - Back to command (i=vim insert)"),
183            Line::from("  q        - Quit"),
184            Line::from(""),
185            Line::from("EXPORT DATA").style(
186                Style::default()
187                    .fg(Color::Green)
188                    .add_modifier(Modifier::BOLD),
189            ),
190            Line::from("  Ctrl+E   - Export to CSV file"),
191            Line::from("  Ctrl+J   - Export to JSON file"),
192            Line::from("           (files saved with timestamp)"),
193            Line::from(""),
194            Line::from("SEARCH/FILTER").style(
195                Style::default()
196                    .fg(Color::Yellow)
197                    .add_modifier(Modifier::BOLD),
198            ),
199            Line::from("  Enter    - Apply"),
200            Line::from("  Esc      - Cancel"),
201            Line::from(""),
202            Line::from("DEBUG MODE (F5)")
203                .style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)),
204            Line::from("  g/G      - Go to top/bottom"),
205            Line::from("  j/k      - Scroll up/down"),
206            Line::from("  PgUp/Dn  - Page up/down"),
207            Line::from("  Ctrl+T   - Yank as test case"),
208            Line::from("  Shift+Y  - Yank debug context"),
209            Line::from("  Esc/q    - Exit debug mode"),
210            Line::from(""),
211            Line::from("TIPS").style(
212                Style::default()
213                    .fg(Color::Green)
214                    .add_modifier(Modifier::BOLD),
215            ),
216            Line::from("  • Load CSV: sql-cli data.csv"),
217            Line::from("  • Press C for compact view"),
218            Line::from("  • Press N for row numbers"),
219            Line::from("  • Press : then 200 → row 200"),
220            Line::from("  • Vim counts: 5j, 10k, 3h, 7l"),
221            Line::from("  • Press 'i' for vim-style insert"),
222            Line::from("  • cw/cs/cf = jump to SQL clauses"),
223            Line::from("  • Space locks viewport"),
224            Line::from("  • Columns auto-adjust width"),
225            Line::from("  • f + 'ubs = exact 'ubs' match"),
226            Line::from("  • \\ + name = find column by name"),
227            Line::from("  • F5 + Ctrl+T = Auto-generate tests!"),
228            Line::from(""),
229            Line::from(""),
230        ]
231    }
232}