diff: Simplify info box
161db5b643c6b2f0d2e185b655cd8157cd9f10db
1 parent
34d021d8
crates/diff/src/viewer.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
src/a.rs
+0 -0
src/b.rs
+0 -0
README.md
+0 -0
src/app/a.rs
+0 -0
src/lib/b.rs
+0 -0
README.md
+0 -0
assets/css/style.css
+0 -0
assets/css/style.css
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
crates/diff/src/viewer/tree.rs
+10 -11
| 3 | 3 | use std::collections::BTreeSet; |
|
| 4 | 4 | use std::path::PathBuf; |
|
| 5 | 5 | ||
| 6 | 6 | use rustik_tui as tui; |
|
| 7 | 7 | use tui::{ |
|
| 8 | - | Buffer, Color, Label, Placement, Point, Rect, Style, Table, TableOptions, Tree, TreeModel, |
|
| 9 | - | TreeNodeKind, TreeRow, TreeState, TreeStyle, View, Widget, colors, |
|
| 8 | + | Buffer, Color, Label, Line, Placement, Point, Rect, Style, Table, TableOptions, Tree, |
|
| 9 | + | TreeModel, TreeNodeKind, TreeRow, TreeState, TreeStyle, View, Widget, colors, |
|
| 10 | 10 | }; |
|
| 11 | 11 | ||
| 12 | 12 | use super::{DiffPalette, FILE_KIND_BADGE_FG, MIN_RENDER_COLS}; |
|
| 13 | 13 | use crate::{DiffDocument, FileId, FileKind, Stats}; |
|
| 14 | 14 | ||
| 15 | 15 | /// Minimum columns reserved for the file tree when it is visible. |
|
| 16 | 16 | const DEFAULT_COLS: usize = 28; |
|
| 17 | 17 | /// Blank rows above the file tree list. |
|
| 18 | 18 | const TOP_PADDING_ROWS: usize = 1; |
|
| 19 | 19 | /// Rows reserved for the summary box below the file tree. |
|
| 20 | - | const INFO_BOX_ROWS: usize = 5; |
|
| 20 | + | const INFO_BOX_ROWS: usize = 4; |
|
| 21 | 21 | /// Blank rows between the file tree and the summary box. |
|
| 22 | 22 | const INFO_BOX_GAP_ROWS: usize = 1; |
|
| 23 | 23 | /// Minimum tree rows kept visible when the summary box is shown. |
|
| 24 | 24 | const MIN_TREE_ROWS_WITH_INFO: usize = 3; |
|
| 25 | 25 | /// Columns added by the tree widget for each nesting level. |
| 179 | 179 | ..TableOptions::default() |
|
| 180 | 180 | }); |
|
| 181 | 181 | let stats = self.model.stats; |
|
| 182 | 182 | ||
| 183 | 183 | table.push([ |
|
| 184 | - | Label::new("lines added").fg(FOLDER_FG), |
|
| 185 | - | Label::from(format!("+{}", stats.insertions)).fg(palette.positive_fg), |
|
| 184 | + | Line::new(Label::new("lines changed").fg(FOLDER_FG)), |
|
| 185 | + | Line::spaced([ |
|
| 186 | + | Label::from(format!("+{}", stats.insertions)).fg(palette.positive_fg), |
|
| 187 | + | Label::from(format!("-{}", stats.deletions)).fg(palette.negative_fg), |
|
| 188 | + | ]), |
|
| 186 | 189 | ]); |
|
| 187 | 190 | table.push([ |
|
| 188 | - | Label::new("lines removed").fg(FOLDER_FG), |
|
| 189 | - | Label::from(format!("-{}", stats.deletions)).fg(palette.negative_fg), |
|
| 190 | - | ]); |
|
| 191 | - | table.push([ |
|
| 192 | - | Label::new("files changed").fg(FOLDER_FG), |
|
| 193 | - | Label::from(format!(" {}", stats.files_changed)).fg(Color::White), |
|
| 191 | + | Line::new(Label::new("files changed").fg(FOLDER_FG)), |
|
| 192 | + | Line::new(Label::from(format!(" {}", stats.files_changed)).fg(Color::White)), |
|
| 194 | 193 | ]); |
|
| 195 | 194 | table.render(area, buf); |
|
| 196 | 195 | } |
|
| 197 | 196 | } |
|
| 198 | 197 |
a.rs
+0 -0
b.rs
+0 -0
crates/diff/tests/golden/wide_file_tree_100x12.txt
+3 -3
| 3 | 3 | ⊙ a.rs ├────────────────────────────────────────────────────────────────────┤▐ |
|
| 4 | 4 | ⊙ b.rs │ 1 1 context │▐ |
|
| 5 | 5 | │ 2 - old │▐ |
|
| 6 | 6 | │ 2 + new │▐ |
|
| 7 | 7 | │ 3 + extra │▐ |
|
| 8 | - | ╭──────────────────────────╮ │ 3 4 tail │▐ |
|
| 9 | - | │ lines added +3 │ ╰────────────────────────────────────────────────────────────────────╯▐ |
|
| 10 | - | │ lines removed -2 │ ╭────────────────────────────────────────────────────────────────────╮🮘 |
|
| 8 | + | │ 3 4 tail │▐ |
|
| 9 | + | ╭──────────────────────────╮ ╰────────────────────────────────────────────────────────────────────╯▐ |
|
| 10 | + | │ lines changed +3 -2 │ ╭────────────────────────────────────────────────────────────────────╮🮘 |
|
| 11 | 11 | │ files changed 2 │ │ ⊙ b.rs +1 -1 │🮘 |
|
| 12 | 12 | ╰──────────────────────────╯ ├────────────────────────────────────────────────────────────────────┤🮘 |