optimize track callback

This commit is contained in:
🪞👃🪞 2024-07-07 00:17:49 +03:00
parent e98c110dbe
commit acb952736e
2 changed files with 52 additions and 29 deletions

View file

@ -106,15 +106,17 @@ mod horizontal {
cell_lo.set_char('▄');
cell_lo.set_style(dim);
let keys = [&cell_lo, &cell_lo, &cell_full, &cell_hi, &cell_hi, &cell_hi];
let cell_keys = [&cell_lo, &cell_lo, &cell_full, &cell_hi, &cell_hi, &cell_hi];
let Rect { x, y, width, height } = area;
let height = height.min(128);
let h = height.saturating_sub(2);
for index in 0..h {
let y = y + h - index;
*buf.get_mut(x + 1, y) = keys[(index % 6) as usize].clone();
*buf.get_mut(x + 2, y) = cell_full.clone();
let key1 = buf.get_mut(x + 1, y);
*key1 = cell_keys[(index % 6) as usize].clone();
let key2 = buf.get_mut(x + 2, y);
*key2 = cell_full.clone();
for x in x+5..x+width-1 {
*buf.get_mut(x, y) = cell_bg.clone();
}