diff --git a/Cargo.toml b/Cargo.toml index 7f311d6..f420b20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ version = "1.0" [dependencies.bear-lib-terminal] optional = true -version = "1.3" +version = "1.4" [dependencies.ncurses] features = ["wide"] diff --git a/src/backend/blt.rs b/src/backend/blt.rs index 7c4e3d6..ded8b51 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -107,11 +107,13 @@ impl Backend { position: self.mouse_position, offset: Vec2::zero(), } - }).unwrap_or(Event::Unknown(vec![])) + }) + .unwrap_or(Event::Unknown(vec![])) } BltEvent::ShiftReleased | BltEvent::ControlReleased => { Event::Refresh } + _ => Event::Unknown(vec![]), } }) } @@ -166,7 +168,8 @@ impl Backend { position: self.mouse_position, offset: Vec2::zero(), } - }).unwrap_or(Event::Unknown(vec![])), + }) + .unwrap_or(Event::Unknown(vec![])), KeyCode::A | KeyCode::B | KeyCode::C @@ -229,11 +232,13 @@ impl Backend { | KeyCode::Num7 | KeyCode::Num8 | KeyCode::Num9 - | KeyCode::Num0 => if ctrl { - Event::CtrlChar(blt_keycode_to_char(kc, shift)) - } else { - Event::Char(blt_keycode_to_char(kc, shift)) - }, + | KeyCode::Num0 => { + if ctrl { + Event::CtrlChar(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 { match kc { - KeyCode::A => if shift { - 'A' - } else { - 'a' - }, - KeyCode::B => if shift { - 'B' - } else { - 'b' - }, - KeyCode::C => if shift { - 'C' - } else { - 'c' - }, - KeyCode::D => if shift { - 'D' - } else { - 'd' - }, - KeyCode::E => if shift { - 'E' - } else { - 'e' - }, - KeyCode::F => if shift { - 'F' - } else { - 'f' - }, - KeyCode::G => if shift { - 'G' - } else { - 'g' - }, - KeyCode::H => if shift { - 'H' - } else { - 'h' - }, - KeyCode::I => if shift { - 'I' - } else { - 'i' - }, - KeyCode::J => if shift { - 'J' - } else { - 'j' - }, - KeyCode::K => if shift { - 'K' - } else { - 'k' - }, - KeyCode::L => if shift { - 'L' - } else { - 'l' - }, - KeyCode::M => if shift { - 'M' - } else { - 'm' - }, - KeyCode::N => if shift { - 'N' - } else { - 'n' - }, - KeyCode::O => if shift { - 'O' - } else { - 'o' - }, - KeyCode::P => if shift { - 'P' - } else { - 'p' - }, - KeyCode::Q => if shift { - 'Q' - } else { - 'q' - }, - KeyCode::R => if shift { - 'R' - } else { - 'r' - }, - KeyCode::S => if shift { - 'S' - } else { - 's' - }, - KeyCode::T => if shift { - 'T' - } else { - 't' - }, - KeyCode::U => if shift { - 'U' - } else { - 'u' - }, - KeyCode::V => if shift { - 'V' - } else { - 'v' - }, - KeyCode::W => if shift { - 'W' - } else { - 'w' - }, - KeyCode::X => if shift { - 'X' - } else { - 'x' - }, - KeyCode::Y => if shift { - 'Y' - } else { - 'y' - }, - KeyCode::Z => if shift { - 'Z' - } else { - 'z' - }, - KeyCode::Row1 => if shift { - '!' - } else { - '1' - }, - KeyCode::Row2 => if shift { - '@' - } else { - '2' - }, - KeyCode::Row3 => if shift { - '#' - } else { - '3' - }, - KeyCode::Row4 => if shift { - '$' - } else { - '4' - }, - KeyCode::Row5 => if shift { - '%' - } else { - '5' - }, - KeyCode::Row6 => if shift { - '^' - } else { - '6' - }, - KeyCode::Row7 => if shift { - '&' - } else { - '7' - }, - KeyCode::Row8 => 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::A => { + if shift { + 'A' + } else { + 'a' + } + } + KeyCode::B => { + if shift { + 'B' + } else { + 'b' + } + } + KeyCode::C => { + if shift { + 'C' + } else { + 'c' + } + } + KeyCode::D => { + if shift { + 'D' + } else { + 'd' + } + } + KeyCode::E => { + if shift { + 'E' + } else { + 'e' + } + } + KeyCode::F => { + if shift { + 'F' + } else { + 'f' + } + } + KeyCode::G => { + if shift { + 'G' + } else { + 'g' + } + } + KeyCode::H => { + if shift { + 'H' + } else { + 'h' + } + } + KeyCode::I => { + if shift { + 'I' + } else { + 'i' + } + } + KeyCode::J => { + if shift { + 'J' + } else { + 'j' + } + } + KeyCode::K => { + if shift { + 'K' + } else { + 'k' + } + } + KeyCode::L => { + if shift { + 'L' + } else { + 'l' + } + } + KeyCode::M => { + if shift { + 'M' + } else { + 'm' + } + } + KeyCode::N => { + if shift { + 'N' + } else { + 'n' + } + } + KeyCode::O => { + if shift { + 'O' + } else { + 'o' + } + } + KeyCode::P => { + if shift { + 'P' + } else { + 'p' + } + } + KeyCode::Q => { + if shift { + 'Q' + } else { + 'q' + } + } + KeyCode::R => { + if shift { + 'R' + } else { + 'r' + } + } + KeyCode::S => { + if shift { + 'S' + } else { + 's' + } + } + KeyCode::T => { + if shift { + 'T' + } else { + 't' + } + } + KeyCode::U => { + if shift { + 'U' + } else { + 'u' + } + } + KeyCode::V => { + if shift { + 'V' + } else { + 'v' + } + } + KeyCode::W => { + if shift { + 'W' + } else { + 'w' + } + } + KeyCode::X => { + if shift { + 'X' + } else { + 'x' + } + } + KeyCode::Y => { + if shift { + 'Y' + } else { + 'y' + } + } + KeyCode::Z => { + if shift { + 'Z' + } else { + 'z' + } + } + KeyCode::Row1 => { + if shift { + '!' + } else { + '1' + } + } + KeyCode::Row2 => { + if shift { + '@' + } else { + '2' + } + } + KeyCode::Row3 => { + if shift { + '#' + } else { + '3' + } + } + KeyCode::Row4 => { + if shift { + '$' + } else { + '4' + } + } + KeyCode::Row5 => { + if shift { + '%' + } else { + '5' + } + } + KeyCode::Row6 => { + if shift { + '^' + } else { + '6' + } + } + KeyCode::Row7 => { + if shift { + '&' + } else { + '7' + } + } + KeyCode::Row8 => { + 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::NumDivide => '/', KeyCode::NumMultiply => '*',