[PAN] Interprete 'carriage return' as 'enter' (#342)

Pancurses returns different key codes for "Enter" in the normal area
('\r'), and the one in the numpad ('\n'). Cursive only interpretes '\n'
as Enter, and leaves '\r' as CtrlChar('m'), which is different than
that with NCurses on Linux, and makes 'Enter' key not trigger a clicked
event on buttons.
This commit is contained in:
Shixin Zeng 2019-05-08 13:07:05 -04:00 committed by Alexandre Bury
parent cf86f64334
commit df0391aef2

View File

@ -135,7 +135,8 @@ impl Backend {
if let Some(ev) = self.window.getch() { if let Some(ev) = self.window.getch() {
Some(match ev { Some(match ev {
pancurses::Input::Character('\n') => Event::Key(Key::Enter), pancurses::Input::Character('\n')
| pancurses::Input::Character('\r') => Event::Key(Key::Enter),
// TODO: wait for a very short delay. If more keys are // TODO: wait for a very short delay. If more keys are
// pipelined, it may be an escape sequence. // pipelined, it may be an escape sequence.
pancurses::Input::Character('\u{7f}') pancurses::Input::Character('\u{7f}')