Update for latest bear-lib-terminal

This commit is contained in:
Alexandre Bury 2018-11-05 11:03:52 -08:00
parent 005d505cc4
commit e111f982b9
2 changed files with 342 additions and 243 deletions

View File

@ -40,7 +40,7 @@ version = "1.0"
[dependencies.bear-lib-terminal] [dependencies.bear-lib-terminal]
optional = true optional = true
version = "1.3" version = "1.4"
[dependencies.ncurses] [dependencies.ncurses]
features = ["wide"] features = ["wide"]

View File

@ -107,11 +107,13 @@ impl Backend {
position: self.mouse_position, position: self.mouse_position,
offset: Vec2::zero(), offset: Vec2::zero(),
} }
}).unwrap_or(Event::Unknown(vec![])) })
.unwrap_or(Event::Unknown(vec![]))
} }
BltEvent::ShiftReleased | BltEvent::ControlReleased => { BltEvent::ShiftReleased | BltEvent::ControlReleased => {
Event::Refresh Event::Refresh
} }
_ => Event::Unknown(vec![]),
} }
}) })
} }
@ -166,7 +168,8 @@ impl Backend {
position: self.mouse_position, position: self.mouse_position,
offset: Vec2::zero(), offset: Vec2::zero(),
} }
}).unwrap_or(Event::Unknown(vec![])), })
.unwrap_or(Event::Unknown(vec![])),
KeyCode::A KeyCode::A
| KeyCode::B | KeyCode::B
| KeyCode::C | KeyCode::C
@ -229,11 +232,13 @@ impl Backend {
| KeyCode::Num7 | KeyCode::Num7
| KeyCode::Num8 | KeyCode::Num8
| KeyCode::Num9 | KeyCode::Num9
| KeyCode::Num0 => if ctrl { | KeyCode::Num0 => {
if ctrl {
Event::CtrlChar(blt_keycode_to_char(kc, shift)) Event::CtrlChar(blt_keycode_to_char(kc, shift))
} else { } else {
Event::Char(blt_keycode_to_char(kc, shift)) Event::Char(blt_keycode_to_char(kc, shift))
}, }
}
} }
} }
} }
@ -398,241 +403,335 @@ fn colour_to_blt_colour(clr: Color, role: ColorRole) -> BltColor {
fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char { fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char {
match kc { match kc {
KeyCode::A => if shift { KeyCode::A => {
if shift {
'A' 'A'
} else { } else {
'a' 'a'
}, }
KeyCode::B => if shift { }
KeyCode::B => {
if shift {
'B' 'B'
} else { } else {
'b' 'b'
}, }
KeyCode::C => if shift { }
KeyCode::C => {
if shift {
'C' 'C'
} else { } else {
'c' 'c'
}, }
KeyCode::D => if shift { }
KeyCode::D => {
if shift {
'D' 'D'
} else { } else {
'd' 'd'
}, }
KeyCode::E => if shift { }
KeyCode::E => {
if shift {
'E' 'E'
} else { } else {
'e' 'e'
}, }
KeyCode::F => if shift { }
KeyCode::F => {
if shift {
'F' 'F'
} else { } else {
'f' 'f'
}, }
KeyCode::G => if shift { }
KeyCode::G => {
if shift {
'G' 'G'
} else { } else {
'g' 'g'
}, }
KeyCode::H => if shift { }
KeyCode::H => {
if shift {
'H' 'H'
} else { } else {
'h' 'h'
}, }
KeyCode::I => if shift { }
KeyCode::I => {
if shift {
'I' 'I'
} else { } else {
'i' 'i'
}, }
KeyCode::J => if shift { }
KeyCode::J => {
if shift {
'J' 'J'
} else { } else {
'j' 'j'
}, }
KeyCode::K => if shift { }
KeyCode::K => {
if shift {
'K' 'K'
} else { } else {
'k' 'k'
}, }
KeyCode::L => if shift { }
KeyCode::L => {
if shift {
'L' 'L'
} else { } else {
'l' 'l'
}, }
KeyCode::M => if shift { }
KeyCode::M => {
if shift {
'M' 'M'
} else { } else {
'm' 'm'
}, }
KeyCode::N => if shift { }
KeyCode::N => {
if shift {
'N' 'N'
} else { } else {
'n' 'n'
}, }
KeyCode::O => if shift { }
KeyCode::O => {
if shift {
'O' 'O'
} else { } else {
'o' 'o'
}, }
KeyCode::P => if shift { }
KeyCode::P => {
if shift {
'P' 'P'
} else { } else {
'p' 'p'
}, }
KeyCode::Q => if shift { }
KeyCode::Q => {
if shift {
'Q' 'Q'
} else { } else {
'q' 'q'
}, }
KeyCode::R => if shift { }
KeyCode::R => {
if shift {
'R' 'R'
} else { } else {
'r' 'r'
}, }
KeyCode::S => if shift { }
KeyCode::S => {
if shift {
'S' 'S'
} else { } else {
's' 's'
}, }
KeyCode::T => if shift { }
KeyCode::T => {
if shift {
'T' 'T'
} else { } else {
't' 't'
}, }
KeyCode::U => if shift { }
KeyCode::U => {
if shift {
'U' 'U'
} else { } else {
'u' 'u'
}, }
KeyCode::V => if shift { }
KeyCode::V => {
if shift {
'V' 'V'
} else { } else {
'v' 'v'
}, }
KeyCode::W => if shift { }
KeyCode::W => {
if shift {
'W' 'W'
} else { } else {
'w' 'w'
}, }
KeyCode::X => if shift { }
KeyCode::X => {
if shift {
'X' 'X'
} else { } else {
'x' 'x'
}, }
KeyCode::Y => if shift { }
KeyCode::Y => {
if shift {
'Y' 'Y'
} else { } else {
'y' 'y'
}, }
KeyCode::Z => if shift { }
KeyCode::Z => {
if shift {
'Z' 'Z'
} else { } else {
'z' 'z'
}, }
KeyCode::Row1 => if shift { }
KeyCode::Row1 => {
if shift {
'!' '!'
} else { } else {
'1' '1'
}, }
KeyCode::Row2 => if shift { }
KeyCode::Row2 => {
if shift {
'@' '@'
} else { } else {
'2' '2'
}, }
KeyCode::Row3 => if shift { }
KeyCode::Row3 => {
if shift {
'#' '#'
} else { } else {
'3' '3'
}, }
KeyCode::Row4 => if shift { }
KeyCode::Row4 => {
if shift {
'$' '$'
} else { } else {
'4' '4'
}, }
KeyCode::Row5 => if shift { }
KeyCode::Row5 => {
if shift {
'%' '%'
} else { } else {
'5' '5'
}, }
KeyCode::Row6 => if shift { }
KeyCode::Row6 => {
if shift {
'^' '^'
} else { } else {
'6' '6'
}, }
KeyCode::Row7 => if shift { }
KeyCode::Row7 => {
if shift {
'&' '&'
} else { } else {
'7' '7'
}, }
KeyCode::Row8 => if shift { }
KeyCode::Row8 => {
if shift {
'*' '*'
} else { } else {
'8' '8'
}, }
KeyCode::Row9 => if shift { }
KeyCode::Row9 => {
if shift {
'(' '('
} else { } else {
'9' '9'
}, }
KeyCode::Row0 => if shift { }
KeyCode::Row0 => {
if shift {
')' ')'
} else { } else {
'0' '0'
}, }
KeyCode::Grave => if shift { }
KeyCode::Grave => {
if shift {
'~' '~'
} else { } else {
'`' '`'
}, }
KeyCode::Minus => if shift { }
KeyCode::Minus => {
if shift {
'_' '_'
} else { } else {
'-' '-'
}, }
KeyCode::Equals => if shift { }
KeyCode::Equals => {
if shift {
'+' '+'
} else { } else {
'=' '='
}, }
KeyCode::LeftBracket => if shift { }
KeyCode::LeftBracket => {
if shift {
'{' '{'
} else { } else {
'[' '['
}, }
KeyCode::RightBracket => if shift { }
KeyCode::RightBracket => {
if shift {
'}' '}'
} else { } else {
']' ']'
}, }
KeyCode::Backslash => if shift { }
KeyCode::Backslash => {
if shift {
'|' '|'
} else { } else {
'\\' '\\'
}, }
KeyCode::Semicolon => if shift { }
KeyCode::Semicolon => {
if shift {
':' ':'
} else { } else {
';' ';'
}, }
KeyCode::Apostrophe => if shift { }
KeyCode::Apostrophe => {
if shift {
'"' '"'
} else { } else {
'\'' '\''
}, }
KeyCode::Comma => if shift { }
KeyCode::Comma => {
if shift {
'<' '<'
} else { } else {
',' ','
}, }
KeyCode::Period => if shift { }
KeyCode::Period => {
if shift {
'>' '>'
} else { } else {
'.' '.'
}, }
KeyCode::Slash => if shift { }
KeyCode::Slash => {
if shift {
'?' '?'
} else { } else {
'/' '/'
}, }
}
KeyCode::Space => ' ', KeyCode::Space => ' ',
KeyCode::NumDivide => '/', KeyCode::NumDivide => '/',
KeyCode::NumMultiply => '*', KeyCode::NumMultiply => '*',