Skip to content

Commit b376e39

Browse files
okt4vclaude
andcommitted
style: apply rustfmt to gen_demo example
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9e69e4d commit b376e39

3 files changed

Lines changed: 619 additions & 264 deletions

File tree

crates/asat-tui/src/grid.rs

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,15 @@ impl<'a> Widget for GridWidget<'a> {
263263
.map(|c| Color::Rgb(c.r, c.g, c.b))
264264
.unwrap_or(cell_bg)
265265
};
266-
render_cell_str(buf, x, screen_y, col_width, "", Style::default().bg(bg), false);
266+
render_cell_str(
267+
buf,
268+
x,
269+
screen_y,
270+
col_width,
271+
"",
272+
Style::default().bg(bg),
273+
false,
274+
);
267275
}
268276
// row_idx == m.row_start but col != m.col_start: same-row covered cell,
269277
// anchor's wide render already painted this area — just advance x.
@@ -581,7 +589,15 @@ impl<'a> Widget for GridWidget<'a> {
581589
} else {
582590
Style::default().fg(darken(header_fg, 0.6)).bg(header_bg)
583591
};
584-
render_cell_str(buf, area.x, ey, ROW_GUTTER_WIDTH, " │", cont_style, false);
592+
render_cell_str(
593+
buf,
594+
area.x,
595+
ey,
596+
ROW_GUTTER_WIDTH,
597+
" │",
598+
cont_style,
599+
false,
600+
);
585601

586602
// Fill cells with background; render wrapped text for wrap-enabled cells
587603
let mut ex = area.x + ROW_GUTTER_WIDTH;
@@ -868,9 +884,15 @@ fn render_data_cell(
868884
.and_then(|c| c.style.as_ref())
869885
.map(|s| s.align);
870886
match user_align {
871-
Some(Alignment::Right) => render_cell_right(buf, x, y, col_width, &display, cell_style, underline_full),
872-
Some(Alignment::Center) => render_cell_centered(buf, x, y, col_width, &display, cell_style, underline_full),
873-
Some(Alignment::Left) => render_cell_str(buf, x, y, col_width, &display, cell_style, underline_full),
887+
Some(Alignment::Right) => {
888+
render_cell_right(buf, x, y, col_width, &display, cell_style, underline_full)
889+
}
890+
Some(Alignment::Center) => {
891+
render_cell_centered(buf, x, y, col_width, &display, cell_style, underline_full)
892+
}
893+
Some(Alignment::Left) => {
894+
render_cell_str(buf, x, y, col_width, &display, cell_style, underline_full)
895+
}
874896
_ => {
875897
if matches!(raw_value, CellValue::Number(_) | CellValue::Boolean(_)) {
876898
render_cell_right(buf, x, y, col_width, &display, cell_style, underline_full);
@@ -920,12 +942,24 @@ fn is_in_visual_selection(
920942
}
921943

922944
/// Render a fixed-width cell left-aligned. Appends "…" (single char) if content is wider.
923-
fn render_cell_str(buf: &mut Buffer, x: u16, y: u16, width: u16, content: &str, style: Style, underline_full: bool) {
945+
fn render_cell_str(
946+
buf: &mut Buffer,
947+
x: u16,
948+
y: u16,
949+
width: u16,
950+
content: &str,
951+
style: Style,
952+
underline_full: bool,
953+
) {
924954
if width == 0 {
925955
return;
926956
}
927957
// Strip underline from padding unless underline_full is set
928-
let bg_style = if underline_full { style } else { style.remove_modifier(Modifier::UNDERLINED) };
958+
let bg_style = if underline_full {
959+
style
960+
} else {
961+
style.remove_modifier(Modifier::UNDERLINED)
962+
};
929963
for dx in 0..width {
930964
if let Some(cell) = buf.cell_mut((x + dx, y)) {
931965
cell.set_char(' ');
@@ -967,11 +1001,23 @@ fn render_cell_str(buf: &mut Buffer, x: u16, y: u16, width: u16, content: &str,
9671001
}
9681002

9691003
/// Right-aligned cell render. Shows "####" when a number won't fit (Excel convention).
970-
fn render_cell_right(buf: &mut Buffer, x: u16, y: u16, width: u16, content: &str, style: Style, underline_full: bool) {
1004+
fn render_cell_right(
1005+
buf: &mut Buffer,
1006+
x: u16,
1007+
y: u16,
1008+
width: u16,
1009+
content: &str,
1010+
style: Style,
1011+
underline_full: bool,
1012+
) {
9711013
if width == 0 {
9721014
return;
9731015
}
974-
let bg_style = if underline_full { style } else { style.remove_modifier(Modifier::UNDERLINED) };
1016+
let bg_style = if underline_full {
1017+
style
1018+
} else {
1019+
style.remove_modifier(Modifier::UNDERLINED)
1020+
};
9751021
for dx in 0..width {
9761022
if let Some(cell) = buf.cell_mut((x + dx, y)) {
9771023
cell.set_char(' ');
@@ -1011,11 +1057,23 @@ fn render_cell_right(buf: &mut Buffer, x: u16, y: u16, width: u16, content: &str
10111057
}
10121058

10131059
/// Center-aligned cell render (for column headers)
1014-
fn render_cell_centered(buf: &mut Buffer, x: u16, y: u16, width: u16, content: &str, style: Style, underline_full: bool) {
1060+
fn render_cell_centered(
1061+
buf: &mut Buffer,
1062+
x: u16,
1063+
y: u16,
1064+
width: u16,
1065+
content: &str,
1066+
style: Style,
1067+
underline_full: bool,
1068+
) {
10151069
if width == 0 {
10161070
return;
10171071
}
1018-
let bg_style = if underline_full { style } else { style.remove_modifier(Modifier::UNDERLINED) };
1072+
let bg_style = if underline_full {
1073+
style
1074+
} else {
1075+
style.remove_modifier(Modifier::UNDERLINED)
1076+
};
10191077
for dx in 0..width {
10201078
if let Some(cell) = buf.cell_mut((x + dx, y)) {
10211079
cell.set_char(' ');

0 commit comments

Comments
 (0)