Browse Source

ui: use BoundsIterator in clear_area

tags/alpha-0.4.1
Manos Pitsidianakis 2 months ago
parent
commit
c431fb6dff
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
2 changed files with 12 additions and 10 deletions
  1. +6
    -4
      ui/src/components/mail/listing/plain.rs
  2. +6
    -6
      ui/src/terminal/cells.rs

+ 6
- 4
ui/src/components/mail/listing/plain.rs View File

@@ -252,17 +252,19 @@ impl ListingTrait for PlainListing {
let remainder = width
.saturating_sub(self.data_columns.widths[0])
.saturating_sub(self.data_columns.widths[1])
- 4;
.saturating_sub(4);
self.data_columns.widths[2] = remainder / 6;
self.data_columns.widths[4] = (2 * remainder) / 3 - self.data_columns.widths[3];
self.data_columns.widths[4] =
((2 * remainder) / 3).saturating_sub(self.data_columns.widths[3]);
} else {
let remainder = width
.saturating_sub(self.data_columns.widths[0])
.saturating_sub(self.data_columns.widths[1])
.saturating_sub(8);
if min_col_width + self.data_columns.widths[4] > remainder {
self.data_columns.widths[4] =
remainder - min_col_width - self.data_columns.widths[3];
self.data_columns.widths[4] = remainder
.saturating_sub(min_col_width)
.saturating_sub(self.data_columns.widths[3]);
self.data_columns.widths[2] = min_col_width;
}
}


+ 6
- 6
ui/src/terminal/cells.rs View File

@@ -363,10 +363,10 @@ impl CellBuffer {
pub fn bounds_iter(&self, area: Area) -> BoundsIterator {
BoundsIterator {
rows: std::cmp::min(self.rows.saturating_sub(1), get_y(upper_left!(area)))
..(std::cmp::min(self.rows, get_y(bottom_right!(area))) + 1),
..(std::cmp::min(self.rows, get_y(bottom_right!(area)) + 1)),
cols: (
std::cmp::min(self.cols.saturating_sub(1), get_x(upper_left!(area))),
std::cmp::min(self.cols.saturating_sub(1), get_x(bottom_right!(area))),
std::cmp::min(self.cols, get_x(bottom_right!(area)) + 1),
),
}
}
@@ -1043,9 +1043,9 @@ pub fn clear_area(grid: &mut CellBuffer, area: Area) {
}
let upper_left = upper_left!(area);
let bottom_right = bottom_right!(area);
for y in get_y(upper_left)..=get_y(bottom_right) {
for x in get_x(upper_left)..=get_x(bottom_right) {
grid[(x, y)] = Cell::default();
for row in grid.bounds_iter(area) {
for c in row {
grid[c] = Cell::default();
}
}
}
@@ -1325,7 +1325,7 @@ impl Iterator for BoundsIterator {
if let Some(next_row) = self.rows.next() {
Some(RowIterator {
row: next_row,
col: self.cols.0..(self.cols.1 + 1),
col: self.cols.0..self.cols.1,
})
} else {
None


Loading…
Cancel
Save