more entrypoint macros

This commit is contained in:
facile pop culture reference 2026-07-25 15:13:05 +03:00
parent 4cfe8d087c
commit 66ac2bcbb6
18 changed files with 696 additions and 663 deletions

64
src/term/scroll.rs Normal file
View file

@ -0,0 +1,64 @@
use crate::*;
use ratatui::{prelude::{Style, Position, Backend, Color}};
pub const ICON_DEC_V: &[char] = &['▲'];
pub const ICON_INC_V: &[char] = &['▼'];
pub const ICON_DEC_H: &[char] = &[' ', '🞀', ' '];
pub const ICON_INC_H: &[char] = &[' ', '🞂', ' '];
pub fn x_scroll () -> impl Draw<Tui> {
thunk(|Tui(buf, XYWH(x1, y1, w, h)): &mut Tui|{
let x2 = *x1 + *w;
for (i, x) in (*x1..=x2).enumerate() {
if let Some(cell) = buf.cell_mut(Position::from((x, *y1))) {
if i < (ICON_DEC_H.len()) {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Rgb(0, 0, 0));
cell.set_char(ICON_DEC_H[i as usize]);
} else if i > (*w as usize - ICON_INC_H.len()) {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Rgb(0, 0, 0));
cell.set_char(ICON_INC_H[*w as usize - i]);
} else if false {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Reset);
cell.set_char('━');
} else {
cell.set_fg(Rgb(0, 0, 0));
cell.set_bg(Reset);
cell.set_char('╌');
}
}
}
Ok(Some(XYWH(*x1, *y1, *w, 1)))
})
}
pub fn y_scroll () -> impl Draw<Tui> {
thunk(|Tui(buf, XYWH(x1, y1, w, h)): &mut Tui|{
let y2 = *y1 + *h;
for (i, y) in (*y1..=y2).enumerate() {
if let Some(cell) = buf.cell_mut(Position::from((*x1, y))) {
if (i as usize) < (ICON_DEC_V.len()) {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Rgb(0, 0, 0));
cell.set_char(ICON_DEC_V[i as usize]);
} else if (i as usize) > (*h as usize - ICON_INC_V.len()) {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Rgb(0, 0, 0));
cell.set_char(ICON_INC_V[*h as usize - i]);
} else if false {
cell.set_fg(Rgb(255, 255, 255));
cell.set_bg(Reset);
cell.set_char('‖'); // ━
} else {
cell.set_fg(Rgb(0, 0, 0));
cell.set_bg(Reset);
cell.set_char('╎'); // ━
}
}
}
Ok(Some(XYWH(*x1, *y1, 1, *h)))
})
}