Convert Screen::write_char() to usize

This commit is contained in:
kerty 2025-01-24 20:31:50 +03:00 committed by Johannes Altmanninger
parent 7acc2b7223
commit 9915a07741

View File

@ -960,9 +960,9 @@ impl Screen {
} }
/// Convert a wide character to a multibyte string and append it to the buffer. /// Convert a wide character to a multibyte string and append it to the buffer.
fn write_char(&mut self, c: char, width: isize) { fn write_char(&mut self, c: char, width: usize) {
let mut zelf = self.scoped_buffer(); let mut zelf = self.scoped_buffer();
zelf.actual.cursor.x = zelf.actual.cursor.x.wrapping_add(width as usize); zelf.actual.cursor.x = zelf.actual.cursor.x.wrapping_add(width);
zelf.outp.borrow_mut().writech(c); zelf.outp.borrow_mut().writech(c);
if Some(zelf.actual.cursor.x) == zelf.actual.screen_width && allow_soft_wrap() { if Some(zelf.actual.cursor.x) == zelf.actual.screen_width && allow_soft_wrap() {
zelf.soft_wrap_location = Some(Cursor { zelf.soft_wrap_location = Some(Cursor {
@ -1254,7 +1254,7 @@ impl Screen {
set_color(&mut zelf, color); set_color(&mut zelf, color);
let ch = o_line(&zelf, i).char_at(j); let ch = o_line(&zelf, i).char_at(j);
let width = wcwidth_rendered_min_0(ch); let width = wcwidth_rendered_min_0(ch);
zelf.write_char(ch, isize::try_from(width).unwrap()); zelf.write_char(ch, width);
current_width += width; current_width += width;
j += 1; j += 1;
} }