Expand description
Colored diff rendering widget.
Provides a Diff widget that computes and renders line-level diffs
between two texts, supporting both unified and side-by-side display styles.
The diff algorithm uses a simple LCS (Longest Common Subsequence) approach with O(n*m) complexity, suitable for typical text sizes.
§Example
use gilt::diff::{Diff, DiffStyle};
use gilt::console::Console;
let old = "fn main() {\n println!(\"hello\");\n}\n";
let new = "fn main() {\n println!(\"world\");\n return;\n}\n";
// Unified diff
let diff = Diff::new(old, new)
.with_labels("a/main.rs", "b/main.rs");
// Side-by-side diff
let diff = Diff::side_by_side(old, new);Structs§
- Diff
- A widget that computes and renders a colored diff between two texts.
Enums§
Functions§
- compute_
diff - Compute a line-level diff between two texts using LCS backtracking.