use crate::prelude::KeyCode as WinitKeyCode;
use crate::tui::key_code::KeyCode;
pub fn from_winit(winit_key: WinitKeyCode, shift: bool) -> Option<KeyCode> {
match winit_key {
WinitKeyCode::KeyA => Some(KeyCode::Char(if shift { 'A' } else { 'a' })),
WinitKeyCode::KeyB => Some(KeyCode::Char(if shift { 'B' } else { 'b' })),
WinitKeyCode::KeyC => Some(KeyCode::Char(if shift { 'C' } else { 'c' })),
WinitKeyCode::KeyD => Some(KeyCode::Char(if shift { 'D' } else { 'd' })),
WinitKeyCode::KeyE => Some(KeyCode::Char(if shift { 'E' } else { 'e' })),
WinitKeyCode::KeyF => Some(KeyCode::Char(if shift { 'F' } else { 'f' })),
WinitKeyCode::KeyG => Some(KeyCode::Char(if shift { 'G' } else { 'g' })),
WinitKeyCode::KeyH => Some(KeyCode::Char(if shift { 'H' } else { 'h' })),
WinitKeyCode::KeyI => Some(KeyCode::Char(if shift { 'I' } else { 'i' })),
WinitKeyCode::KeyJ => Some(KeyCode::Char(if shift { 'J' } else { 'j' })),
WinitKeyCode::KeyK => Some(KeyCode::Char(if shift { 'K' } else { 'k' })),
WinitKeyCode::KeyL => Some(KeyCode::Char(if shift { 'L' } else { 'l' })),
WinitKeyCode::KeyM => Some(KeyCode::Char(if shift { 'M' } else { 'm' })),
WinitKeyCode::KeyN => Some(KeyCode::Char(if shift { 'N' } else { 'n' })),
WinitKeyCode::KeyO => Some(KeyCode::Char(if shift { 'O' } else { 'o' })),
WinitKeyCode::KeyP => Some(KeyCode::Char(if shift { 'P' } else { 'p' })),
WinitKeyCode::KeyQ => Some(KeyCode::Char(if shift { 'Q' } else { 'q' })),
WinitKeyCode::KeyR => Some(KeyCode::Char(if shift { 'R' } else { 'r' })),
WinitKeyCode::KeyS => Some(KeyCode::Char(if shift { 'S' } else { 's' })),
WinitKeyCode::KeyT => Some(KeyCode::Char(if shift { 'T' } else { 't' })),
WinitKeyCode::KeyU => Some(KeyCode::Char(if shift { 'U' } else { 'u' })),
WinitKeyCode::KeyV => Some(KeyCode::Char(if shift { 'V' } else { 'v' })),
WinitKeyCode::KeyW => Some(KeyCode::Char(if shift { 'W' } else { 'w' })),
WinitKeyCode::KeyX => Some(KeyCode::Char(if shift { 'X' } else { 'x' })),
WinitKeyCode::KeyY => Some(KeyCode::Char(if shift { 'Y' } else { 'y' })),
WinitKeyCode::KeyZ => Some(KeyCode::Char(if shift { 'Z' } else { 'z' })),
WinitKeyCode::Digit0 => Some(KeyCode::Char(if shift { ')' } else { '0' })),
WinitKeyCode::Digit1 => Some(KeyCode::Char(if shift { '!' } else { '1' })),
WinitKeyCode::Digit2 => Some(KeyCode::Char(if shift { '@' } else { '2' })),
WinitKeyCode::Digit3 => Some(KeyCode::Char(if shift { '#' } else { '3' })),
WinitKeyCode::Digit4 => Some(KeyCode::Char(if shift { '$' } else { '4' })),
WinitKeyCode::Digit5 => Some(KeyCode::Char(if shift { '%' } else { '5' })),
WinitKeyCode::Digit6 => Some(KeyCode::Char(if shift { '^' } else { '6' })),
WinitKeyCode::Digit7 => Some(KeyCode::Char(if shift { '&' } else { '7' })),
WinitKeyCode::Digit8 => Some(KeyCode::Char(if shift { '*' } else { '8' })),
WinitKeyCode::Digit9 => Some(KeyCode::Char(if shift { '(' } else { '9' })),
WinitKeyCode::Space => Some(KeyCode::Char(' ')),
WinitKeyCode::ArrowUp => Some(KeyCode::Up),
WinitKeyCode::ArrowDown => Some(KeyCode::Down),
WinitKeyCode::ArrowLeft => Some(KeyCode::Left),
WinitKeyCode::ArrowRight => Some(KeyCode::Right),
WinitKeyCode::Enter => Some(KeyCode::Enter),
WinitKeyCode::Escape => Some(KeyCode::Escape),
WinitKeyCode::Backspace => Some(KeyCode::Backspace),
WinitKeyCode::Tab => Some(if shift {
KeyCode::BackTab
} else {
KeyCode::Tab
}),
WinitKeyCode::Home => Some(KeyCode::Home),
WinitKeyCode::End => Some(KeyCode::End),
WinitKeyCode::PageUp => Some(KeyCode::PageUp),
WinitKeyCode::PageDown => Some(KeyCode::PageDown),
WinitKeyCode::Insert => Some(KeyCode::Insert),
WinitKeyCode::Delete => Some(KeyCode::Delete),
WinitKeyCode::F1 => Some(KeyCode::F(1)),
WinitKeyCode::F2 => Some(KeyCode::F(2)),
WinitKeyCode::F3 => Some(KeyCode::F(3)),
WinitKeyCode::F4 => Some(KeyCode::F(4)),
WinitKeyCode::F5 => Some(KeyCode::F(5)),
WinitKeyCode::F6 => Some(KeyCode::F(6)),
WinitKeyCode::F7 => Some(KeyCode::F(7)),
WinitKeyCode::F8 => Some(KeyCode::F(8)),
WinitKeyCode::F9 => Some(KeyCode::F(9)),
WinitKeyCode::F10 => Some(KeyCode::F(10)),
WinitKeyCode::F11 => Some(KeyCode::F(11)),
WinitKeyCode::F12 => Some(KeyCode::F(12)),
WinitKeyCode::Minus => Some(KeyCode::Char(if shift { '_' } else { '-' })),
WinitKeyCode::Equal => Some(KeyCode::Char(if shift { '+' } else { '=' })),
WinitKeyCode::BracketLeft => Some(KeyCode::Char(if shift { '{' } else { '[' })),
WinitKeyCode::BracketRight => Some(KeyCode::Char(if shift { '}' } else { ']' })),
WinitKeyCode::Backslash => Some(KeyCode::Char(if shift { '|' } else { '\\' })),
WinitKeyCode::Semicolon => Some(KeyCode::Char(if shift { ':' } else { ';' })),
WinitKeyCode::Quote => Some(KeyCode::Char(if shift { '"' } else { '\'' })),
WinitKeyCode::Backquote => Some(KeyCode::Char(if shift { '~' } else { '`' })),
WinitKeyCode::Comma => Some(KeyCode::Char(if shift { '<' } else { ',' })),
WinitKeyCode::Period => Some(KeyCode::Char(if shift { '>' } else { '.' })),
WinitKeyCode::Slash => Some(KeyCode::Char(if shift { '?' } else { '/' })),
_ => None,
}
}