Add Cell::keep_attrs() method
parent
4bc8ff2ce9
commit
465c78e903
|
@ -1038,12 +1038,13 @@ impl CompactListing {
|
|||
columns[4][c].set_bg(color);
|
||||
}
|
||||
for c in columns[4].row_iter(_x..(_x + 1), idx) {
|
||||
columns[4][c].set_bg(color);
|
||||
columns[4][c].set_keep_bg(true);
|
||||
columns[4][c].set_bg(color).set_keep_bg(true);
|
||||
}
|
||||
for c in columns[4].row_iter((x + 1)..(_x + 1), idx) {
|
||||
columns[4][c].set_keep_fg(true);
|
||||
columns[4][c].set_keep_bg(true);
|
||||
columns[4][c]
|
||||
.set_keep_fg(true)
|
||||
.set_keep_bg(true)
|
||||
.set_keep_attrs(true);
|
||||
}
|
||||
for c in columns[4].row_iter(x..(x + 1), idx) {
|
||||
columns[4][c].set_keep_bg(true);
|
||||
|
@ -1241,12 +1242,15 @@ impl CompactListing {
|
|||
);
|
||||
self.data_columns.columns[4][(x, idx)].set_bg(color);
|
||||
if _x < min_width.4 {
|
||||
self.data_columns.columns[4][(_x, idx)].set_bg(color);
|
||||
self.data_columns.columns[4][(_x, idx)].set_keep_bg(true);
|
||||
self.data_columns.columns[4][(_x, idx)]
|
||||
.set_bg(color)
|
||||
.set_keep_bg(true);
|
||||
}
|
||||
for x in (x + 1).._x {
|
||||
self.data_columns.columns[4][(x, idx)].set_keep_fg(true);
|
||||
self.data_columns.columns[4][(x, idx)].set_keep_bg(true);
|
||||
self.data_columns.columns[4][(x, idx)]
|
||||
.set_keep_fg(true)
|
||||
.set_keep_bg(true)
|
||||
.set_keep_attrs(true);
|
||||
}
|
||||
self.data_columns.columns[4][(x, idx)].set_keep_bg(true);
|
||||
x = _x + 1;
|
||||
|
|
|
@ -492,6 +492,7 @@ pub struct Cell {
|
|||
attrs: Attr,
|
||||
keep_fg: bool,
|
||||
keep_bg: bool,
|
||||
keep_attrs: bool,
|
||||
}
|
||||
|
||||
impl Cell {
|
||||
|
@ -515,6 +516,7 @@ impl Cell {
|
|||
empty: false,
|
||||
keep_fg: false,
|
||||
keep_bg: false,
|
||||
keep_attrs: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,6 +577,7 @@ impl Cell {
|
|||
self.ch = newch;
|
||||
self.keep_fg = false;
|
||||
self.keep_bg = false;
|
||||
self.keep_attrs = false;
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -643,7 +646,9 @@ impl Cell {
|
|||
}
|
||||
|
||||
pub fn set_attrs(&mut self, newattrs: Attr) -> &mut Cell {
|
||||
self.attrs = newattrs;
|
||||
if !self.keep_attrs {
|
||||
self.attrs = newattrs;
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -671,6 +676,13 @@ impl Cell {
|
|||
self.keep_bg = new_val;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets `keep_attrs` field. If true, the text attributes will not be altered if attempted so
|
||||
/// until the character content of the cell is changed.
|
||||
pub fn set_keep_attrs(&mut self, new_val: bool) -> &mut Cell {
|
||||
self.keep_attrs = new_val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Cell {
|
||||
|
@ -1719,13 +1731,14 @@ pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area,
|
|||
grid_dest[(x, y)] = grid_src[(src_x, src_y)];
|
||||
for t in &stack {
|
||||
if let Some(fg) = grid_src.tag_table()[&t].fg {
|
||||
grid_dest[(x, y)].set_fg(fg);
|
||||
grid_dest[(x, y)].set_fg(fg).set_keep_fg(true);
|
||||
}
|
||||
if let Some(bg) = grid_src.tag_table()[&t].bg {
|
||||
grid_dest[(x, y)].set_bg(bg);
|
||||
grid_dest[(x, y)].set_bg(bg).set_keep_bg(true);
|
||||
}
|
||||
if let Some(attrs) = grid_src.tag_table()[&t].attrs {
|
||||
grid_dest[(x, y)].attrs |= attrs;
|
||||
grid_dest[(x, y)].set_keep_attrs(true);
|
||||
}
|
||||
}
|
||||
if src_x >= get_x(bottom_right!(src)) {
|
||||
|
|
Loading…
Reference in New Issue