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