ricecoder-tui 0.1.71

Terminal User Interface for RiceCoder
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# RiceCoder TUI Usage Guide


This guide provides comprehensive examples and usage patterns for the RiceCoder Terminal User Interface.

## Table of Contents


1. [Getting Started]#getting-started
2. [Chat Widget]#chat-widget
3. [Diff Widget]#diff-widget
4. [Prompt Widget]#prompt-widget
5. [Configuration]#configuration
6. [Keyboard Shortcuts]#keyboard-shortcuts
7. [Advanced Usage]#advanced-usage

## Getting Started


### Starting the TUI


```bash
# Start with default configuration

ricecoder-tui

# Start with specific theme

ricecoder-tui --theme dracula

# Start with debug logging

ricecoder-tui --debug

# Start with high contrast mode

ricecoder-tui --high-contrast
```

### Basic Navigation


- **Tab**: Move focus between widgets
- **Shift+Tab**: Move focus backward
- **Ctrl+C**: Exit application
- **Ctrl+1**: Switch to Chat mode
- **Ctrl+2**: Switch to Command mode
- **Ctrl+3**: Switch to Diff mode
- **Ctrl+4**: Show Help

## Chat Widget


The Chat Widget provides a conversational interface for interacting with AI assistants.

### Features


- Real-time message streaming
- Markdown rendering with syntax highlighting
- Message history with scrolling
- Copy/paste operations
- Multi-line input

### Usage Examples


#### Sending a Message


```
1. Type your message in the input area
2. Press Enter to send
3. Watch the response stream in real-time
```

#### Navigating Chat History

```
- Up Arrow: Scroll up in message history
- Down Arrow: Scroll down in message history
- Page Up: Jump up one screen
- Page Down: Jump down one screen
- Home: Jump to oldest message
- End: Jump to newest message
```

#### Copying Messages

```
1. Navigate to the message you want to copy
2. Press 'c' to copy the entire message
3. Press 'Ctrl+Shift+C' to copy code blocks only
4. Paste with Ctrl+V in your editor
```

#### Editing Messages

```
1. Navigate to your message
2. Press 'e' to edit
3. Modify the message
4. Press Enter to resubmit
5. Press Escape to cancel
```

### Markdown Support

The Chat Widget supports the following markdown features:

```markdown
# Heading 1
## Heading 2
### Heading 3

**Bold text**
*Italic text*
***Bold italic***

- Bullet point
- Another point
  - Nested point

1. Numbered list
2. Second item

`inline code`

\`\`\`python
# Code block with syntax highlighting
def hello():
    print("Hello, world!")
\`\`\`

[Link text](https://example.com)

> Blockquote
> Multiple lines
```

## Diff Widget


The Diff Widget displays code changes with syntax highlighting and approval workflow.

### Features


- Unified and side-by-side views
- Syntax highlighting for 500+ languages
- Hunk-level navigation and approval
- Line number display
- Collapsible hunks

### Usage Examples


#### Viewing Diffs


```
1. Navigate to Diff mode (Ctrl+3)
2. View the diff in unified format
3. Use arrow keys to navigate
```

#### Switching View Formats

```
- 'u': Switch to unified view
- 's': Switch to side-by-side view
- 'v': Toggle view format
```

#### Navigating Hunks

```
- 'n': Jump to next hunk
- 'p': Jump to previous hunk
- 'j': Jump to specific hunk (enter hunk number)
- 'Home': Jump to first hunk
- 'End': Jump to last hunk
```

#### Approving Changes

```
- 'a': Approve current hunk
- 'r': Reject current hunk
- 'A': Approve all hunks
- 'R': Reject all hunks
- 'Space': Toggle hunk approval
```

#### Collapsing Hunks

```
- 'c': Collapse/expand current hunk
- 'C': Collapse all hunks
- 'E': Expand all hunks
```

### Diff Statistics

The diff header shows:
- Total number of lines
- Number of added lines (+)
- Number of removed lines (-)
- Number of approved hunks

Example:
```
Unified Diff View | 150 lines | +45 -30 | Approved: 2/5
```

## Prompt Widget

The Prompt Widget displays the command prompt with context information.

### Context Information

The prompt displays:
- **Git Branch**: Current git branch (if in a git repository)
- **Project Name**: Name of the current project
- **Mode**: Current application mode (Chat, Command, Diff, Help)
- **Provider**: Active AI provider (e.g., OpenAI, Anthropic)
- **Model**: Active AI model (e.g., gpt-4, claude-3)

### Example Prompt

```
[main] ricecoder (Chat) [OpenAI/gpt-4] ❯ 
```

### Multi-line Input

```
1. Type your command
2. Press Shift+Enter for a new line
3. Press Enter to submit
4. Use Up/Down arrows to navigate input history
```

## Configuration

### Configuration File Location

- **Linux/macOS**: `~/.ricecoder/config.yaml`
- **Windows**: `%APPDATA%\ricecoder\config.yaml`

### Configuration Options

```yaml
# Theme selection
theme: dracula

# Enable/disable animations
animations: true

# Enable/disable mouse support
mouse: true

# Terminal dimensions (auto-detect if not specified)
width: 120
height: 40

# Accessibility options
accessibility:
  screen_reader_enabled: false
  high_contrast_mode: false
  disable_animations: false
  focus_indicator_style: "box"

# Performance options
performance:
  lazy_load_enabled: true
  chunk_size: 50
  max_chunks: 10
  diff_max_lines: 1000
  disable_syntax_highlight_above: 5000

# Keybindings
keybindings:
  vim_mode: false
  custom_bindings: {}
```

### Available Themes


Built-in themes:
- `dark` (default)
- `light`
- `monokai`
- `dracula`
- `nord`
- `high-contrast`

### Custom Themes


Create a custom theme in `~/.ricecoder/themes/my-theme.yaml`:

```yaml
name: my-theme
colors:
  primary: "#007AFF"
  secondary: "#5AC8FA"
  background: "#FFFFFF"
  text: "#000000"
  success: "#34C759"
  error: "#FF3B30"
  warning: "#FF9500"
  info: "#00C7FF"
```

## Keyboard Shortcuts


### Global Shortcuts


| Key | Action |
|-----|--------|
| Ctrl+C | Exit application |
| Ctrl+1 | Switch to Chat mode |
| Ctrl+2 | Switch to Command mode |
| Ctrl+3 | Switch to Diff mode |
| Ctrl+4 | Show Help |
| Ctrl+T | Toggle theme |
| Ctrl+L | Clear screen |
| Ctrl+H | Show keybindings help |

### Chat Mode


| Key | Action |
|-----|--------|
| Enter | Send message |
| Shift+Enter | New line in input |
| Up/Down | Navigate history |
| Page Up/Down | Scroll messages |
| c | Copy message |
| e | Edit message |
| r | Regenerate response |
| Ctrl+A | Select all |
| Ctrl+X | Cut |
| Ctrl+C | Copy |
| Ctrl+V | Paste |

### Diff Mode


| Key | Action |
|-----|--------|
| n | Next hunk |
| p | Previous hunk |
| a | Approve hunk |
| r | Reject hunk |
| A | Approve all |
| R | Reject all |
| u | Unified view |
| s | Side-by-side view |
| c | Collapse hunk |
| C | Collapse all |
| E | Expand all |

### Navigation


| Key | Action |
|-----|--------|
| Tab | Next widget |
| Shift+Tab | Previous widget |
| Arrow Keys | Navigate within widget |
| Home | Jump to start |
| End | Jump to end |
| Page Up | Scroll up |
| Page Down | Scroll down |

## Advanced Usage


### Vim Mode


Enable vim-style keybindings in config:

```yaml
keybindings:
  vim_mode: true
```

Vim keybindings:
- `h/j/k/l`: Navigate (left/down/up/right)
- `w/b`: Jump word forward/backward
- `gg`: Jump to start
- `G`: Jump to end
- `d`: Delete
- `y`: Yank (copy)
- `p`: Paste
- `:q`: Quit
- `:w`: Save

### Screen Reader Support


Enable screen reader support for accessibility:

```bash
ricecoder-tui --screen-reader
```

Or in config:

```yaml
accessibility:
  screen_reader_enabled: true
```

### High Contrast Mode


Enable high contrast mode for better visibility:

```bash
ricecoder-tui --high-contrast
```

Or in config:

```yaml
accessibility:
  high_contrast_mode: true
```

### Performance Optimization


For large chat histories:

```yaml
performance:
  lazy_load_enabled: true
  chunk_size: 100
  max_chunks: 5
```

For large diffs:

```yaml
performance:
  diff_max_lines: 500
  disable_syntax_highlight_above: 2000
```

### Custom Keybindings


Define custom keybindings in config:

```yaml
keybindings:
  custom_bindings:
    "Ctrl+Shift+S": "save"
    "Ctrl+Shift+L": "load"
    "Alt+1": "chat_mode"
    "Alt+2": "command_mode"
```

## Tips and Tricks


### Efficient Navigation


1. Use Tab to move between widgets instead of mouse
2. Use keyboard shortcuts for common operations
3. Enable vim mode if you're familiar with vim
4. Use Page Up/Down for faster scrolling

### Performance


1. Disable animations for slower terminals
2. Use built-in themes instead of custom themes
3. Enable lazy loading for large chat histories
4. Disable syntax highlighting for very large diffs

### Accessibility


1. Enable screen reader support for better accessibility
2. Use high contrast mode for better visibility
3. Disable animations if they cause issues
4. Use keyboard navigation exclusively

### Customization


1. Create custom themes for your preferred colors
2. Define custom keybindings for your workflow
3. Configure performance settings for your system
4. Enable/disable features based on your needs

## Troubleshooting


For common issues and solutions, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md).

## Additional Resources


- [RiceCoder Documentation]https://github.com/ricecoder/ricecoder
- [Ratatui Documentation]https://docs.rs/ratatui/
- [Crossterm Documentation]https://docs.rs/crossterm/