ui: use BoundsIterator in clear_area
parent
9d8d3e09f4
commit
c431fb6dff
|
@ -252,17 +252,19 @@ impl ListingTrait for PlainListing {
|
||||||
let remainder = width
|
let remainder = width
|
||||||
.saturating_sub(self.data_columns.widths[0])
|
.saturating_sub(self.data_columns.widths[0])
|
||||||
.saturating_sub(self.data_columns.widths[1])
|
.saturating_sub(self.data_columns.widths[1])
|
||||||
- 4;
|
.saturating_sub(4);
|
||||||
self.data_columns.widths[2] = remainder / 6;
|
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 {
|
} else {
|
||||||
let remainder = width
|
let remainder = width
|
||||||
.saturating_sub(self.data_columns.widths[0])
|
.saturating_sub(self.data_columns.widths[0])
|
||||||
.saturating_sub(self.data_columns.widths[1])
|
.saturating_sub(self.data_columns.widths[1])
|
||||||
.saturating_sub(8);
|
.saturating_sub(8);
|
||||||
if min_col_width + self.data_columns.widths[4] > remainder {
|
if min_col_width + self.data_columns.widths[4] > remainder {
|
||||||
self.data_columns.widths[4] =
|
self.data_columns.widths[4] = remainder
|
||||||
remainder - min_col_width - self.data_columns.widths[3];
|
.saturating_sub(min_col_width)
|
||||||
|
.saturating_sub(self.data_columns.widths[3]);
|
||||||
self.data_columns.widths[2] = min_col_width;
|
self.data_columns.widths[2] = min_col_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,10 +363,10 @@ impl CellBuffer {
|
||||||
pub fn bounds_iter(&self, area: Area) -> BoundsIterator {
|
pub fn bounds_iter(&self, area: Area) -> BoundsIterator {
|
||||||
BoundsIterator {
|
BoundsIterator {
|
||||||
rows: std::cmp::min(self.rows.saturating_sub(1), get_y(upper_left!(area)))
|
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: (
|
cols: (
|
||||||
std::cmp::min(self.cols.saturating_sub(1), get_x(upper_left!(area))),
|
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 upper_left = upper_left!(area);
|
||||||
let bottom_right = bottom_right!(area);
|
let bottom_right = bottom_right!(area);
|
||||||
for y in get_y(upper_left)..=get_y(bottom_right) {
|
for row in grid.bounds_iter(area) {
|
||||||
for x in get_x(upper_left)..=get_x(bottom_right) {
|
for c in row {
|
||||||
grid[(x, y)] = Cell::default();
|
grid[c] = Cell::default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1325,7 +1325,7 @@ impl Iterator for BoundsIterator {
|
||||||
if let Some(next_row) = self.rows.next() {
|
if let Some(next_row) = self.rows.next() {
|
||||||
Some(RowIterator {
|
Some(RowIterator {
|
||||||
row: next_row,
|
row: next_row,
|
||||||
col: self.cols.0..(self.cols.1 + 1),
|
col: self.cols.0..self.cols.1,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue