Expand description
Code diffing widget
This module provides the DiffWidget for displaying and managing code changes.
It supports multiple diff formats (unified and side-by-side), syntax highlighting,
and hunk-level approval/rejection.
§Features
- Multiple view formats: Unified and side-by-side diff views
- Syntax highlighting: Language-aware code highlighting
- Hunk navigation: Jump between hunks with keyboard shortcuts
- Approval workflow: Accept or reject individual hunks
- Line numbers: Display original and new line numbers
§Examples
Creating a diff widget:
ⓘ
use ricecoder_tui::{DiffWidget, DiffHunk, DiffLine, DiffLineType};
let mut diff = DiffWidget::new();
let line = DiffLine {
line_type: DiffLineType::Added,
old_line_num: None,
new_line_num: Some(1),
content: "fn hello() {}".to_string(),
};Navigating hunks:
ⓘ
diff.next_hunk(); // Move to next hunk
diff.prev_hunk(); // Move to previous hunkApproving changes:
ⓘ
diff.approve_hunk(0); // Approve first hunk
diff.reject_hunk(1); // Reject second hunkStructs§
- Diff
Hunk - Diff hunk
- Diff
Line - Diff line
- Diff
Widget - Diff widget
Enums§
- Diff
Line Type - Diff line type
- Diff
View Type - Diff view type