fix non-ascii input causing crashes

This commit is contained in:
Crispy 2024-10-07 18:45:24 +02:00
parent 040b3d3779
commit 90d2e35ade

View file

@ -445,7 +445,14 @@ impl Editor {
let input_x = 560;
let width = d.get_screen_width();
if self.input_as_text {
let mut input_text = String::from_utf8_lossy(self.machine.input()).to_string();
let mut input_text = String::new();
for &byte in self.machine.input() {
if byte.is_ascii_graphic() || byte == b' ' {
input_text.push(byte as char);
} else {
input_text.push('\\');
}
}
if text_input(
d,
Rectangle::new(input_x as f32, 5., (width - input_x - 5) as f32, 30.),