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       - (Multi-line mode removed)"),
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"),
63            Line::from("  Alt+]    - Jump to next SQL token"),
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/Ctrl+PgUp - Previous buffer"),
71            Line::from("  F12/Ctrl+PgDn - Next buffer"),
72            Line::from("  Ctrl+6        - Quick switch (toggle last two)"),
73            Line::from("  Alt+N         - New buffer"),
74            Line::from("  Alt+W         - Close buffer"),
75            Line::from("  Alt+B         - List buffers"),
76            Line::from("  Alt+1-9       - Switch to buffer N"),
77            Line::from(""),
78            Line::from("VIEW MODES").style(
79                Style::default()
80                    .fg(Color::Yellow)
81                    .add_modifier(Modifier::BOLD),
82            ),
83            Line::from("  F1/?     - Toggle this help"),
84            Line::from("  F5       - Debug info"),
85            Line::from("  F6       - Pretty query view"),
86            Line::from("  F7       - Cache management"),
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("CACHE COMMANDS").style(
92                Style::default()
93                    .fg(Color::Yellow)
94                    .add_modifier(Modifier::BOLD),
95            ),
96            Line::from("  :cache save [id] - Save with ID"),
97            Line::from("  :cache load ID   - Load by ID"),
98            Line::from("  :cache list      - Show cached"),
99            Line::from("  :cache clear     - Disable cache"),
100            Line::from(""),
101            Line::from("๐ŸŒŸ FEATURES").style(
102                Style::default()
103                    .fg(Color::Magenta)
104                    .add_modifier(Modifier::BOLD),
105            ),
106            Line::from("  โ€ข Column statistics (S key)"),
107            Line::from("  โ€ข Column pinning (p/P keys)"),
108            Line::from("  โ€ข Dynamic column sizing"),
109            Line::from("  โ€ข Compact mode (C key)"),
110            Line::from("  โ€ข Rainbow parentheses"),
111            Line::from("  โ€ข Auto-execute CSV/JSON"),
112            Line::from("  โ€ข Multi-source indicators"),
113            Line::from("  โ€ข LINQ-style null checking"),
114            Line::from("  โ€ข Named cache IDs"),
115            Line::from("  โ€ข Row numbers (N key)"),
116            Line::from("  โ€ข Jump to row (: key)"),
117        ]
118    }
119
120    /// Get the right column content for help display
121    #[must_use]
122    pub fn right_column() -> Vec<Line<'static>> {
123        vec![
124            Line::from("Use โ†“/โ†‘ or j/k to scroll help").style(Style::default().fg(Color::DarkGray)),
125            Line::from(""),
126            Line::from("RESULTS NAVIGATION").style(
127                Style::default()
128                    .fg(Color::Yellow)
129                    .add_modifier(Modifier::BOLD),
130            ),
131            Line::from("  j/โ†“      - Next row"),
132            Line::from("  k/โ†‘      - Previous row"),
133            Line::from("  h/โ†      - Previous column"),
134            Line::from("  l/โ†’      - Next column"),
135            Line::from("  5j       - โšก Move down 5 rows (vim counts)"),
136            Line::from("  3k       - โšก Move up 3 rows (vim counts)"),
137            Line::from("  10l      - โšก Move right 10 columns"),
138            Line::from("  g        - First row"),
139            Line::from("  G        - Last row"),
140            Line::from("  H        - Top of viewport"),
141            Line::from("  M        - Middle of viewport"),
142            Line::from("  L        - Bottom of viewport"),
143            Line::from("  0/^      - First column"),
144            Line::from("  $        - Last column"),
145            Line::from("  PgDn     - Page down"),
146            Line::from("  PgUp     - Page up"),
147            Line::from(""),
148            Line::from("RESULTS FEATURES").style(
149                Style::default()
150                    .fg(Color::Yellow)
151                    .add_modifier(Modifier::BOLD),
152            ),
153            Line::from("  C        - ๐ŸŽฏ Toggle compact"),
154            Line::from("  N        - ๐Ÿ”ข Toggle row nums"),
155            Line::from("  :        - ๐Ÿ“ Jump to row"),
156            Line::from("  Space    - ๐Ÿ”’ Toggle viewport lock"),
157            Line::from("  x/X      - ๐Ÿ”’ Toggle cursor lock (alternative)"),
158            Line::from("  Ctrl+Space - ๐Ÿ”’ Toggle cursor lock"),
159            Line::from("  p        - ๐Ÿ“Œ Pin/unpin column"),
160            Line::from("  P        - Clear all pins"),
161            Line::from("  -        - ๐Ÿ‘๏ธ Hide current column"),
162            Line::from("  +/=      - ๐Ÿ‘๏ธ Unhide all columns"),
163            Line::from("  <        - โ†”๏ธ Move column left"),
164            Line::from("  >        - โ†”๏ธ Move column right"),
165            Line::from("  /        - ๐Ÿ” Vim search (type, Enter to confirm)"),
166            Line::from("  n        - Next search match"),
167            Line::from("  N        - Previous search match"),
168            Line::from("  \\        - Search column names"),
169            Line::from("  Shift+F  - Filter rows (regex)"),
170            Line::from("  f        - Fuzzy filter rows"),
171            Line::from("  'text    - Exact match filter"),
172            Line::from("             (matches highlighted)"),
173            Line::from("  v        - Toggle cell/row mode"),
174            Line::from("  s        - Sort by column"),
175            Line::from("  S        - ๐Ÿ“Š Column statistics"),
176            Line::from("  y        - Yank (cell mode: yank cell)"),
177            Line::from("    yy     - Yank current row (row mode)"),
178            Line::from("    yc     - Yank current column"),
179            Line::from("    ya     - Yank all data"),
180            Line::from("    yq     - Yank current query"),
181            Line::from("  c        - SQL clause navigation:"),
182            Line::from("    cw     - Jump to WHERE clause"),
183            Line::from("    cs     - Jump to SELECT clause"),
184            Line::from("    cf     - Jump to FROM clause"),
185            Line::from("    co     - Jump to ORDER BY"),
186            Line::from("    cg     - Jump to GROUP BY"),
187            Line::from("  i/F2/Esc - Back to command (i=vim insert)"),
188            Line::from("  q        - Quit"),
189            Line::from(""),
190            Line::from("EXPORT DATA ๐Ÿ“ค").style(
191                Style::default()
192                    .fg(Color::Green)
193                    .add_modifier(Modifier::BOLD),
194            ),
195            Line::from("  Ctrl+E   - Export to CSV file"),
196            Line::from("  Ctrl+J   - Export to JSON file"),
197            Line::from("           (files saved with timestamp)"),
198            Line::from(""),
199            Line::from("SEARCH/FILTER").style(
200                Style::default()
201                    .fg(Color::Yellow)
202                    .add_modifier(Modifier::BOLD),
203            ),
204            Line::from("  Enter    - Apply"),
205            Line::from("  Esc      - Cancel"),
206            Line::from(""),
207            Line::from("DEBUG MODE (F5)")
208                .style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)),
209            Line::from("  g/G      - Go to top/bottom"),
210            Line::from("  j/k      - Scroll up/down"),
211            Line::from("  PgUp/Dn  - Page up/down"),
212            Line::from("  Ctrl+T   - Yank as test case โœจ"),
213            Line::from("  Shift+Y  - Yank debug context โœจ"),
214            Line::from("  Esc/q    - Exit debug mode"),
215            Line::from(""),
216            Line::from("๐Ÿ’ก TIPS").style(
217                Style::default()
218                    .fg(Color::Green)
219                    .add_modifier(Modifier::BOLD),
220            ),
221            Line::from("  โ€ข Load CSV: sql-cli data.csv"),
222            Line::from("  โ€ข Press C for compact view"),
223            Line::from("  โ€ข Press N for row numbers"),
224            Line::from("  โ€ข Press : then 200 โ†’ row 200"),
225            Line::from("  โ€ข Vim counts: 5j, 10k, 3h, 7l"),
226            Line::from("  โ€ข Press 'i' for vim-style insert"),
227            Line::from("  โ€ข cw/cs/cf = jump to SQL clauses"),
228            Line::from("  โ€ข Space locks viewport"),
229            Line::from("  โ€ข Columns auto-adjust width"),
230            Line::from("  โ€ข Named: :cache save q1"),
231            Line::from("  โ€ข f + 'ubs = exact 'ubs' match"),
232            Line::from("  โ€ข \\ + name = find column by name"),
233            Line::from("  โ€ข F5 + Ctrl+T = Auto-generate tests!"),
234            Line::from(""),
235            Line::from("๐Ÿ“ฆ Cache ๐Ÿ“ File ๐ŸŒ API ๐Ÿ—„๏ธ SQL ๐Ÿงช Test"),
236        ]
237    }
238}