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 => {
Event::CtrlChar(blt_keycode_to_char(kc, shift)) if ctrl {
} else { Event::CtrlChar(blt_keycode_to_char(kc, shift))
Event::Char(blt_keycode_to_char(kc, shift)) } else {
}, 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 => {
'A' if shift {
} else { 'A'
'a' } else {
}, 'a'
KeyCode::B => if shift { }
'B' }
} else { KeyCode::B => {
'b' if shift {
}, 'B'
KeyCode::C => if shift { } else {
'C' 'b'
} else { }
'c' }
}, KeyCode::C => {
KeyCode::D => if shift { if shift {
'D' 'C'
} else { } else {
'd' 'c'
}, }
KeyCode::E => if shift { }
'E' KeyCode::D => {
} else { if shift {
'e' 'D'
}, } else {
KeyCode::F => if shift { 'd'
'F' }
} else { }
'f' KeyCode::E => {
}, if shift {
KeyCode::G => if shift { 'E'
'G' } else {
} else { 'e'
'g' }
}, }
KeyCode::H => if shift { KeyCode::F => {
'H' if shift {
} else { 'F'
'h' } else {
}, 'f'
KeyCode::I => if shift { }
'I' }
} else { KeyCode::G => {
'i' if shift {
}, 'G'
KeyCode::J => if shift { } else {
'J' 'g'
} else { }
'j' }
}, KeyCode::H => {
KeyCode::K => if shift { if shift {
'K' 'H'
} else { } else {
'k' 'h'
}, }
KeyCode::L => if shift { }
'L' KeyCode::I => {
} else { if shift {
'l' 'I'
}, } else {
KeyCode::M => if shift { 'i'
'M' }
} else { }
'm' KeyCode::J => {
}, if shift {
KeyCode::N => if shift { 'J'
'N' } else {
} else { 'j'
'n' }
}, }
KeyCode::O => if shift { KeyCode::K => {
'O' if shift {
} else { 'K'
'o' } else {
}, 'k'
KeyCode::P => if shift { }
'P' }
} else { KeyCode::L => {
'p' if shift {
}, 'L'
KeyCode::Q => if shift { } else {
'Q' 'l'
} else { }
'q' }
}, KeyCode::M => {
KeyCode::R => if shift { if shift {
'R' 'M'
} else { } else {
'r' 'm'
}, }
KeyCode::S => if shift { }
'S' KeyCode::N => {
} else { if shift {
's' 'N'
}, } else {
KeyCode::T => if shift { 'n'
'T' }
} else { }
't' KeyCode::O => {
}, if shift {
KeyCode::U => if shift { 'O'
'U' } else {
} else { 'o'
'u' }
}, }
KeyCode::V => if shift { KeyCode::P => {
'V' if shift {
} else { 'P'
'v' } else {
}, 'p'
KeyCode::W => if shift { }
'W' }
} else { KeyCode::Q => {
'w' if shift {
}, 'Q'
KeyCode::X => if shift { } else {
'X' 'q'
} else { }
'x' }
}, KeyCode::R => {
KeyCode::Y => if shift { if shift {
'Y' 'R'
} else { } else {
'y' 'r'
}, }
KeyCode::Z => if shift { }
'Z' KeyCode::S => {
} else { if shift {
'z' 'S'
}, } else {
KeyCode::Row1 => if shift { 's'
'!' }
} else { }
'1' KeyCode::T => {
}, if shift {
KeyCode::Row2 => if shift { 'T'
'@' } else {
} else { 't'
'2' }
}, }
KeyCode::Row3 => if shift { KeyCode::U => {
'#' if shift {
} else { 'U'
'3' } else {
}, 'u'
KeyCode::Row4 => if shift { }
'$' }
} else { KeyCode::V => {
'4' if shift {
}, 'V'
KeyCode::Row5 => if shift { } else {
'%' 'v'
} else { }
'5' }
}, KeyCode::W => {
KeyCode::Row6 => if shift { if shift {
'^' 'W'
} else { } else {
'6' 'w'
}, }
KeyCode::Row7 => if shift { }
'&' KeyCode::X => {
} else { if shift {
'7' 'X'
}, } else {
KeyCode::Row8 => if shift { 'x'
'*' }
} else { }
'8' KeyCode::Y => {
}, if shift {
KeyCode::Row9 => if shift { 'Y'
'(' } else {
} else { 'y'
'9' }
}, }
KeyCode::Row0 => if shift { KeyCode::Z => {
')' if shift {
} else { 'Z'
'0' } else {
}, 'z'
KeyCode::Grave => if shift { }
'~' }
} else { KeyCode::Row1 => {
'`' if shift {
}, '!'
KeyCode::Minus => if shift { } else {
'_' '1'
} else { }
'-' }
}, KeyCode::Row2 => {
KeyCode::Equals => if shift { if shift {
'+' '@'
} else { } else {
'=' '2'
}, }
KeyCode::LeftBracket => if shift { }
'{' KeyCode::Row3 => {
} else { if shift {
'[' '#'
}, } else {
KeyCode::RightBracket => if shift { '3'
'}' }
} else { }
']' KeyCode::Row4 => {
}, if shift {
KeyCode::Backslash => if shift { '$'
'|' } else {
} else { '4'
'\\' }
}, }
KeyCode::Semicolon => if shift { KeyCode::Row5 => {
':' if shift {
} else { '%'
';' } else {
}, '5'
KeyCode::Apostrophe => if shift { }
'"' }
} else { KeyCode::Row6 => {
'\'' if shift {
}, '^'
KeyCode::Comma => if shift { } else {
'<' '6'
} else { }
',' }
}, KeyCode::Row7 => {
KeyCode::Period => if shift { if shift {
'>' '&'
} else { } else {
'.' '7'
}, }
KeyCode::Slash => if shift { }
'?' KeyCode::Row8 => {
} else { if shift {
'/' '*'
}, } else {
'8'
}
}
KeyCode::Row9 => {
if shift {
'('
} else {
'9'
}
}
KeyCode::Row0 => {
if shift {
')'
} else {
'0'
}
}
KeyCode::Grave => {
if shift {
'~'
} else {
'`'
}
}
KeyCode::Minus => {
if shift {
'_'
} else {
'-'
}
}
KeyCode::Equals => {
if shift {
'+'
} else {
'='
}
}
KeyCode::LeftBracket => {
if shift {
'{'
} else {
'['
}
}
KeyCode::RightBracket => {
if shift {
'}'
} else {
']'
}
}
KeyCode::Backslash => {
if shift {
'|'
} else {
'\\'
}
}
KeyCode::Semicolon => {
if shift {
':'
} else {
';'
}
}
KeyCode::Apostrophe => {
if shift {
'"'
} else {
'\''
}
}
KeyCode::Comma => {
if shift {
'<'
} else {
','
}
}
KeyCode::Period => {
if shift {
'>'
} else {
'.'
}
}
KeyCode::Slash => {
if shift {
'?'
} else {
'/'
}
}
KeyCode::Space => ' ', KeyCode::Space => ' ',
KeyCode::NumDivide => '/', KeyCode::NumDivide => '/',
KeyCode::NumMultiply => '*', KeyCode::NumMultiply => '*',