Allow for undefined buffer width and/or height, fixes #70

This commit is contained in:
Jeremy Soller 2024-06-12 09:04:04 -06:00
parent cd1cd0a337
commit 93a7df859a
15 changed files with 99 additions and 72 deletions

View file

@ -102,7 +102,7 @@ fn main() {
// Set scroll to view scroll
buffer.set_scroll(*scroll);
// Set size, will relayout and shape until scroll if changed
buffer.set_size(width as f32, height as f32);
buffer.set_size(Some(width as f32), Some(height as f32));
// Shape until scroll, ensures scroll is clamped
//TODO: ability to prune with multiple views?
buffer.shape_until_scroll(true);
@ -154,10 +154,10 @@ fn main() {
scroll.vertical -= buffer.metrics().line_height;
}
Key::Named(NamedKey::PageDown) => {
scroll.vertical += buffer.size().1;
scroll.vertical += buffer.size().1.unwrap_or(0.0);
}
Key::Named(NamedKey::PageUp) => {
scroll.vertical -= buffer.size().1;
scroll.vertical -= buffer.size().1.unwrap_or(0.0);
}
_ => {}
}