mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 19:26:09 +00:00
curses backends: don't crash on weird input
This commit is contained in:
parent
2cae042a85
commit
beefac9c6a
@ -266,10 +266,12 @@ impl backend::Backend for Concrete {
|
|||||||
|
|
||||||
// Is it a UTF-8 starting point?
|
// Is it a UTF-8 starting point?
|
||||||
if 32 <= ch && ch <= 255 && ch != 127 {
|
if 32 <= ch && ch <= 255 && ch != 127 {
|
||||||
Event::Char(
|
|
||||||
utf8::read_char(ch as u8, || Some(ncurses::getch() as u8))
|
utf8::read_char(ch as u8, || Some(ncurses::getch() as u8))
|
||||||
.unwrap(),
|
.map(Event::Char)
|
||||||
)
|
.unwrap_or_else(|e| {
|
||||||
|
warn!("Error reading input: {}", e);
|
||||||
|
Event::Unknown(vec![ch as u8])
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
self.parse_ncurses_char(ch)
|
self.parse_ncurses_char(ch)
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,6 @@ impl backend::Backend for Concrete {
|
|||||||
pancurses::Input::Character(c)
|
pancurses::Input::Character(c)
|
||||||
if 32 <= (c as u32) && (c as u32) <= 255 =>
|
if 32 <= (c as u32) && (c as u32) <= 255 =>
|
||||||
{
|
{
|
||||||
Event::Char(
|
|
||||||
utf8::read_char(c as u8, || {
|
utf8::read_char(c as u8, || {
|
||||||
self.window.getch().and_then(|i| match i {
|
self.window.getch().and_then(|i| match i {
|
||||||
pancurses::Input::Character(c) => {
|
pancurses::Input::Character(c) => {
|
||||||
@ -249,8 +248,11 @@ impl backend::Backend for Concrete {
|
|||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}).unwrap(),
|
}).map(Event::Char)
|
||||||
)
|
.unwrap_or_else(|e| {
|
||||||
|
warn!("Error reading input: {}", e);
|
||||||
|
Event::Unknown(vec![c as u8])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
pancurses::Input::Character(c) if (c as u32) <= 26 => {
|
pancurses::Input::Character(c) if (c as u32) <= 26 => {
|
||||||
Event::CtrlChar((b'a' - 1 + c as u8) as char)
|
Event::CtrlChar((b'a' - 1 + c as u8) as char)
|
||||||
|
Loading…
Reference in New Issue
Block a user