From 15cee6bb4851ae538bc6ba97ea7ac28dfaf33e2e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:15:56 +0100 Subject: [PATCH] fbcond: Resize ransid console on every write This is necessary to correctly handle async changes to the framebuffer size in the future. --- graphics/fbcond/src/text.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/graphics/fbcond/src/text.rs b/graphics/fbcond/src/text.rs index 7f75c6fbc5..2adcc5a7dd 100644 --- a/graphics/fbcond/src/text.rs +++ b/graphics/fbcond/src/text.rs @@ -21,7 +21,8 @@ pub struct TextScreen { impl TextScreen { pub fn new(display: Display) -> TextScreen { TextScreen { - console: ransid::Console::new(display.width / 8, display.height / 16), + // Width and height will be filled in on the next write to the console + console: ransid::Console::new(0, 0), display, changed: BTreeSet::new(), ctrl: false, @@ -121,8 +122,6 @@ impl TextScreen { pub fn resize(&mut self, width: usize, height: usize) { self.display .resize(width.try_into().unwrap(), height.try_into().unwrap()); - self.console.state.w = width / 8; - self.console.state.h = height / 16; } pub fn input(&mut self, event: &Event) { @@ -223,6 +222,10 @@ impl TextScreen { } pub fn write(&mut self, buf: &[u8]) -> Result { + self.console.state.w = self.display.width / 8; + self.console.state.h = self.display.height / 16; + self.console.state.bottom_margin = (self.display.height / 16).saturating_sub(1); + if self.console.state.cursor && self.console.state.x < self.console.state.w && self.console.state.y < self.console.state.h