use justerm_core::{Cell, CellFlags, Color, Frame, FrameKind, Span, encode};
use std::collections::BTreeMap;
const COLS: u16 = 80;
const ROWS: u16 = 24;
fn main() {
let path = std::env::args()
.nth(1)
.expect("usage: gen_render_frame <out-file>");
let text = b"The quick brown fox jumps over the lazy dog while 1234567890 ticks by. ";
let mut spans = Vec::with_capacity(ROWS as usize);
for row in 0..ROWS {
let cells: Vec<Cell> = (0..COLS)
.map(|col| {
let ch = text[(row as usize * 7 + col as usize) % text.len()] as char;
let fg = Color::Indexed(((col / 5) % 256) as u8);
Cell::from_parts(ch, fg, Color::Default, CellFlags::empty())
})
.collect();
spans.push(Span {
line: row,
left: 0,
right: COLS - 1,
cells,
combining: BTreeMap::new(),
links: BTreeMap::new(),
ucolors: BTreeMap::new(),
});
}
let frame = Frame {
cols: COLS,
rows: ROWS,
kind: FrameKind::Full,
cursor_row: 0,
cursor_col: 0,
cursor_visible: true,
cursor_shape: justerm_core::CursorShape::Block,
cursor_blink: false,
display_offset: 0,
scrollback_len: 0,
mouse_events: Default::default(),
alt_screen: false,
scroll: None,
spans,
side_table: vec![],
link_table: vec![],
overlay: Default::default(),
};
let bytes = encode(&frame);
std::fs::write(&path, &bytes).expect("write frame");
eprintln!(
"gen_render_frame: wrote {} ({} wire bytes, {} cells)",
path,
bytes.len(),
COLS as usize * ROWS as usize
);
}