diff: Add review progress to file chrome
913b7a5243da281d017c348032936dbed917ea6b
Show per-file review progress, LOC metadata, and footer diff stats in the diff and brain interfaces. This keeps the visual expectations in the existing golden fixtures while removing the file-tree summary box. Assisted-by: Codex:gpt-5.5
1 parent
37523832
crates/brain/src/decorate.rs
+26 -25
| 7 | 7 | //! it. Accepted hunks are dimmed and marked with a check mark; commented |
|
| 8 | 8 | //! hunks show a comment marker and count. |
|
| 9 | 9 | ||
| 10 | 10 | use std::collections::{BTreeMap, BTreeSet}; |
|
| 11 | 11 | ||
| 12 | - | use rustik_diff::{DiffDecorator, DiffPalette, FileDecoration, FileId, HunkDecoration, HunkId}; |
|
| 12 | + | use rustik_diff::{ |
|
| 13 | + | DiffDecorator, DiffPalette, FileDecoration, FileId, FileProgress, HunkDecoration, HunkId, |
|
| 14 | + | }; |
|
| 13 | 15 | use rustik_tui as tui; |
|
| 14 | 16 | use tui::{Label, Line, Paint, Style, colors}; |
|
| 15 | 17 | ||
| 16 | 18 | use crate::comments::Comments; |
|
| 17 | 19 | use crate::review::Review; |
|
| 18 | 20 | ||
| 19 | - | /// Check mark drawn beside accepted hunks and fully accepted files. |
|
| 20 | - | const ACCEPTED_MARK: char = '\u{2714}'; |
|
| 21 | - | /// Marker drawn in the corner of a hunk that has comments. |
|
| 22 | - | const COMMENT_MARK: char = '\u{1F5E9}'; |
|
| 21 | + | /// Check mark drawn beside accepted hunks and fully accepted files: โ. |
|
| 22 | + | const ACCEPTED_MARK: char = 'โ'; |
|
| 23 | + | /// Marker drawn in the corner of a hunk that has comments: ๐ฉ. |
|
| 24 | + | const COMMENT_MARK: char = '๐ฉ'; |
|
| 23 | 25 | ||
| 24 | 26 | /// Immutable decoration snapshot of one commit's review state. |
|
| 25 | 27 | #[derive(Clone, Debug)] |
|
| 26 | 28 | pub struct Decorations { |
|
| 27 | 29 | /// Hunks accepted at snapshot time. |
| 51 | 53 | } |
|
| 52 | 54 | } |
|
| 53 | 55 | ||
| 54 | 56 | impl DiffDecorator for Decorations { |
|
| 55 | 57 | fn file(&self, file: FileId) -> FileDecoration { |
|
| 56 | - | let accepted = self.file_hunks.get(&file).is_some_and(|hunks| { |
|
| 57 | - | !hunks.is_empty() && hunks.iter().all(|hunk| self.accepted.contains(hunk)) |
|
| 58 | + | let hunks = self.file_hunks.get(&file).map_or(&[][..], Vec::as_slice); |
|
| 59 | + | let progress = (!hunks.is_empty()).then(|| FileProgress { |
|
| 60 | + | accepted: hunks |
|
| 61 | + | .iter() |
|
| 62 | + | .filter(|hunk| self.accepted.contains(hunk)) |
|
| 63 | + | .count(), |
|
| 64 | + | total: hunks.len(), |
|
| 58 | 65 | }); |
|
| 59 | - | let comment_count = self |
|
| 60 | - | .file_hunks |
|
| 61 | - | .get(&file) |
|
| 62 | - | .into_iter() |
|
| 63 | - | .flatten() |
|
| 66 | + | let comment_count = hunks |
|
| 67 | + | .iter() |
|
| 64 | 68 | .filter_map(|hunk| self.comments.get(hunk)) |
|
| 65 | 69 | .sum::<usize>(); |
|
| 66 | - | if accepted { |
|
| 67 | - | FileDecoration { |
|
| 68 | - | status: Some(Paint::new(ACCEPTED_MARK).fg(self.palette.positive_fg)), |
|
| 69 | - | ..FileDecoration::default() |
|
| 70 | - | } |
|
| 70 | + | let mut decoration = FileDecoration { |
|
| 71 | + | progress, |
|
| 72 | + | ..FileDecoration::default() |
|
| 73 | + | }; |
|
| 74 | + | if progress.is_some_and(FileProgress::is_complete) { |
|
| 75 | + | decoration.status = Some(Paint::new(ACCEPTED_MARK).fg(self.palette.positive_fg)); |
|
| 71 | 76 | } else if comment_count > 0 { |
|
| 72 | - | FileDecoration { |
|
| 73 | - | annotations: vec![Line::new( |
|
| 74 | - | Label::new(&format!("{comment_count} {COMMENT_MARK}")).fg(colors::rgb::DIM), |
|
| 75 | - | )], |
|
| 76 | - | ..FileDecoration::default() |
|
| 77 | - | } |
|
| 78 | - | } else { |
|
| 79 | - | FileDecoration::default() |
|
| 77 | + | decoration.annotations = vec![Line::new( |
|
| 78 | + | Label::new(&format!("{comment_count} {COMMENT_MARK}")).fg(colors::rgb::DIM), |
|
| 79 | + | )]; |
|
| 80 | 80 | } |
|
| 81 | + | decoration |
|
| 81 | 82 | } |
|
| 82 | 83 | ||
| 83 | 84 | fn hunk(&self, _file: FileId, hunk: HunkId) -> HunkDecoration { |
|
| 84 | 85 | let accepted = self.accepted.contains(&hunk); |
|
| 85 | 86 | let comments = self.comments.get(&hunk).copied().unwrap_or_default(); |
crates/brain/src/main.rs
+9 -1
| 155 | 155 | let events = events.unwrap_or_else(session::Events::spawn); |
|
| 156 | 156 | ||
| 157 | 157 | terminal.clear()?; |
|
| 158 | 158 | terminal.set_cursor_visible(false)?; |
|
| 159 | 159 | ||
| 160 | - | let result = session::run(&mut terminal, events, commits, backend, brain, comments, options); |
|
| 160 | + | let result = session::run( |
|
| 161 | + | &mut terminal, |
|
| 162 | + | events, |
|
| 163 | + | commits, |
|
| 164 | + | backend, |
|
| 165 | + | brain, |
|
| 166 | + | comments, |
|
| 167 | + | options, |
|
| 168 | + | ); |
|
| 161 | 169 | let cursor = terminal.set_cursor_visible(true); |
|
| 162 | 170 | ||
| 163 | 171 | result?; |
|
| 164 | 172 | cursor.map_err(Error::Io) |
|
| 165 | 173 | } |
crates/brain/src/review.rs
+0 -5
| 45 | 45 | /// Replaces the accepted hunk set. |
|
| 46 | 46 | pub fn replace(&mut self, accepted: BTreeSet<HunkId>) { |
|
| 47 | 47 | self.accepted = accepted; |
|
| 48 | 48 | } |
|
| 49 | 49 | ||
| 50 | - | /// Returns the number of accepted hunks. |
|
| 51 | - | pub fn count(&self) -> usize { |
|
| 52 | - | self.accepted.len() |
|
| 53 | - | } |
|
| 54 | - | ||
| 55 | 50 | /// Returns whether every hunk in `hunks` has been accepted. |
|
| 56 | 51 | pub fn accepts_all(&self, hunks: impl IntoIterator<Item = HunkId>) -> bool { |
|
| 57 | 52 | let mut hunks = hunks.into_iter().peekable(); |
|
| 58 | 53 | ||
| 59 | 54 | hunks.peek().is_some() && hunks.all(|hunk| self.accepted.contains(&hunk)) |
crates/brain/src/session.rs
+15 -5
| 40 | 40 | /// Boxed because the hunk view owns its own diff viewer, which would |
|
| 41 | 41 | /// otherwise dominate the size of every mode value. |
|
| 42 | 42 | Hunk(Box<HunkView>), |
|
| 43 | 43 | } |
|
| 44 | 44 | ||
| 45 | + | impl Mode { |
|
| 46 | + | /// Returns the footer label for this active view. |
|
| 47 | + | fn label(&self) -> &'static str { |
|
| 48 | + | match self { |
|
| 49 | + | Self::Commits => "history", |
|
| 50 | + | Self::Diff => "commit", |
|
| 51 | + | Self::Hunk(_) => "hunk", |
|
| 52 | + | } |
|
| 53 | + | } |
|
| 54 | + | } |
|
| 55 | + | ||
| 45 | 56 | /// Terminal event channel shared by pre-session prompts and the session loop. |
|
| 46 | 57 | /// |
|
| 47 | 58 | /// Reading terminal input consumes it, so one input worker must feed every |
|
| 48 | 59 | /// consumer; creating a second stream would steal keystrokes from the first. |
|
| 49 | 60 | pub struct Events { |
| 927 | 938 | ||
| 928 | 939 | /// Returns the footer status line for the current commit. |
|
| 929 | 940 | fn footer(&self) -> Status { |
|
| 930 | 941 | let slot = &self.commits[self.current]; |
|
| 931 | 942 | Status { |
|
| 932 | - | position: (self.current + 1, self.commits.len()), |
|
| 943 | + | mode: self.mode.label(), |
|
| 933 | 944 | short: slot.commit.id.short(), |
|
| 934 | 945 | summary: slot.commit.summary.clone(), |
|
| 935 | - | accepted: slot |
|
| 936 | - | .loaded |
|
| 937 | - | .as_ref() |
|
| 938 | - | .map_or(0, |loaded| loaded.review.count()), |
|
| 946 | + | reviewed: slot.reviewed, |
|
| 947 | + | stats: slot.commit.stats, |
|
| 948 | + | palette: self.options.diff_palette, |
|
| 939 | 949 | visibility: self.visibility, |
|
| 940 | 950 | } |
|
| 941 | 951 | } |
|
| 942 | 952 | } |
crates/brain/src/session/hunk.rs
+2 -3
| 16 | 16 | /// Maximum rows the comment input grows to. |
|
| 17 | 17 | const MAX_INPUT_ROWS: usize = 6; |
|
| 18 | 18 | /// Maximum rows used to list a hunk's existing comments. |
|
| 19 | 19 | const MAX_COMMENT_ROWS: usize = 8; |
|
| 20 | 20 | /// Hint shown above the comment input box. |
|
| 21 | - | const BROWSE_HINT: &str = "comments \u{00b7} c new \u{00b7} e edit \u{00b7} d delete \u{00b7} n/p select \u{00b7} Esc back"; |
|
| 21 | + | const BROWSE_HINT: &str = "comments ยท c new ยท e edit ยท d delete ยท n/p select ยท Esc back"; |
|
| 22 | 22 | /// Hint shown above the comment input box. |
|
| 23 | - | const EDIT_HINT: &str = |
|
| 24 | - | "comment \u{00b7} Enter newline \u{00b7} Ctrl-Enter save \u{00b7} Esc cancel"; |
|
| 23 | + | const EDIT_HINT: &str = "comment ยท Enter newline ยท Ctrl-Enter save ยท Esc cancel"; |
|
| 25 | 24 | ||
| 26 | 25 | /// Comment editor target. |
|
| 27 | 26 | #[derive(Clone, Debug, Eq, PartialEq)] |
|
| 28 | 27 | pub(super) enum CommentEdit { |
|
| 29 | 28 | /// Add a new comment. |
a.txt
+0 -0
crates/brain/src/session/status.rs
+102 -41
| 1 | 1 | //! Status and chrome rendering for the review session. |
|
| 2 | 2 | ||
| 3 | 3 | use std::time::{SystemTime, UNIX_EPOCH}; |
|
| 4 | 4 | ||
| 5 | 5 | use rustik_diff::DiffPalette; |
|
| 6 | + | use rustik_repo::DiffStat; |
|
| 6 | 7 | use rustik_tui::{ |
|
| 7 | 8 | Border, Buffer, Color, Constraint, HStack, Label, Line, Rect, Size, Style, Table, TableOptions, |
|
| 8 | 9 | Widget, colors, |
|
| 9 | 10 | }; |
|
| 10 | 11 |
| 15 | 16 | ||
| 16 | 17 | /// Number of rows reserved for the bottom footer when possible. |
|
| 17 | 18 | const FOOTER_ROWS: usize = 1; |
|
| 18 | 19 | /// Foreground color for dim footer text. |
|
| 19 | 20 | const FOOTER_FG: Color = Color::Fixed(240); |
|
| 20 | - | /// Background color for the footer row. |
|
| 21 | - | const FOOTER_BG: Color = Color::Fixed(233); |
|
| 21 | + | /// Background color for the footer row, matching file border chrome. |
|
| 22 | + | const FOOTER_BG: Color = colors::FAINT; |
|
| 23 | + | /// Background color for the application badge. |
|
| 24 | + | const APP_BADGE_BG: Color = Color::RGB(124, 36, 32); |
|
| 25 | + | /// Background color for the active-mode badge. |
|
| 26 | + | const MODE_BADGE_BG: Color = Color::RGB(68, 68, 68); |
|
| 27 | + | /// Foreground color for the current commit hash. |
|
| 28 | + | const FOOTER_HASH_FG: Color = Color::Fixed(250); |
|
| 29 | + | /// Foreground color for neutral footer values. |
|
| 30 | + | const FOOTER_VALUE_FG: Color = FOOTER_HASH_FG; |
|
| 31 | + | /// Foreground color for the current commit summary. |
|
| 32 | + | const FOOTER_SUMMARY_FG: Color = Color::Fixed(153); |
|
| 22 | 33 | /// Border color for the selected comment in the hunk view. |
|
| 23 | 34 | const SELECTED_COMMENT_BORDER: Color = Color::Fixed(239); |
|
| 24 | - | /// Marker shown beside a commit whose hunks have all been accepted. |
|
| 25 | - | const REVIEWED_MARK: char = '\u{2714}'; |
|
| 26 | - | /// Marker shown when accepted hunks are visible in the footer. |
|
| 27 | - | const APPROVED_HUNKS_MODE_ICON: &str = "\u{2714}"; |
|
| 28 | - | /// Marker shown when full-file mode is visible in the footer. |
|
| 29 | - | const FULL_FILE_MODE_ICON: &str = "\u{2195}"; |
|
| 35 | + | /// Marker shown beside a commit whose hunks have all been accepted: โ. |
|
| 36 | + | const REVIEWED_MARK: char = 'โ'; |
|
| 37 | + | /// Marker shown when the active commit is fully reviewed: โ. |
|
| 38 | + | const REVIEWED_STATUS_MARK: &str = "โ"; |
|
| 39 | + | /// Marker shown when the active commit still needs review: ยท. |
|
| 40 | + | const UNREVIEWED_STATUS_MARK: &str = "ยท"; |
|
| 41 | + | /// Marker shown when accepted hunks are visible in the footer: โ. |
|
| 42 | + | const APPROVED_HUNKS_MODE_ICON: &str = "โ"; |
|
| 43 | + | /// Marker shown when full-file mode is visible in the footer: โ. |
|
| 44 | + | const FULL_FILE_MODE_ICON: &str = "โ"; |
|
| 45 | + | /// Separator shown between footer status segments: ยท. |
|
| 46 | + | const FOOTER_SEPARATOR: &str = " ยท "; |
|
| 47 | + | /// Marker used when footer text truncates: โฆ. |
|
| 48 | + | const FOOTER_ELLIPSIS: &str = "โฆ"; |
|
| 49 | + | /// Foreground color for active context-expansion mode. |
|
| 50 | + | const FULL_FILE_MODE_FG: Color = colors::rgb::TEAL; |
|
| 30 | 51 | /// Rendered rows in one stored comment card. |
|
| 31 | 52 | pub(super) const COMMENT_CARD_ROWS: usize = 4; |
|
| 32 | 53 | /// Rows of card chrome around a comment body: the top border, the header row, |
|
| 33 | 54 | /// and the bottom border. |
|
| 34 | 55 | pub(super) const COMMENT_CARD_CHROME_ROWS: usize = 3; |
| 37 | 58 | pub(super) const COMMENT_CARD_CHROME_COLS: usize = 2; |
|
| 38 | 59 | ||
| 39 | 60 | /// Footer status describing the current commit and review progress. |
|
| 40 | 61 | #[derive(Debug)] |
|
| 41 | 62 | pub(super) struct Status { |
|
| 42 | - | /// One-based position and total commit count. |
|
| 43 | - | pub(super) position: (usize, usize), |
|
| 63 | + | /// Active review mode name. |
|
| 64 | + | pub(super) mode: &'static str, |
|
| 44 | 65 | /// Abbreviated current commit hash. |
|
| 45 | 66 | pub(super) short: String, |
|
| 46 | 67 | /// First line of the current commit message. |
|
| 47 | 68 | pub(super) summary: String, |
|
| 48 | - | /// Accepted-hunk count for the current commit. |
|
| 49 | - | pub(super) accepted: usize, |
|
| 69 | + | /// Whether all hunks in the current commit are accepted. |
|
| 70 | + | pub(super) reviewed: bool, |
|
| 71 | + | /// Aggregated diff size for the current commit. |
|
| 72 | + | pub(super) stats: DiffStat, |
|
| 73 | + | /// Diff palette used for stat and review colors. |
|
| 74 | + | pub(super) palette: DiffPalette, |
|
| 50 | 75 | /// Session-wide accepted-hunk visibility. |
|
| 51 | 76 | pub(super) visibility: Visibility, |
|
| 52 | 77 | } |
|
| 53 | 78 | ||
| 54 | 79 | impl Widget for Status { |
| 59 | 84 | fn render(&mut self, area: Rect, buf: &mut Buffer) { |
|
| 60 | 85 | if area.is_empty() { |
|
| 61 | 86 | return; |
|
| 62 | 87 | } |
|
| 63 | 88 | Self::background(area.cols).render(area, buf); |
|
| 64 | - | self.bar().render(area, buf); |
|
| 89 | + | self.bar(area.cols).render(area, buf); |
|
| 65 | 90 | } |
|
| 66 | 91 | } |
|
| 67 | 92 | ||
| 68 | 93 | impl Status { |
|
| 69 | 94 | /// Returns the content and footer areas for a full session frame. |
| 71 | 96 | area.split_bottom(FOOTER_ROWS) |
|
| 72 | 97 | } |
|
| 73 | 98 | ||
| 74 | 99 | /// Returns the full-width status row background. |
|
| 75 | 100 | fn background(cols: usize) -> Line { |
|
| 101 | + | Line::new(Label::space().bg(FOOTER_BG)).padded(cols) |
|
| 102 | + | } |
|
| 103 | + | ||
| 104 | + | /// Returns the bottom status row content. |
|
| 105 | + | fn bar(&self, cols: usize) -> HStack<'_> { |
|
| 106 | + | let right = self.right_status(); |
|
| 107 | + | let left_width = cols.saturating_sub(right.width()).saturating_sub(1); |
|
| 108 | + | ||
| 109 | + | HStack::default() |
|
| 110 | + | .child(self.left_status().truncated(left_width, FOOTER_ELLIPSIS)) |
|
| 111 | + | .spacer() |
|
| 112 | + | .child(right) |
|
| 113 | + | } |
|
| 114 | + | ||
| 115 | + | /// Returns the left status section with application, mode, summary, and hash. |
|
| 116 | + | fn left_status(&self) -> Line { |
|
| 76 | 117 | Line::blank() |
|
| 118 | + | .item( |
|
| 119 | + | Label::new(" brain ") |
|
| 120 | + | .fg(Color::White) |
|
| 121 | + | .bg(APP_BADGE_BG) |
|
| 122 | + | .style(Style::default().bold()), |
|
| 123 | + | ) |
|
| 124 | + | .item( |
|
| 125 | + | Label::new(&format!(" {} ", self.mode)) |
|
| 126 | + | .fg(Color::White) |
|
| 127 | + | .bg(MODE_BADGE_BG) |
|
| 128 | + | .style(Style::default().bold()), |
|
| 129 | + | ) |
|
| 130 | + | .item(Label::space()) |
|
| 131 | + | .item(Label::new(&self.short).fg(FOOTER_HASH_FG)) |
|
| 132 | + | .item(Label::space()) |
|
| 133 | + | .item(Label::new(&self.summary).fg(FOOTER_SUMMARY_FG)) |
|
| 77 | 134 | .style(Style::default().bg(FOOTER_BG)) |
|
| 78 | - | .padded(cols) |
|
| 79 | 135 | } |
|
| 80 | 136 | ||
| 81 | - | /// Returns the bottom status row content. |
|
| 82 | - | fn bar(&self) -> HStack<'_> { |
|
| 83 | - | let action = if self.visibility.show_accepted { |
|
| 84 | - | "hide approved" |
|
| 137 | + | /// Returns the right status section with review state and diff statistics. |
|
| 138 | + | fn right_status(&self) -> Line { |
|
| 139 | + | let review = if self.reviewed { |
|
| 140 | + | REVIEWED_STATUS_MARK |
|
| 85 | 141 | } else { |
|
| 86 | - | "show approved" |
|
| 142 | + | UNREVIEWED_STATUS_MARK |
|
| 87 | 143 | }; |
|
| 88 | - | let (index, total) = self.position; |
|
| 89 | - | let left = format!("brain [{index}/{total}] {} {}", self.short, self.summary); |
|
| 90 | - | let mut right = format!("{} accepted \u{00b7} ", self.accepted); |
|
| 91 | - | if self.visibility.show_accepted { |
|
| 92 | - | right.push_str(APPROVED_HUNKS_MODE_ICON); |
|
| 93 | - | } |
|
| 94 | - | if self.visibility.full_file { |
|
| 95 | - | if self.visibility.show_accepted { |
|
| 96 | - | right.push(' '); |
|
| 97 | - | } |
|
| 98 | - | right.push_str(FULL_FILE_MODE_ICON); |
|
| 99 | - | } |
|
| 100 | - | if self.visibility.show_accepted || self.visibility.full_file { |
|
| 101 | - | right.push_str(" \u{00b7} "); |
|
| 102 | - | } |
|
| 103 | - | right.push_str("v "); |
|
| 104 | - | right.push_str(action); |
|
| 105 | - | HStack::default() |
|
| 106 | - | .child(Line::new(Label::new(&left).fg(FOOTER_FG))) |
|
| 107 | - | .spacer() |
|
| 108 | - | .child(Line::new(Label::new(&right).fg(FOOTER_FG))) |
|
| 144 | + | let accepted_fg = if self.visibility.show_accepted { |
|
| 145 | + | self.palette.positive_fg |
|
| 146 | + | } else { |
|
| 147 | + | FOOTER_FG |
|
| 148 | + | }; |
|
| 149 | + | let full_file_fg = if self.visibility.full_file { |
|
| 150 | + | FULL_FILE_MODE_FG |
|
| 151 | + | } else { |
|
| 152 | + | FOOTER_FG |
|
| 153 | + | }; |
|
| 154 | + | let files = self.stats.files_changed; |
|
| 155 | + | let plural = if files == 1 { "" } else { "s" }; |
|
| 156 | + | ||
| 157 | + | Line::blank() |
|
| 158 | + | .item(Label::new(review).fg(self.palette.positive_fg)) |
|
| 159 | + | .item(Label::space()) |
|
| 160 | + | .item(Label::new(APPROVED_HUNKS_MODE_ICON).fg(accepted_fg)) |
|
| 161 | + | .item(Label::space()) |
|
| 162 | + | .item(Label::new(FULL_FILE_MODE_ICON).fg(full_file_fg)) |
|
| 163 | + | .item(Label::space()) |
|
| 164 | + | .item(Label::new(&format!("+{}", self.stats.insertions)).fg(self.palette.positive_fg)) |
|
| 165 | + | .item(Label::space()) |
|
| 166 | + | .item(Label::new(&format!("-{}", self.stats.deletions)).fg(self.palette.negative_fg)) |
|
| 167 | + | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 168 | + | .item(Label::new(&format!("{files} file{plural}")).fg(FOOTER_VALUE_FG)) |
|
| 169 | + | .style(Style::default().bg(FOOTER_BG)) |
|
| 109 | 170 | } |
|
| 110 | 171 | } |
|
| 111 | 172 | ||
| 112 | 173 | /// Returns the viewer area above the footer chrome. |
|
| 113 | 174 | pub(super) fn viewer_area(area: Rect) -> Rect { |
| 273 | 334 | ||
| 274 | 335 | assert_eq!(lines.len(), COMMENT_CARD_ROWS); |
|
| 275 | 336 | assert!(text.contains("alice"), "text: {text:?}"); |
|
| 276 | 337 | assert!(text.contains("just now"), "text: {text:?}"); |
|
| 277 | 338 | assert!(text.contains("first second"), "text: {text:?}"); |
|
| 278 | - | assert!(!text.contains('\u{1F5E8}'), "text: {text:?}"); |
|
| 339 | + | assert!(!text.contains('๐จ'), "text: {text:?}"); |
|
| 279 | 340 | } |
|
| 280 | 341 | ||
| 281 | 342 | #[test] |
|
| 282 | 343 | fn unselected_comment_cards_render_a_faint_border() { |
|
| 283 | 344 | let comment = Comment { |
crates/diff/src/bin/rustik-diff/session.rs
+55 -20
| 4 | 4 | use std::sync::mpsc; |
|
| 5 | 5 | use std::thread; |
|
| 6 | 6 | use std::time::{Duration, Instant}; |
|
| 7 | 7 | ||
| 8 | 8 | use rustik_diff::{ |
|
| 9 | - | ContextChange, DiffViewer, HighlightOutput, HighlightRequest, Highlighter, spawn_highlighter, |
|
| 9 | + | ContextChange, DiffPalette, DiffViewer, HighlightOutput, HighlightRequest, Highlighter, Stats, |
|
| 10 | + | spawn_highlighter, |
|
| 10 | 11 | }; |
|
| 11 | 12 | use rustik_repo::git; |
|
| 12 | 13 | use rustik_tui as tui; |
|
| 13 | 14 | use rustik_tui::{ |
|
| 14 | - | Color, Control, Event, Key, Label, Line, Mouse, MouseButton, Rect, Style, Terminal, |
|
| 15 | + | Color, Constraint, Control, Event, HStack, Key, Label, Line, Mouse, MouseButton, Rect, Style, |
|
| 16 | + | Terminal, Widget, colors, |
|
| 15 | 17 | }; |
|
| 16 | 18 | use rustik_tui_termion as tui_termion; |
|
| 17 | 19 | use tui::event::Modifiers; |
|
| 18 | 20 | ||
| 19 | 21 | use crate::error::Error; |
|
| 20 | 22 | ||
| 21 | 23 | /// Number of rows reserved for the bottom footer when possible. |
|
| 22 | 24 | const FOOTER_ROWS: usize = 1; |
|
| 23 | 25 | /// Foreground color for dim footer text. |
|
| 24 | 26 | const FOOTER_FG: Color = Color::Fixed(240); |
|
| 25 | - | /// Background color for the footer row. |
|
| 26 | - | const FOOTER_BG: Color = Color::Fixed(233); |
|
| 27 | + | /// Background color for the footer row, matching file border chrome. |
|
| 28 | + | const FOOTER_BG: Color = colors::FAINT; |
|
| 29 | + | /// Foreground color for neutral footer values. |
|
| 30 | + | const FOOTER_VALUE_FG: Color = Color::Fixed(250); |
|
| 31 | + | /// Separator shown between footer status segments: ยท. |
|
| 32 | + | const FOOTER_SEPARATOR: &str = " ยท "; |
|
| 27 | 33 | ||
| 28 | 34 | /// Terminal backend used by the interactive viewer. |
|
| 29 | 35 | type DiffTerminal = Terminal<tui_termion::TermionBackend<tui_termion::term::TerminalScreen>>; |
|
| 30 | 36 | ||
| 31 | 37 | /// Runs the terminal event loop. |
| 188 | 194 | /// Draws one terminal frame without scheduling highlight work. |
|
| 189 | 195 | fn draw_frame(&mut self) -> io::Result<()> { |
|
| 190 | 196 | self.terminal.draw(|frame| { |
|
| 191 | 197 | let body = viewer_area(frame.area); |
|
| 192 | 198 | frame.render_widget(&mut *self.viewer, body); |
|
| 193 | - | draw_status(frame, self.debug_status.as_deref()); |
|
| 199 | + | draw_status( |
|
| 200 | + | frame, |
|
| 201 | + | self.viewer.document().stats(), |
|
| 202 | + | self.viewer.options().diff_palette, |
|
| 203 | + | self.debug_status.as_deref(), |
|
| 204 | + | ); |
|
| 194 | 205 | }) |
|
| 195 | 206 | } |
|
| 196 | 207 | } |
|
| 197 | 208 | ||
| 198 | 209 | /// Event delivered to the terminal loop. |
| 247 | 258 | area.rows.saturating_sub(footer_rows), |
|
| 248 | 259 | ) |
|
| 249 | 260 | } |
|
| 250 | 261 | ||
| 251 | 262 | /// Draws the bottom status row. |
|
| 252 | - | fn draw_status(frame: &mut tui::Frame<'_>, debug: Option<&str>) { |
|
| 263 | + | fn draw_status( |
|
| 264 | + | frame: &mut tui::Frame<'_>, |
|
| 265 | + | stats: Stats, |
|
| 266 | + | palette: DiffPalette, |
|
| 267 | + | debug: Option<&str>, |
|
| 268 | + | ) { |
|
| 253 | 269 | let area = frame.area; |
|
| 254 | 270 | if area.rows == 0 { |
|
| 255 | 271 | return; |
|
| 256 | 272 | } |
|
| 257 | 273 | let row = Rect::new(area.x, area.bottom().saturating_sub(1), area.cols, 1); |
|
| 258 | 274 | ||
| 259 | - | frame.render_widget(status_line(area.cols, debug), row); |
|
| 275 | + | frame.render_widget(status_line(area.cols, stats, palette, debug), row); |
|
| 260 | 276 | } |
|
| 261 | 277 | ||
| 262 | 278 | /// Returns the padded bottom status line. |
|
| 263 | - | fn status_line(cols: usize, debug: Option<&str>) -> Line { |
|
| 264 | - | let text = match debug { |
|
| 265 | - | Some(debug) if debug.len() < cols => { |
|
| 266 | - | format!( |
|
| 267 | - | "{:<width$}{debug}", |
|
| 268 | - | "rustik-diff", |
|
| 269 | - | width = cols - debug.len() |
|
| 270 | - | ) |
|
| 271 | - | } |
|
| 272 | - | _ => "rustik-diff".to_owned(), |
|
| 273 | - | }; |
|
| 274 | - | Line::new(Label::new(&text).fg(FOOTER_FG)) |
|
| 279 | + | fn status_line(cols: usize, stats: Stats, palette: DiffPalette, debug: Option<&str>) -> Line { |
|
| 280 | + | HStack::default() |
|
| 281 | + | .child( |
|
| 282 | + | Line::new(Label::new("diff").fg(FOOTER_FG)) |
|
| 283 | + | .style(Style::default().bg(FOOTER_BG)) |
|
| 284 | + | .padded(4), |
|
| 285 | + | ) |
|
| 286 | + | .spacer() |
|
| 287 | + | .child(status_stats(stats, palette, debug).truncated(cols.saturating_sub(5), "")) |
|
| 288 | + | .to_line(Constraint::tight(cols)) |
|
| 275 | 289 | .style(Style::default().bg(FOOTER_BG)) |
|
| 276 | 290 | .padded(cols) |
|
| 277 | 291 | .truncated(cols, "") |
|
| 278 | 292 | } |
|
| 279 | 293 | ||
| 294 | + | /// Returns the right-aligned status data for the footer. |
|
| 295 | + | fn status_stats(stats: Stats, palette: DiffPalette, debug: Option<&str>) -> Line { |
|
| 296 | + | let files = stats.files_changed; |
|
| 297 | + | let plural = if files == 1 { "" } else { "s" }; |
|
| 298 | + | let mut line = Line::blank() |
|
| 299 | + | .item(Label::new(&format!("+{}", stats.insertions)).fg(palette.positive_fg)) |
|
| 300 | + | .item(Label::space()) |
|
| 301 | + | .item(Label::new(&format!("-{}", stats.deletions)).fg(palette.negative_fg)) |
|
| 302 | + | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 303 | + | .item(Label::new(&format!("{files} file{plural}")).fg(FOOTER_VALUE_FG)); |
|
| 304 | + | if let Some(debug) = debug { |
|
| 305 | + | line = line |
|
| 306 | + | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 307 | + | .item(Label::new(debug).fg(FOOTER_FG)); |
|
| 308 | + | } |
|
| 309 | + | line.style(Style::default().bg(FOOTER_BG)) |
|
| 310 | + | } |
|
| 311 | + | ||
| 280 | 312 | /// Formats debug timing in milliseconds. |
|
| 281 | 313 | fn format_ms(duration: Duration) -> String { |
|
| 282 | 314 | format!("{:.1}ms", duration.as_secs_f64() * 1_000.0) |
|
| 283 | 315 | } |
|
| 284 | 316 |
| 296 | 328 | assert_eq!(viewer_area(Rect::new(0, 0, 80, 1)), Rect::new(0, 0, 80, 0)); |
|
| 297 | 329 | } |
|
| 298 | 330 | ||
| 299 | 331 | #[test] |
|
| 300 | 332 | fn status_line_fills_footer_width() { |
|
| 301 | - | assert_eq!(status_line(24, None).width(), 24); |
|
| 333 | + | assert_eq!( |
|
| 334 | + | status_line(24, Stats::default(), DiffPalette::default(), None).width(), |
|
| 335 | + | 24 |
|
| 336 | + | ); |
|
| 302 | 337 | } |
|
| 303 | 338 | ||
| 304 | 339 | #[test] |
|
| 305 | 340 | fn resize_requests_redraw_even_when_viewer_continues() { |
|
| 306 | 341 | let resized = true; |
crates/diff/src/decorate.rs
+18 -0
| 42 | 42 | pub struct FileDecoration { |
|
| 43 | 43 | /// Status glyph inserted before the path, for example an approval marker. |
|
| 44 | 44 | pub status: Option<Paint<char>>, |
|
| 45 | 45 | /// Right-aligned segments shown before the diffstat, outermost first. |
|
| 46 | 46 | pub annotations: Vec<Line>, |
|
| 47 | + | /// File-level review progress shown in the header. |
|
| 48 | + | pub progress: Option<FileProgress>, |
|
| 47 | 49 | /// Replacement for the computed `+adds -dels` diffstat, when set. |
|
| 48 | 50 | pub stats: Option<Line>, |
|
| 49 | 51 | } |
|
| 50 | 52 | ||
| 53 | + | /// File-level review progress. |
|
| 54 | + | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] |
|
| 55 | + | pub struct FileProgress { |
|
| 56 | + | /// Number of reviewed hunks in the file. |
|
| 57 | + | pub accepted: usize, |
|
| 58 | + | /// Total number of reviewable hunks in the file. |
|
| 59 | + | pub total: usize, |
|
| 60 | + | } |
|
| 61 | + | ||
| 62 | + | impl FileProgress { |
|
| 63 | + | /// Returns whether all reviewable hunks have been accepted. |
|
| 64 | + | pub fn is_complete(self) -> bool { |
|
| 65 | + | self.total > 0 && self.accepted >= self.total |
|
| 66 | + | } |
|
| 67 | + | } |
|
| 68 | + | ||
| 51 | 69 | /// Decoration overlaid on a hunk. |
|
| 52 | 70 | /// |
|
| 53 | 71 | /// Decorations never add rows: the corner is drawn over the hunk's first body |
|
| 54 | 72 | /// row, and the style is composed onto the hunk's existing body rows. |
|
| 55 | 73 | #[derive(Clone, Debug, Default)] |
crates/diff/src/lib.rs
+1 -1
| 31 | 31 | #[cfg(feature = "builtins")] |
|
| 32 | 32 | pub use builtins::Builtins; |
|
| 33 | 33 | pub use commit::{Commit, Header, ParseCommitError}; |
|
| 34 | 34 | pub use context::ContextChange; |
|
| 35 | 35 | pub use decode::Decode; |
|
| 36 | - | pub use decorate::{DiffDecorator, FileDecoration, HunkDecoration}; |
|
| 36 | + | pub use decorate::{DiffDecorator, FileDecoration, FileProgress, HunkDecoration}; |
|
| 37 | 37 | pub use document::{ |
|
| 38 | 38 | DecodeError, DiffDocument, DiffLine, DiffLineKind, FileDiff, FileHeader, FileId, FileKind, |
|
| 39 | 39 | FileMode, FileStats, Hunk, HunkHeader, HunkId, Oid, OidError, RowId, Stats, |
|
| 40 | 40 | }; |
|
| 41 | 41 | pub use encode::Encode; |
crates/diff/src/viewer.rs
+50 -7
| 16 | 16 | MouseButton, Rect, Scroll, ScrollView, ScrollbarStyle, Size, Style, Table, TableOptions, Text, |
|
| 17 | 17 | VStack, View, Viewport, Widget, colors, |
|
| 18 | 18 | }; |
|
| 19 | 19 | ||
| 20 | 20 | use crate::context::{self, ContextChange, ContextState}; |
|
| 21 | - | use crate::decorate::{DiffDecorator, FileDecoration, HunkDecoration}; |
|
| 21 | + | use crate::decorate::{DiffDecorator, FileDecoration, FileProgress, HunkDecoration}; |
|
| 22 | 22 | use crate::highlight::{DiffHighlighter, HighlightKeyInput, HighlightResult}; |
|
| 23 | 23 | use crate::word; |
|
| 24 | 24 | use crate::{ |
|
| 25 | 25 | Commit, Decode, DecodeError, DiffDocument, DiffLine, DiffLineKind, DiffSide, FileDiff, FileId, |
|
| 26 | 26 | FileKind, HighlightKey, HighlightRequest, HighlightSource, Hunk, HunkId, RowId, |
| 71 | 71 | const NO_NEWLINE_MARKER: &str = "\\ No newline at end of file"; |
|
| 72 | 72 | /// Rendered source text replacement for a single source tab. |
|
| 73 | 73 | const SOURCE_TAB_MARKER: &str = "ยท "; |
|
| 74 | 74 | /// Marker cell shown between hunks in the diff marker column. |
|
| 75 | 75 | const HUNK_GAP_MARKER_CELL: &str = " โฎ "; |
|
| 76 | - | /// Separator shown between file header metadata segments. |
|
| 77 | - | const FILE_HEADER_SEGMENT_SEPARATOR: &str = " \u{00b7} "; |
|
| 76 | + | /// Separator shown between file header metadata segments: ยท. |
|
| 77 | + | const FILE_HEADER_SEGMENT_SEPARATOR: &str = " ยท "; |
|
| 78 | + | /// Width of the file review progress bar in file headers. |
|
| 79 | + | const FILE_PROGRESS_BAR_WIDTH: usize = 12; |
|
| 80 | + | /// Glyph text used by file review progress bars: โ. |
|
| 81 | + | const FILE_PROGRESS_BAR_GLYPH: &str = "โ"; |
|
| 78 | 82 | /// Default syntax theme selection stored in highlight keys. |
|
| 79 | 83 | const DEFAULT_THEME: &str = "auto"; |
|
| 80 | 84 | /// Number of rows in a sticky file header. |
|
| 81 | 85 | const STICKY_HEADER_ROWS: usize = 3; |
|
| 82 | 86 | /// Number of body rows moved by keyboard line-scroll inputs. |
| 1976 | 1980 | }; |
|
| 1977 | 1981 | left.push(Label::from_char(self.header.kind.marker()).fg(fg)); |
|
| 1978 | 1982 | } |
|
| 1979 | 1983 | left.push(Label::space()); |
|
| 1980 | 1984 | left = left.extend(self.path_line()); |
|
| 1985 | + | left.push(Label::space()); |
|
| 1986 | + | left.push(Label::new(&format!("{} LOC", self.loc())).fg(colors::rgb::DIM)); |
|
| 1981 | 1987 | ||
| 1982 | 1988 | if let Some(badge) = self.badge(palette) { |
|
| 1983 | 1989 | left.push(Label::space()); |
|
| 1984 | 1990 | left = left.extend(badge.line()); |
|
| 1985 | 1991 | } |
|
| 1986 | 1992 | // Right-aligned segments: host annotations first, then the diffstat (or |
|
| 1987 | 1993 | // its decoration override), joined by a fixed gap. |
|
| 1988 | 1994 | let mut right = decoration.annotations.clone(); |
|
| 1989 | - | let stats = decoration.stats.clone().or_else(|| { |
|
| 1995 | + | if let Some(progress) = decoration.progress { |
|
| 1996 | + | right.push(Self::progress_bar(progress, palette)); |
|
| 1997 | + | } |
|
| 1998 | + | if decoration.progress.is_some_and(FileProgress::is_complete) { |
|
| 1999 | + | right.push(Line::new(Label::new("Approved").fg(palette.positive_fg))); |
|
| 2000 | + | } else if let Some(stats) = decoration.stats.clone().or_else(|| { |
|
| 1990 | 2001 | let stats = self.stats(); |
|
| 1991 | 2002 | Self::diffstat_line(stats.additions, stats.deletions, palette) |
|
| 1992 | - | }); |
|
| 1993 | - | if let Some(side) = stats { |
|
| 1994 | - | right.push(side); |
|
| 2003 | + | }) { |
|
| 2004 | + | right.push(stats); |
|
| 1995 | 2005 | } |
|
| 1996 | 2006 | let mut header = HStack::default().child(left).spacer(); |
|
| 1997 | 2007 | for (index, segment) in right.into_iter().enumerate() { |
|
| 1998 | 2008 | if index > 0 { |
|
| 1999 | 2009 | header = header.child(Line::new( |
| 2033 | 2043 | line.push(Label::new(&format!("-{deletions}")).fg(palette.negative_fg)); |
|
| 2034 | 2044 | } |
|
| 2035 | 2045 | Some(line) |
|
| 2036 | 2046 | } |
|
| 2037 | 2047 | ||
| 2048 | + | /// Returns a compact file review progress bar. |
|
| 2049 | + | fn progress_bar(progress: FileProgress, palette: DiffPalette) -> Line { |
|
| 2050 | + | let filled = progress |
|
| 2051 | + | .accepted |
|
| 2052 | + | .saturating_mul(FILE_PROGRESS_BAR_WIDTH) |
|
| 2053 | + | .checked_div(progress.total) |
|
| 2054 | + | .unwrap_or(0) |
|
| 2055 | + | .min(FILE_PROGRESS_BAR_WIDTH); |
|
| 2056 | + | let empty = FILE_PROGRESS_BAR_WIDTH - filled; |
|
| 2057 | + | ||
| 2058 | + | Line::blank() |
|
| 2059 | + | .item(Label::new(&FILE_PROGRESS_BAR_GLYPH.repeat(filled)).fg(palette.positive_fg)) |
|
| 2060 | + | .item(Label::new(&FILE_PROGRESS_BAR_GLYPH.repeat(empty)).fg(colors::FAINT)) |
|
| 2061 | + | } |
|
| 2062 | + | ||
| 2063 | + | /// Returns the nonblank line count on the displayed side of this file. |
|
| 2064 | + | fn loc(&self) -> usize { |
|
| 2065 | + | let deleted = self.header.kind == FileKind::Deleted; |
|
| 2066 | + | self.hunks |
|
| 2067 | + | .iter() |
|
| 2068 | + | .flat_map(|hunk| hunk.lines.iter()) |
|
| 2069 | + | .filter(|line| { |
|
| 2070 | + | let visible = match line.kind { |
|
| 2071 | + | DiffLineKind::Context => true, |
|
| 2072 | + | DiffLineKind::Addition => !deleted, |
|
| 2073 | + | DiffLineKind::Deletion => deleted, |
|
| 2074 | + | DiffLineKind::NoNewline => false, |
|
| 2075 | + | }; |
|
| 2076 | + | visible && !line.text.trim().is_empty() |
|
| 2077 | + | }) |
|
| 2078 | + | .count() |
|
| 2079 | + | } |
|
| 2080 | + | ||
| 2038 | 2081 | /// Returns a file-kind badge. |
|
| 2039 | 2082 | fn badge(&self, palette: DiffPalette) -> Option<Badge> { |
|
| 2040 | 2083 | match self.header.kind { |
|
| 2041 | 2084 | FileKind::Added => Some(Self::change_badge( |
|
| 2042 | 2085 | "created", |
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
crates/diff/tests/golden/sticky_header_before_next_file_64x5.txt
+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
a.rs
+0 -0
b.rs
+0 -0
assets/css/style.css
+0 -0
assets/css/style.css
+0 -0
first.rs
+0 -0
second.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
crates/diff/src/viewer/tree.rs
+7 -53
| 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, Constraint, Label, Line, Placement, Point, Rect, Size, Style, Table, |
|
| 9 | - | TableOptions, Tree, TreeHitZone, TreeModel, TreeNodeKind, TreeRow, TreeState, TreeStyle, |
|
| 10 | - | Widget, |
|
| 8 | + | Buffer, Color, Constraint, Label, Placement, Point, Rect, Size, Style, Tree, TreeHitZone, |
|
| 9 | + | TreeModel, TreeNodeKind, TreeRow, TreeState, TreeStyle, Widget, |
|
| 11 | 10 | }; |
|
| 12 | 11 | ||
| 13 | 12 | use super::{DiffPalette, FILE_KIND_BADGE_FG, MIN_RENDER_COLS}; |
|
| 14 | - | use crate::{DiffDecorator, DiffDocument, FileId, FileKind, Stats}; |
|
| 13 | + | use crate::{DiffDecorator, DiffDocument, FileId, FileKind}; |
|
| 15 | 14 | ||
| 16 | 15 | /// Blank rows above the file tree list. |
|
| 17 | 16 | const TOP_PADDING_ROWS: usize = 1; |
|
| 18 | - | /// Rows reserved for the summary box below the file tree. |
|
| 19 | - | const INFO_BOX_ROWS: usize = 4; |
|
| 20 | - | /// Minimum columns needed to render the summary box without truncating labels. |
|
| 21 | - | const INFO_BOX_COLS: usize = 28; |
|
| 22 | - | /// Blank rows between the file tree and the summary box. |
|
| 23 | - | const INFO_BOX_GAP_ROWS: usize = 1; |
|
| 24 | - | /// Minimum tree rows kept visible when the summary box is shown. |
|
| 25 | - | const MIN_TREE_ROWS_WITH_INFO: usize = 3; |
|
| 26 | 17 | /// Background color for the selected or active file row. |
|
| 27 | 18 | const SELECTED_FILE_BG: Color = Color::Fixed(235); |
|
| 28 | 19 | /// Background color for the selected or active folder row. |
|
| 29 | 20 | const SELECTED_FOLDER_BG: Color = Color::Fixed(234); |
|
| 30 | 21 | /// Foreground color for active file-tree row labels. |
| 177 | 168 | palette: DiffPalette, |
|
| 178 | 169 | decorator: Option<&dyn DiffDecorator>, |
|
| 179 | 170 | area: Rect, |
|
| 180 | 171 | buf: &mut Buffer, |
|
| 181 | 172 | ) { |
|
| 182 | - | let Some((tree_area, info_area)) = Self::areas(area) else { |
|
| 173 | + | let Some(tree_area) = Self::area(area) else { |
|
| 183 | 174 | return; |
|
| 184 | 175 | }; |
|
| 185 | 176 | let collapsed = self |
|
| 186 | 177 | .model |
|
| 187 | 178 | .branch_ids() |
| 198 | 189 | let tree = Tree::new(&styled, &self.state).style(FILE_TREE_STYLE); |
|
| 199 | 190 | let rows = tree.visible_rows(); |
|
| 200 | 191 | let view = tree.selected_view(&rows, tree_area.rows, Placement::Minimal); |
|
| 201 | 192 | ||
| 202 | 193 | view.render_rows(tree_area, buf, |row, cols| tree.render_row(rows[row], cols)); |
|
| 203 | - | if let Some(area) = info_area { |
|
| 204 | - | let stats = self.model.stats; |
|
| 205 | - | let mut table = Table::new(TableOptions { |
|
| 206 | - | spacing: 2, |
|
| 207 | - | ..TableOptions::bordered() |
|
| 208 | - | }) |
|
| 209 | - | .row([ |
|
| 210 | - | Line::new(Label::new("lines changed").fg(FOLDER_FG)), |
|
| 211 | - | Line::spaced([ |
|
| 212 | - | Label::from(format!("+{}", stats.insertions)).fg(palette.positive_fg), |
|
| 213 | - | Label::from(format!("-{}", stats.deletions)).fg(palette.negative_fg), |
|
| 214 | - | ]), |
|
| 215 | - | ]) |
|
| 216 | - | .row([ |
|
| 217 | - | Line::new(Label::new("files changed").fg(FOLDER_FG)), |
|
| 218 | - | Line::new(Label::from(format!(" {}", stats.files_changed)).fg(Color::White)), |
|
| 219 | - | ]); |
|
| 220 | - | table.render(area, buf); |
|
| 221 | - | } |
|
| 222 | 194 | } |
|
| 223 | 195 | ||
| 224 | 196 | /// Enters the file tree when it is visible. |
|
| 225 | 197 | pub(super) fn enter(&mut self, active_file: Option<FileId>) { |
|
| 226 | 198 | let chosen = active_file |
| 245 | 217 | self.state.select(id) |
|
| 246 | 218 | } |
|
| 247 | 219 | ||
| 248 | 220 | /// Selects the file-tree row at `point` inside `area`. |
|
| 249 | 221 | pub(super) fn select_at(&mut self, area: Rect, point: Point) -> Option<FileTreeClick> { |
|
| 250 | - | let (tree_area, _) = Self::areas(area)?; |
|
| 222 | + | let tree_area = Self::area(area)?; |
|
| 251 | 223 | let tree = Tree::new(&self.model, &self.state); |
|
| 252 | 224 | let rows = tree.visible_rows(); |
|
| 253 | 225 | let view = tree.selected_view(&rows, tree_area.rows, Placement::Minimal); |
|
| 254 | 226 | let hit = tree.hit_test(&rows, view, tree_area, point)?; |
|
| 255 | 227 | let id = hit.row.id; |
| 328 | 300 | .next() |
|
| 329 | 301 | .map(|row| row.id) |
|
| 330 | 302 | } |
|
| 331 | 303 | ||
| 332 | 304 | /// Returns the drawable row area for file-tree contents. |
|
| 333 | - | fn areas(area: Rect) -> Option<(Rect, Option<Rect>)> { |
|
| 305 | + | fn area(area: Rect) -> Option<Rect> { |
|
| 334 | 306 | let body: Rect = Rect::new( |
|
| 335 | 307 | area.x, |
|
| 336 | 308 | area.y.saturating_add(TOP_PADDING_ROWS), |
|
| 337 | 309 | area.cols, |
|
| 338 | 310 | area.rows.saturating_sub(TOP_PADDING_ROWS), |
|
| 339 | 311 | ); |
|
| 340 | 312 | if body.is_empty() { |
|
| 341 | 313 | return None; |
|
| 342 | 314 | } |
|
| 343 | - | let info_rows = INFO_BOX_ROWS + INFO_BOX_GAP_ROWS + MIN_TREE_ROWS_WITH_INFO; |
|
| 344 | - | let info = (body.rows >= info_rows && body.cols >= INFO_BOX_COLS).then(|| { |
|
| 345 | - | Rect::new( |
|
| 346 | - | body.x, |
|
| 347 | - | body.bottom().saturating_sub(INFO_BOX_ROWS), |
|
| 348 | - | body.cols, |
|
| 349 | - | INFO_BOX_ROWS, |
|
| 350 | - | ) |
|
| 351 | - | }); |
|
| 352 | - | let tree_rows = if info.is_some() { |
|
| 353 | - | body.rows.saturating_sub(INFO_BOX_ROWS + INFO_BOX_GAP_ROWS) |
|
| 354 | - | } else { |
|
| 355 | - | body.rows |
|
| 356 | - | }; |
|
| 357 | - | ||
| 358 | - | Some((Rect::new(body.x, body.y, body.cols, tree_rows), info)) |
|
| 315 | + | Some(body) |
|
| 359 | 316 | } |
|
| 360 | 317 | } |
|
| 361 | 318 | ||
| 362 | 319 | impl Widget for FileTree { |
|
| 363 | 320 | fn size(&self, parent: Constraint) -> Size { |
| 378 | 335 | pub(super) struct FileTreeModel { |
|
| 379 | 336 | /// Root node ids. |
|
| 380 | 337 | roots: Vec<usize>, |
|
| 381 | 338 | /// Tree nodes indexed by id. |
|
| 382 | 339 | nodes: Vec<FileTreeNode>, |
|
| 383 | - | /// Aggregate diff statistics for the summary box. |
|
| 384 | - | stats: Stats, |
|
| 385 | 340 | } |
|
| 386 | 341 | ||
| 387 | 342 | impl FileTreeModel { |
|
| 388 | 343 | /// Creates a path tree from the files in `document`. |
|
| 389 | 344 | pub(super) fn new(document: &DiffDocument, root: String) -> Self { |
|
| 390 | 345 | let mut model = Self { |
|
| 391 | 346 | roots: Vec::new(), |
|
| 392 | 347 | nodes: Vec::new(), |
|
| 393 | - | stats: document.stats(), |
|
| 394 | 348 | }; |
|
| 395 | 349 | let root = model.push_node(None, root, None, FileTreeTarget::Root); |
|
| 396 | 350 | ||
| 397 | 351 | for file in &document.files { |
|
| 398 | 352 | model.insert_file( |
a.rs
+0 -0
b.rs
+0 -0
crates/diff/tests/golden/bottom_of_file_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -1 โ๐ฎ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | 4 | โ 3 4 tail โโ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
crates/diff/tests/golden/expanded_file_card_64x9.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -1 โ๐ฎ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | 4 | โ 1 1 context โ๐ฎ |
|
| 5 | 5 | โ 2 - old โ๐ฎ |
|
| 6 | 6 | โ 2 + new โ๐ฎ |
|
| 7 | 7 | โ 3 + extra โ๐ฎ |
crates/diff/tests/golden/file_kinds_80x24.txt
+6 -6
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ new.rs created +1 โ๐ฎ |
|
| 2 | + | โ โ new.rs 1 LOC created +1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | 4 | โ 1 + new โ๐ฎ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 6 | 6 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 7 | - | โ โ old.rs deleted -1 โ๐ฎ |
|
| 7 | + | โ โ old.rs 1 LOC deleted -1 โ๐ฎ |
|
| 8 | 8 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 9 | 9 | โ 1 - old โ๐ฎ |
|
| 10 | 10 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 11 | 11 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 12 | - | โ โฆ from.rs โ to.rs moved โ๐ฎ |
|
| 12 | + | โ โฆ from.rs โ to.rs 0 LOC moved โ๐ฎ |
|
| 13 | 13 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 14 | 14 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 15 | - | โ โ copy.rs โ copy2.rs copied โ๐ฎ |
|
| 15 | + | โ โ copy.rs โ copy2.rs 0 LOC copied โ๐ฎ |
|
| 16 | 16 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 17 | 17 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 18 | - | โ โ mode.sh mode changed โ๐ฎ |
|
| 18 | + | โ โ mode.sh 0 LOC mode changed โ๐ฎ |
|
| 19 | 19 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 20 | 20 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 21 | - | โ โ image.png binary โ๐ฎ |
|
| 21 | + | โ โ image.png 0 LOC binary โ๐ฎ |
|
| 22 | 22 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 23 | 23 | ๐ฎ |
|
| 24 | 24 | ๐ฎ |
crates/diff/tests/golden/focused_second_file_64x6.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ b.rs +1 -1 โ๐ฎ |
|
| 2 | + | โ โ b.rs 2 LOC +1 -1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | 4 | โ 1 1 keep โโ |
|
| 5 | 5 | โ 2 - before โโ |
|
| 6 | 6 | โ 2 + after โโ |
crates/diff/tests/golden/highlighted_source_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | - | โ โ a.rs +2 -1 โโ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 4 | 4 | โ 1 1 highlighted context โ๐ฎ |
|
| 5 | 5 | โ 2 - old โ๐ฎ |
crates/diff/tests/golden/multi_hunk_gap_64x12.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -2 โ๐ฎ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -2 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | 4 | โ 1 1 keep โ๐ฎ |
|
| 5 | 5 | โ 2 - old โ๐ฎ |
|
| 6 | 6 | โ 2 + new โ๐ฎ |
|
| 7 | 7 | โ โฎ โ๐ฎ |
crates/diff/tests/golden/narrow_view_14x8.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโฎโ |
|
| 2 | - | โ โ a.rs +โฆ โโ |
|
| 2 | + | โ โ a.rs 4โฆ โโ |
|
| 3 | 3 | โโโโโโโโโโโโโคโ |
|
| 4 | 4 | โ 1 1 โฆ โโ |
|
| 5 | 5 | โ 2 โฆ โโ |
|
| 6 | 6 | โ 2 โฆ โโ |
|
| 7 | 7 | โ 3 โฆ โโ |
crates/diff/tests/golden/preamble_and_no_newline_64x17.txt
+1 -1
| 7 | 7 | โ โ๐ฎ |
|
| 8 | 8 | โ Message body text 1. โ๐ฎ |
|
| 9 | 9 | โ Message body text 2. โ๐ฎ |
|
| 10 | 10 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 11 | 11 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 12 | - | โ โ a.rs +1 -1 โ๐ฎ |
|
| 12 | + | โ โ a.rs 1 LOC +1 -1 โ๐ฎ |
|
| 13 | 13 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 14 | 14 | โ 1 - old โ๐ฎ |
|
| 15 | 15 | โ 1 + new โ๐ฎ |
|
| 16 | 16 | โ \ No newline at end of file โ๐ฎ |
|
| 17 | 17 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
crates/diff/tests/golden/sticky_header_before_next_file_64x5.txt
+1 -1
| 1 | 1 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 2 | 2 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 3 | - | โ โ b.rs +1 -1 โโ |
|
| 3 | + | โ โ b.rs 2 LOC +1 -1 โโ |
|
| 4 | 4 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 5 | 5 | โ 1 1 keep โ๐ฎ |
crates/diff/tests/golden/sticky_header_file_end_boundary_64x5.txt
+2 -2
| 1 | - | โ โ a.rs +2 -1 โ๐ฎ |
|
| 1 | + | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 2 | 2 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 3 | 3 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
|
| 4 | 4 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 5 | - | โ โ b.rs +1 -1 โ๐ฎ |
|
| 5 | + | โ โ b.rs 2 LOC +1 -1 โ๐ฎ |
crates/diff/tests/golden/sticky_header_full_corner_boundary_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -1 โโ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | 4 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 5 | 5 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
crates/diff/tests/golden/sticky_header_inside_file_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -1 โ๐ฎ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | 4 | โ 3 4 tail โโ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
crates/diff/tests/golden/sticky_header_replaces_chrome_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | - | โ โ a.rs +2 -1 โโ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | 4 | โ 3 + extra โโ |
|
| 5 | 5 | โ 3 4 tail โ๐ฎ |
crates/diff/tests/golden/sticky_header_starting_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | - | โ โ a.rs +2 -1 โโ |
|
| 2 | + | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | 4 | โ 2 - old โ๐ฎ |
|
| 5 | 5 | โ 2 + new โ๐ฎ |
crates/diff/tests/golden/wide_file_tree_120x12.txt
+2 -2
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | - | โฟ rustik/ โ โ a.rs +2 -1 โโ |
|
| 2 | + | โฟ rustik/ โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โ a.rs โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 4 | 4 | โ b.rs โ 1 1 context โโ |
|
| 5 | 5 | โ 2 - old โโ |
|
| 6 | 6 | โ 2 + new โโ |
|
| 7 | 7 | โ 3 + extra โโ |
|
| 8 | 8 | โ 3 4 tail โโ |
|
| 9 | 9 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
|
| 10 | 10 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 11 | - | โ โ b.rs +1 -1 โ๐ฎ |
|
| 11 | + | โ โ b.rs 2 LOC +1 -1 โ๐ฎ |
|
| 12 | 12 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |