diff --git a/examples/menu.rs b/examples/menu.rs index 8960c9c..d8de747 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -1,7 +1,7 @@ extern crate minifb; -use minifb::{InputCallback, Window, Key, Scale, WindowOptions, Menu}; -use minifb::{MENU_KEY_CTRL}; +use minifb::MENU_KEY_CTRL; +use minifb::{InputCallback, Key, Menu, Scale, Window, WindowOptions}; const WIDTH: usize = 640; const HEIGHT: usize = 360; @@ -24,31 +24,45 @@ impl InputCallback for KeyCharCallback { fn main() { let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; - let mut window = Window::new("Menu Test - Press ESC to exit", - WIDTH, - HEIGHT, - WindowOptions { - resize: true, - scale: Scale::X2, - ..WindowOptions::default() - }) - .expect("Unable to Open Window"); + let mut window = Window::new( + "Menu Test - Press ESC to exit", + WIDTH, + HEIGHT, + WindowOptions { + resize: true, + scale: Scale::X2, + ..WindowOptions::default() + }, + ) + .expect("Unable to Open Window"); window.set_input_callback(Box::new(KeyCharCallback {})); let mut menu = Menu::new("Test").unwrap(); let mut sub = Menu::new("Select Color").unwrap(); - sub.add_item("Color 0", COLOR_0_ID).shortcut(Key::F1, 0).build(); - sub.add_item("Color 1", COLOR_1_ID).shortcut(Key::F2, 0).build(); - sub.add_item("Color 2", COLOR_2_ID).shortcut(Key::F7, 0).build(); + sub.add_item("Color 0", COLOR_0_ID) + .shortcut(Key::F1, 0) + .build(); + sub.add_item("Color 1", COLOR_1_ID) + .shortcut(Key::F2, 0) + .build(); + sub.add_item("Color 2", COLOR_2_ID) + .shortcut(Key::F7, 0) + .build(); - menu.add_item("Menu Test", MENU_TEST_ID).shortcut(Key::W, MENU_KEY_CTRL).build(); + menu.add_item("Menu Test", MENU_TEST_ID) + .shortcut(Key::W, MENU_KEY_CTRL) + .build(); menu.add_separator(); - menu.add_item("Other Menu", OTHER_MENU_ID).shortcut(Key::W, MENU_KEY_CTRL).build(); - menu.add_item("Remove Menu", CLOSE_MENU_ID).shortcut(Key::R, 0).build(); + menu.add_item("Other Menu", OTHER_MENU_ID) + .shortcut(Key::W, MENU_KEY_CTRL) + .build(); + menu.add_item("Remove Menu", CLOSE_MENU_ID) + .shortcut(Key::R, 0) + .build(); menu.add_sub_menu("Sub Test", &sub); diff --git a/examples/mouse.rs b/examples/mouse.rs index 1f675f7..e895700 100644 --- a/examples/mouse.rs +++ b/examples/mouse.rs @@ -1,6 +1,6 @@ extern crate minifb; -use minifb::{MouseButton, MouseMode, Window, Key, Scale, WindowOptions}; +use minifb::{Key, MouseButton, MouseMode, Scale, Window, WindowOptions}; const WIDTH: usize = 640; const HEIGHT: usize = 360; @@ -8,12 +8,16 @@ const HEIGHT: usize = 360; fn main() { let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; - let mut window = match Window::new("Mouse Draw - Press ESC to exit", WIDTH, HEIGHT, - WindowOptions { - resize: true, - scale: Scale::X2, - ..WindowOptions::default() - }) { + let mut window = match Window::new( + "Mouse Draw - Press ESC to exit", + WIDTH, + HEIGHT, + WindowOptions { + resize: true, + scale: Scale::X2, + ..WindowOptions::default() + }, + ) { Ok(win) => win, Err(err) => { println!("Unable to create window {}", err); @@ -27,7 +31,6 @@ fn main() { { let (new_width, new_height) = window.get_size(); if new_width != width || new_height != height { - // copy valid bits of old buffer to new buffer let mut new_buffer = vec![0; new_width * new_height / 2 / 2]; for y in 0..(height / 2).min(new_height / 2) { @@ -38,13 +41,15 @@ fn main() { buffer = new_buffer; width = new_width; height = new_height; - } } window.get_mouse_pos(MouseMode::Discard).map(|(x, y)| { let screen_pos = ((y as usize) * width / 2) + x as usize; - println!("{:?}", window.get_unscaled_mouse_pos(MouseMode::Discard).unwrap()); + println!( + "{:?}", + window.get_unscaled_mouse_pos(MouseMode::Discard).unwrap() + ); if window.get_mouse_down(MouseButton::Left) { buffer[screen_pos] = 0x00ffffff; diff --git a/examples/multi.rs b/examples/multi.rs index 5eb67dd..bc0b723 100644 --- a/examples/multi.rs +++ b/examples/multi.rs @@ -1,26 +1,39 @@ extern crate minifb; -use minifb::{WindowOptions, Window, Scale, Key}; +use minifb::{Key, Scale, Window, WindowOptions}; fn main() { let width = 640; let height = 320; let mut buffer = vec![0u32; width * height]; - let mut double = Window::new("Larger", width, height, WindowOptions { - scale: Scale::X2, - ..WindowOptions::default() - }).unwrap(); - - let mut orig = Window::new("Smaller", width, height, WindowOptions { - ..WindowOptions::default() - }).unwrap(); + let mut double = Window::new( + "Larger", + width, + height, + WindowOptions { + scale: Scale::X2, + ..WindowOptions::default() + }, + ) + .unwrap(); + let mut orig = Window::new( + "Smaller", + width, + height, + WindowOptions { + ..WindowOptions::default() + }, + ) + .unwrap(); let mut pos = 13; - while orig.is_open() && double.is_open() + while orig.is_open() + && double.is_open() && !orig.is_key_down(Key::Escape) - && !double.is_key_down(Key::Escape) { + && !double.is_key_down(Key::Escape) + { orig.update_with_buffer(&buffer).unwrap(); double.update_with_buffer(&buffer).unwrap(); pos += 7; diff --git a/examples/noise.rs b/examples/noise.rs index 7ac4dbf..de1e8a3 100644 --- a/examples/noise.rs +++ b/examples/noise.rs @@ -1,6 +1,6 @@ extern crate minifb; -use minifb::{Window, Key, Scale, WindowOptions}; +use minifb::{Key, Scale, Window, WindowOptions}; const WIDTH: usize = 640; const HEIGHT: usize = 360; @@ -10,13 +10,16 @@ fn main() { let mut carry; let mut seed = 0xbeefu32; - - let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, - WindowOptions { - resize: true, - scale: Scale::X2, - ..WindowOptions::default() - }) { + let mut window = match Window::new( + "Noise Test - Press ESC to exit", + WIDTH, + HEIGHT, + WindowOptions { + resize: true, + scale: Scale::X2, + ..WindowOptions::default() + }, + ) { Ok(win) => win, Err(err) => { println!("Unable to create window {}", err); diff --git a/examples/title_cursor.rs b/examples/title_cursor.rs index b3e7070..7dd90a9 100644 --- a/examples/title_cursor.rs +++ b/examples/title_cursor.rs @@ -1,6 +1,6 @@ extern crate minifb; -use minifb::{CursorStyle, Window, Key, Scale, WindowOptions, MouseMode}; +use minifb::{CursorStyle, Key, MouseMode, Scale, Window, WindowOptions}; const WIDTH: usize = 640; const HEIGHT: usize = 360; @@ -21,8 +21,7 @@ impl Rect { let xe = self.x + self.width; let ye = self.y + self.height; - if (y >= self.y) && (y <= ye) && - (x >= self.x) && (x <= xe) { + if (y >= self.y) && (y <= ye) && (x >= self.x) && (x <= xe) { true } else { false @@ -41,23 +40,81 @@ fn fill_rect(dest: &mut [u32], rect: &Rect) { fn main() { let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; - let mut window = Window::new("I haz no title :(", - WIDTH, - HEIGHT, - WindowOptions { - scale: Scale::X2, - ..WindowOptions::default() - }) - .expect("Unable to Open Window"); + let mut window = Window::new( + "I haz no title :(", + WIDTH, + HEIGHT, + WindowOptions { + scale: Scale::X2, + ..WindowOptions::default() + }, + ) + .expect("Unable to Open Window"); let rects = [ - Rect { x: 0, y: 0, width: 160, height: 180, color: 0x00b27474, cursor_style: CursorStyle::Arrow }, - Rect { x: 160, y: 0, width: 160, height: 180, color: 0x00b28050, cursor_style: CursorStyle::Ibeam }, - Rect { x: 320, y: 0, width: 160, height: 180, color: 0x00a9b250, cursor_style: CursorStyle::Crosshair }, - Rect { x: 480, y: 0, width: 160, height: 180, color: 0x0060b250, cursor_style: CursorStyle::ClosedHand }, - Rect { x: 0, y: 180, width: 160, height: 180, color: 0x004fb292, cursor_style: CursorStyle::OpenHand }, - Rect { x: 160, y: 180, width: 160, height: 180, color: 0x004f71b2, cursor_style: CursorStyle::ResizeLeftRight }, - Rect { x: 320, y: 180, width: 160, height: 180, color: 0x008850b2, cursor_style: CursorStyle::ResizeUpDown }, - Rect { x: 480, y: 180, width: 160, height: 180, color: 0x00b25091, cursor_style: CursorStyle::ResizeAll } + Rect { + x: 0, + y: 0, + width: 160, + height: 180, + color: 0x00b27474, + cursor_style: CursorStyle::Arrow, + }, + Rect { + x: 160, + y: 0, + width: 160, + height: 180, + color: 0x00b28050, + cursor_style: CursorStyle::Ibeam, + }, + Rect { + x: 320, + y: 0, + width: 160, + height: 180, + color: 0x00a9b250, + cursor_style: CursorStyle::Crosshair, + }, + Rect { + x: 480, + y: 0, + width: 160, + height: 180, + color: 0x0060b250, + cursor_style: CursorStyle::ClosedHand, + }, + Rect { + x: 0, + y: 180, + width: 160, + height: 180, + color: 0x004fb292, + cursor_style: CursorStyle::OpenHand, + }, + Rect { + x: 160, + y: 180, + width: 160, + height: 180, + color: 0x004f71b2, + cursor_style: CursorStyle::ResizeLeftRight, + }, + Rect { + x: 320, + y: 180, + width: 160, + height: 180, + color: 0x008850b2, + cursor_style: CursorStyle::ResizeUpDown, + }, + Rect { + x: 480, + y: 180, + width: 160, + height: 180, + color: 0x00b25091, + cursor_style: CursorStyle::ResizeAll, + }, ]; window.set_title("Different cursor on each color region"); @@ -76,4 +133,3 @@ fn main() { window.update_with_buffer(&buffer).unwrap(); } } - diff --git a/src/buffer_helper.rs b/src/buffer_helper.rs index 0bc5872..4ea4705 100644 --- a/src/buffer_helper.rs +++ b/src/buffer_helper.rs @@ -1,9 +1,14 @@ use error::Error; use Result; -pub fn check_buffer_size(window_width: usize, window_height: usize, scale: usize, buffer: &[u32]) -> Result<()> { +pub fn check_buffer_size( + window_width: usize, + window_height: usize, + scale: usize, + buffer: &[u32], +) -> Result<()> { let buffer_size = buffer.len() * 4; // len is the number of entries so * 4 as we want bytes - let required_buffer_size = (window_width / scale) * (window_height / scale) * 4; // * 4 for 32-bit buffer + let required_buffer_size = (window_width / scale) * (window_height / scale) * 4; // * 4 for 32-bit buffer if buffer_size < required_buffer_size { let err = format!("Update failed because input buffer is too small. Required size for {} x {} window ({}x scale) is {} bytes but the size of the input buffer has the size {} bytes", diff --git a/src/error.rs b/src/error.rs index d1170fc..eff231d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -38,18 +38,10 @@ impl StdError for Error { impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { - Error::MenusNotSupported => { - write!(fmt, "{}", self.description()) - }, - Error::MenuExists(ref e) => { - write!(fmt, "{} {:?}", self.description(), e) - }, - Error::WindowCreate(ref e) => { - write!(fmt, "{} {:?}", self.description(), e) - } - Error::UpdateFailed(ref e) => { - write!(fmt, "{} {:?}", self.description(), e) - } + Error::MenusNotSupported => write!(fmt, "{}", self.description()), + Error::MenuExists(ref e) => write!(fmt, "{} {:?}", self.description(), e), + Error::WindowCreate(ref e) => write!(fmt, "{} {:?}", self.description(), e), + Error::UpdateFailed(ref e) => write!(fmt, "{} {:?}", self.description(), e), } } } diff --git a/src/key.rs b/src/key.rs index b853078..6f8bc4e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -125,4 +125,3 @@ pub enum Key { Count = 107, } - diff --git a/src/key_handler.rs b/src/key_handler.rs index aa7690e..e2e8e92 100644 --- a/src/key_handler.rs +++ b/src/key_handler.rs @@ -1,7 +1,7 @@ extern crate time; use std::mem; -use {Key, KeyRepeat, InputCallback}; +use {InputCallback, Key, KeyRepeat}; pub struct KeyHandler { pub key_callback: Option>, @@ -118,7 +118,9 @@ impl KeyHandler { if repeat == KeyRepeat::Yes && t > self.key_repeat_delay { let delay = self.key_repeat_delay; let rate = self.key_repeat_rate; - if (((t - delay) % rate) > rate * 0.5) != (((t - delay - self.delta_time) % rate) > rate * 0.5) { + if (((t - delay) % rate) > rate * 0.5) + != (((t - delay - self.delta_time) % rate) > rate * 0.5) + { return true; } } diff --git a/src/lib.rs b/src/lib.rs index 95f31ad..bcd03ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,6 @@ pub enum MouseButton { Right, } - /// The diffrent modes that can be used to decide how mouse coordinates should be handled #[derive(PartialEq, Clone, Copy, Debug)] pub enum MouseMode { @@ -94,11 +93,11 @@ pub use self::error::Error; pub type Result = std::result::Result; mod key; -pub use key::Key as Key; -mod os; -mod mouse_handler; +pub use key::Key; mod buffer_helper; mod key_handler; +mod mouse_handler; +mod os; mod window_flags; //mod menu; //pub use menu::Menu as Menu; @@ -108,19 +107,20 @@ mod window_flags; //pub use menu::MENU_KEY_CTRL; //pub use menu::MENU_KEY_ALT; - #[cfg(target_os = "macos")] use self::os::macos as imp; -#[cfg(target_os = "windows")] -use self::os::windows as imp; -#[cfg(any(target_os="linux", - target_os="freebsd", - target_os="dragonfly", - target_os="netbsd", - target_os="openbsd"))] -use self::os::unix as imp; #[cfg(target_os = "redox")] use self::os::redox as imp; +#[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd" +))] +use self::os::unix as imp; +#[cfg(target_os = "windows")] +use self::os::windows as imp; /// /// Window is used to open up a window. It's possible to optionally display a 32-bit buffer when /// the widow is set as non-resizable. @@ -129,9 +129,7 @@ pub struct Window(imp::Window); impl fmt::Debug for Window { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("Window") - .field(&format_args!("..")) - .finish() + f.debug_tuple("Window").field(&format_args!("..")).finish() } } @@ -554,7 +552,7 @@ impl Window { /// Set input callback to recive callback on char input /// #[inline] - pub fn set_input_callback(&mut self, callback: Box) { + pub fn set_input_callback(&mut self, callback: Box) { self.0.set_input_callback(callback) } @@ -590,18 +588,19 @@ impl Window { /// Get Unix menu. Will only return menus on Unix class OSes /// otherwise ```None``` /// - #[cfg(any(target_os="macos", - target_os="windows"))] + #[cfg(any(target_os = "macos", target_os = "windows"))] pub fn get_unix_menus(&self) -> Option<&Vec> { None } - #[cfg(any(target_os="linux", - target_os="freebsd", - target_os="dragonfly", - target_os="netbsd", - target_os="openbsd", - target_os="redox"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox" + ))] pub fn get_unix_menus(&self) -> Option<&Vec> { self.0.get_unix_menus() } @@ -615,7 +614,6 @@ impl Window { } } - /// Command key on Mac OS pub const MENU_KEY_COMMAND: usize = 1; /// Windows key on Windows @@ -627,7 +625,7 @@ pub const MENU_KEY_CTRL: usize = 8; /// Alt key pub const MENU_KEY_ALT: usize = 16; -const MENU_ID_SEPARATOR:usize = 0xffffffff; +const MENU_ID_SEPARATOR: usize = 0xffffffff; /// /// Used on Unix (Linux, FreeBSD, etc) as menus aren't supported in a native where there. @@ -635,14 +633,14 @@ const MENU_ID_SEPARATOR:usize = 0xffffffff; /// #[derive(Debug, Clone)] pub struct UnixMenu { - /// Name of the menu - pub name: String, - /// All items of the menu. - pub items: Vec, + /// Name of the menu + pub name: String, + /// All items of the menu. + pub items: Vec, #[doc(hidden)] - pub handle: MenuHandle, + pub handle: MenuHandle, #[doc(hidden)] - pub item_counter: MenuItemHandle, + pub item_counter: MenuItemHandle, } /// @@ -652,10 +650,10 @@ pub struct UnixMenu { #[derive(Debug, Clone)] pub struct UnixMenuItem { /// Set to a menu if there is a Item is a sub_menu otherwise None - pub sub_menu: Option>, - /// Handle of the MenuItem - pub handle: MenuItemHandle, - /// Id of the item (set by the user from the outside and should be reported back when pressed) + pub sub_menu: Option>, + /// Handle of the MenuItem + pub handle: MenuItemHandle, + /// Id of the item (set by the user from the outside and should be reported back when pressed) pub id: usize, /// Name of the item pub label: String, @@ -675,7 +673,6 @@ pub struct MenuItemHandle(pub u64); #[doc(hidden)] pub struct MenuHandle(pub u64); - /// /// Menu holds info for menus /// @@ -683,9 +680,7 @@ pub struct Menu(imp::Menu); impl fmt::Debug for Menu { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("Menu") - .field(&format_args!("..")) - .finish() + f.debug_tuple("Menu").field(&format_args!("..")).finish() } } @@ -709,7 +704,10 @@ impl Menu { /// Adds a menu separator pub fn add_separator(&mut self) { - self.add_menu_item(&MenuItem { id: MENU_ID_SEPARATOR, ..MenuItem::default() }); + self.add_menu_item(&MenuItem { + id: MENU_ID_SEPARATOR, + ..MenuItem::default() + }); } #[inline] @@ -808,7 +806,7 @@ impl<'a> MenuItem<'a> { MenuItem { key: key, modifier: modifier, - .. self + ..self } } #[inline] @@ -826,7 +824,7 @@ impl<'a> MenuItem<'a> { pub fn separator(self) -> Self { MenuItem { id: MENU_ID_SEPARATOR, - .. self + ..self } } #[inline] @@ -843,7 +841,7 @@ impl<'a> MenuItem<'a> { pub fn enabled(self, enabled: bool) -> Self { MenuItem { enabled: enabled, - .. self + ..self } } #[inline] diff --git a/src/mouse_handler.rs b/src/mouse_handler.rs index 23ec886..35ba55a 100644 --- a/src/mouse_handler.rs +++ b/src/mouse_handler.rs @@ -4,7 +4,14 @@ fn clamp(v: f32, lb: f32, ub: f32) -> f32 { f32::min(f32::max(v, lb), ub) } -pub fn get_pos(mode: MouseMode, mx: f32, my: f32, scale: f32, width: f32, height: f32) -> Option<(f32, f32)> { +pub fn get_pos( + mode: MouseMode, + mx: f32, + my: f32, + scale: f32, + width: f32, + height: f32, +) -> Option<(f32, f32)> { let s = 1.0 / scale as f32; let x = mx * s; let y = my * s; @@ -13,17 +20,16 @@ pub fn get_pos(mode: MouseMode, mx: f32, my: f32, scale: f32, width: f32, height match mode { MouseMode::Pass => Some((x, y)), - MouseMode::Clamp => { - Some((clamp(x, 0.0, window_width - 1.0), - clamp(y, 0.0, window_height - 1.0))) - }, + MouseMode::Clamp => Some(( + clamp(x, 0.0, window_width - 1.0), + clamp(y, 0.0, window_height - 1.0), + )), MouseMode::Discard => { if x < 0.0 || y < 0.0 || x >= window_width || y >= window_height { None } else { Some((x, y)) } - }, + } } } - diff --git a/src/os/macos/mod.rs b/src/os/macos/mod.rs index 6b6d1c4..0f8460c 100644 --- a/src/os/macos/mod.rs +++ b/src/os/macos/mod.rs @@ -1,22 +1,22 @@ #![cfg(target_os = "macos")] -use {MouseButton, MouseMode, Scale, Key, KeyRepeat, WindowOptions}; -use key_handler::KeyHandler; use error::Error; +use key_handler::KeyHandler; use Result; +use {Key, KeyRepeat, MouseButton, MouseMode, Scale, WindowOptions}; // use MenuItem; -use InputCallback; -use mouse_handler; use buffer_helper; +use mouse_handler; use window_flags; -use {CursorStyle, MenuItem, MenuItemHandle, MenuHandle}; +use InputCallback; +use {CursorStyle, MenuHandle, MenuItem, MenuItemHandle}; // use menu::Menu; -use std::os::raw::{c_void, c_char, c_uchar}; use std::ffi::CString; -use std::ptr; use std::mem; use std::os::raw; +use std::os::raw::{c_char, c_uchar, c_void}; +use std::ptr; // Table taken from GLFW and slightly modified @@ -71,7 +71,7 @@ static KEY_MAPPINGS: [Key; 128] = [ /* 2f */ Key::Period, /* 30 */ Key::Tab, /* 31 */ Key::Space, - /* 32 */ Key::Unknown, // World1 + /* 32 */ Key::Unknown, // World1 /* 33 */ Key::Backspace, /* 34 */ Key::Unknown, /* 35 */ Key::Escape, @@ -154,21 +154,24 @@ static KEY_MAPPINGS: [Key; 128] = [ #[link(name = "Cocoa", kind = "framework")] #[link(name = "Carbon", kind = "framework")] extern "C" { - fn mfb_open(name: *const c_char, - width: u32, - height: u32, - flags: u32, - scale: i32) - -> *mut c_void; + fn mfb_open( + name: *const c_char, + width: u32, + height: u32, + flags: u32, + scale: i32, + ) -> *mut c_void; fn mfb_set_title(window: *mut c_void, title: *const c_char); fn mfb_close(window: *mut c_void); fn mfb_update(window: *mut c_void); fn mfb_update_with_buffer(window: *mut c_void, buffer: *const c_uchar); fn mfb_set_position(window: *mut c_void, x: i32, y: i32); - fn mfb_set_key_callback(window: *mut c_void, - target: *mut c_void, - cb: unsafe extern "C" fn(*mut c_void, i32, i32), - cb: unsafe extern "C" fn(*mut c_void, u32)); + fn mfb_set_key_callback( + window: *mut c_void, + target: *mut c_void, + cb: unsafe extern "C" fn(*mut c_void, i32, i32), + cb: unsafe extern "C" fn(*mut c_void, u32), + ); fn mfb_set_mouse_data(window_handle: *mut c_void, shared_data: *mut SharedData); fn mfb_set_cursor_style(window: *mut c_void, cursor: u32); fn mfb_should_close(window: *mut c_void) -> i32; @@ -181,13 +184,14 @@ extern "C" { fn mfb_create_menu(name: *const c_char) -> *mut c_void; fn mfb_remove_menu_at(window: *mut c_void, index: i32); - fn mfb_add_menu_item(menu_item: *mut c_void, - menu_id: i32, - name: *const c_char, - enabled: bool, - key: u32, - modifier: u32) - -> u64; + fn mfb_add_menu_item( + menu_item: *mut c_void, + menu_id: i32, + name: *const c_char, + enabled: bool, + key: u32, + modifier: u32, + ) -> u64; fn mfb_remove_menu_item(menu: *mut c_void, item_handle: u64); } @@ -220,7 +224,9 @@ unsafe extern "C" fn key_callback(window: *mut c_void, key: i32, state: i32) { if key > 128 { (*win).key_handler.set_key_state(Key::Unknown, s); } else { - (*win).key_handler.set_key_state(KEY_MAPPINGS[key as usize], s); + (*win) + .key_handler + .set_key_state(KEY_MAPPINGS[key as usize], s); } } @@ -249,11 +255,13 @@ impl Window { unsafe { let scale_factor = Self::get_scale_factor(width, height, opts.scale) as usize; - let handle = mfb_open(n.as_ptr(), - width as u32, - height as u32, - window_flags::get_flags(opts), - scale_factor as i32); + let handle = mfb_open( + n.as_ptr(), + width as u32, + height as u32, + window_flags::get_flags(opts), + scale_factor as i32, + ); if handle == ptr::null_mut() { return Err(Error::WindowCreate("Unable to open Window".to_owned())); @@ -295,10 +303,12 @@ impl Window { pub fn update_with_buffer(&mut self, buffer: &[u32]) -> Result<()> { self.key_handler.update(); - let check_res = buffer_helper::check_buffer_size(self.shared_data.width as usize, - self.shared_data.height as usize, - self.scale_factor as usize, - buffer); + let check_res = buffer_helper::check_buffer_size( + self.shared_data.width as usize, + self.shared_data.height as usize, + self.scale_factor as usize, + buffer, + ); if check_res.is_err() { return check_res; } @@ -306,10 +316,12 @@ impl Window { unsafe { mfb_update_with_buffer(self.window_handle, buffer.as_ptr() as *const u8); Self::set_mouse_data(self); - mfb_set_key_callback(self.window_handle, - mem::transmute(self), - key_callback, - char_callback); + mfb_set_key_callback( + self.window_handle, + mem::transmute(self), + key_callback, + char_callback, + ); } Ok(()) @@ -321,10 +333,12 @@ impl Window { unsafe { mfb_update(self.window_handle); Self::set_mouse_data(self); - mfb_set_key_callback(self.window_handle, - mem::transmute(self), - key_callback, - char_callback); + mfb_set_key_callback( + self.window_handle, + mem::transmute(self), + key_callback, + char_callback, + ); } } @@ -334,8 +348,10 @@ impl Window { } pub fn get_size(&self) -> (usize, usize) { - (self.shared_data.width as usize, - self.shared_data.height as usize) + ( + self.shared_data.width as usize, + self.shared_data.height as usize, + ) } pub fn get_scroll_wheel(&self) -> Option<(f32, f32)> { @@ -362,12 +378,14 @@ impl Window { let w = self.shared_data.width as f32; let h = self.shared_data.height as f32; - mouse_handler::get_pos(mode, - self.shared_data.mouse_x, - self.shared_data.mouse_y, - s, - w, - h) + mouse_handler::get_pos( + mode, + self.shared_data.mouse_x, + self.shared_data.mouse_y, + s, + w, + h, + ) } pub fn get_unscaled_mouse_pos(&self, mode: MouseMode) -> Option<(f32, f32)> { @@ -375,12 +393,14 @@ impl Window { let w = self.shared_data.width as f32; let h = self.shared_data.height as f32; - mouse_handler::get_pos(mode, - self.shared_data.mouse_x, - self.shared_data.mouse_y, - s, - w, - h) + mouse_handler::get_pos( + mode, + self.shared_data.mouse_x, + self.shared_data.mouse_y, + s, + w, + h, + ) } #[inline] @@ -513,7 +533,9 @@ impl Menu { pub fn new(name: &str) -> Result { unsafe { let menu_name = CString::new(name).unwrap(); - Ok(Menu { menu_handle: mfb_create_menu(menu_name.as_ptr()) }) + Ok(Menu { + menu_handle: mfb_create_menu(menu_name.as_ptr()), + }) } } @@ -640,12 +662,14 @@ impl Menu { let item_name = CString::new(item.label.as_str()).unwrap(); let conv_key = Self::map_key_to_menu_key(item.key); - MenuItemHandle(mfb_add_menu_item(self.menu_handle, - item.id as i32, - item_name.as_ptr(), - item.enabled, - conv_key, - item.modifier as u32)) + MenuItemHandle(mfb_add_menu_item( + self.menu_handle, + item.id as i32, + item_name.as_ptr(), + item.enabled, + conv_key, + item.modifier as u32, + )) } } @@ -663,4 +687,3 @@ impl Drop for Window { } } } - diff --git a/src/os/mod.rs b/src/os/mod.rs index a49520a..0fd7620 100644 --- a/src/os/mod.rs +++ b/src/os/mod.rs @@ -1,12 +1,14 @@ #[cfg(target_os = "macos")] pub mod macos; -#[cfg(target_os = "windows")] -pub mod windows; -#[cfg(any(target_os="linux", - target_os="freebsd", - target_os="dragonfly", - target_os="netbsd", - target_os="openbsd"))] -pub mod unix; #[cfg(target_os = "redox")] pub mod redox; +#[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd" +))] +pub mod unix; +#[cfg(target_os = "windows")] +pub mod windows; diff --git a/src/os/redox/mod.rs b/src/os/redox/mod.rs index 88b2c58..64ac023 100644 --- a/src/os/redox/mod.rs +++ b/src/os/redox/mod.rs @@ -3,16 +3,16 @@ extern crate orbclient; use os::redox::orbclient::Renderer; -use error::Error; -use Result; -use mouse_handler; use buffer_helper; +use error::Error; use key_handler::KeyHandler; +use mouse_handler; use InputCallback; +use Result; use {CursorStyle, MouseButton, MouseMode}; use {Key, KeyRepeat}; +use {MenuHandle, MenuItem, MenuItemHandle, UnixMenu, UnixMenuItem}; use {Scale, WindowOptions}; -use {MenuItem, MenuItemHandle, MenuHandle, UnixMenu, UnixMenuItem}; use std::cmp; use std::os::raw; @@ -47,14 +47,15 @@ impl Window { .map_err(|_| Error::WindowCreate("Unable to get display size".to_owned()))?; let mut scale = 32; while scale > 1 { - if width * scale < display_size.0 as usize && - height * scale < display_size.1 as usize { + if width * scale < display_size.0 as usize + && height * scale < display_size.1 as usize + { break; } scale -= 1; } scale - }, + } }; let window_width = width as u32 * window_scale as u32; @@ -68,29 +69,23 @@ impl Window { window_flags.push(orbclient::WindowFlag::Borderless); } - let window_opt = orbclient::Window::new_flags(-1, - -1, - window_width, - window_height, - name, - &window_flags); + let window_opt = + orbclient::Window::new_flags(-1, -1, window_width, window_height, name, &window_flags); match window_opt { - Some(window) => { - Ok(Window { - mouse_pos: None, - mouse_scroll: None, - mouse_state: (false, false, false), - is_open: true, - is_active: true, - buffer_width: width, - buffer_height: height, - window: window, - window_scale: window_scale, - key_handler: KeyHandler::new(), - menu_counter: MenuHandle(0), - menus: Vec::new(), - }) - }, + Some(window) => Ok(Window { + mouse_pos: None, + mouse_scroll: None, + mouse_state: (false, false, false), + is_open: true, + is_active: true, + buffer_width: width, + buffer_height: height, + window: window, + window_scale: window_scale, + key_handler: KeyHandler::new(), + menu_counter: MenuHandle(0), + menus: Vec::new(), + }), None => Err(Error::WindowCreate("Unable to open Window".to_owned())), } } @@ -107,7 +102,12 @@ impl Window { self.process_events(); self.key_handler.update(); - let check_res = buffer_helper::check_buffer_size(self.buffer_width, self.buffer_height, self.window_scale, buffer); + let check_res = buffer_helper::check_buffer_size( + self.buffer_width, + self.buffer_height, + self.window_scale, + buffer, + ); if check_res.is_err() { return check_res; } @@ -142,20 +142,22 @@ impl Window { pub fn get_mouse_down(&self, button: MouseButton) -> bool { match button { - MouseButton::Left => self.mouse_state.0, + MouseButton::Left => self.mouse_state.0, MouseButton::Middle => self.mouse_state.1, - MouseButton::Right => self.mouse_state.2, + MouseButton::Right => self.mouse_state.2, } } pub fn get_mouse_pos(&self, mode: MouseMode) -> Option<(f32, f32)> { if let Some((mouse_x, mouse_y)) = self.mouse_pos { - mouse_handler::get_pos(mode, - mouse_x as f32, - mouse_y as f32, - self.window_scale as f32, - self.buffer_width as f32 * self.window_scale as f32, - self.buffer_height as f32 * self.window_scale as f32) + mouse_handler::get_pos( + mode, + mouse_x as f32, + mouse_y as f32, + self.window_scale as f32, + self.buffer_width as f32 * self.window_scale as f32, + self.buffer_height as f32 * self.window_scale as f32, + ) } else { None } @@ -163,12 +165,14 @@ impl Window { pub fn get_unscaled_mouse_pos(&self, mode: MouseMode) -> Option<(f32, f32)> { if let Some((mouse_x, mouse_y)) = self.mouse_pos { - mouse_handler::get_pos(mode, - mouse_x as f32, - mouse_y as f32, - 1.0 as f32, - self.buffer_width as f32 * self.window_scale as f32, - self.buffer_height as f32 * self.window_scale as f32) + mouse_handler::get_pos( + mode, + mouse_x as f32, + mouse_y as f32, + 1.0 as f32, + self.buffer_width as f32 * self.window_scale as f32, + self.buffer_height as f32 * self.window_scale as f32, + ) } else { None } @@ -228,26 +232,26 @@ impl Window { if let Some(key) = key_opt { self.key_handler.set_key_state(key, key_event.pressed); } - }, + } orbclient::EventOption::Mouse(mouse_event) => { self.mouse_pos = Some((mouse_event.x, mouse_event.y)); - }, + } orbclient::EventOption::Button(button_event) => { self.mouse_state = (button_event.left, button_event.middle, button_event.right); - }, + } orbclient::EventOption::Quit(_) => { self.is_open = false; - }, + } orbclient::EventOption::Focus(focus_event) => { self.is_active = focus_event.focused; - if ! self.is_active { + if !self.is_active { self.mouse_pos = None; } - }, + } orbclient::EventOption::Scroll(scroll_event) => { self.mouse_pos = Some((scroll_event.x, scroll_event.y)); - }, - _ => { }, + } + _ => {} } } } @@ -335,16 +339,20 @@ impl Window { _ => { println!("Unknown Orbital scancode 0x{:2x}", scancode); None - }, + } } } /// Renders the given pixel data into the Orbital window fn render_buffer(&mut self, buffer: &[u32]) { - let render_width = cmp::min(self.buffer_width * self.window_scale, - self.window.width() as usize); - let render_height = cmp::min(self.buffer_height * self.window_scale, - self.window.height() as usize); + let render_width = cmp::min( + self.buffer_width * self.window_scale, + self.window.width() as usize, + ); + let render_height = cmp::min( + self.buffer_height * self.window_scale, + self.window.height() as usize, + ); let window_width = self.window.width() as usize; let window_buffer = self.window.data_mut(); @@ -400,7 +408,7 @@ impl Menu { item_counter: MenuItemHandle(0), name: name.to_owned(), items: Vec::new(), - } + }, }) } @@ -438,6 +446,8 @@ impl Menu { } pub fn remove_item(&mut self, handle: &MenuItemHandle) { - self.internal.items.retain(|ref item| item.handle.0 != handle.0); + self.internal + .items + .retain(|ref item| item.handle.0 != handle.0); } } diff --git a/src/os/unix/key_mapping.rs b/src/os/unix/key_mapping.rs index e2da734..7d1a16c 100644 --- a/src/os/unix/key_mapping.rs +++ b/src/os/unix/key_mapping.rs @@ -61,7 +61,6 @@ * */ - //************************************************************************ //**** KeySym to Unicode mapping table **** //************************************************************************ @@ -71,791 +70,789 @@ type CodePair = (u32 /* keysym */, u32 /* ucs */); const LENGTH: usize = 776; #[allow(non_upper_case_globals)] -const keysymtab: [CodePair ; LENGTH] = [ - ( 0x01a1, 0x0104 ), - ( 0x01a2, 0x02d8 ), - ( 0x01a3, 0x0141 ), - ( 0x01a5, 0x013d ), - ( 0x01a6, 0x015a ), - ( 0x01a9, 0x0160 ), - ( 0x01aa, 0x015e ), - ( 0x01ab, 0x0164 ), - ( 0x01ac, 0x0179 ), - ( 0x01ae, 0x017d ), - ( 0x01af, 0x017b ), - ( 0x01b1, 0x0105 ), - ( 0x01b2, 0x02db ), - ( 0x01b3, 0x0142 ), - ( 0x01b5, 0x013e ), - ( 0x01b6, 0x015b ), - ( 0x01b7, 0x02c7 ), - ( 0x01b9, 0x0161 ), - ( 0x01ba, 0x015f ), - ( 0x01bb, 0x0165 ), - ( 0x01bc, 0x017a ), - ( 0x01bd, 0x02dd ), - ( 0x01be, 0x017e ), - ( 0x01bf, 0x017c ), - ( 0x01c0, 0x0154 ), - ( 0x01c3, 0x0102 ), - ( 0x01c5, 0x0139 ), - ( 0x01c6, 0x0106 ), - ( 0x01c8, 0x010c ), - ( 0x01ca, 0x0118 ), - ( 0x01cc, 0x011a ), - ( 0x01cf, 0x010e ), - ( 0x01d0, 0x0110 ), - ( 0x01d1, 0x0143 ), - ( 0x01d2, 0x0147 ), - ( 0x01d5, 0x0150 ), - ( 0x01d8, 0x0158 ), - ( 0x01d9, 0x016e ), - ( 0x01db, 0x0170 ), - ( 0x01de, 0x0162 ), - ( 0x01e0, 0x0155 ), - ( 0x01e3, 0x0103 ), - ( 0x01e5, 0x013a ), - ( 0x01e6, 0x0107 ), - ( 0x01e8, 0x010d ), - ( 0x01ea, 0x0119 ), - ( 0x01ec, 0x011b ), - ( 0x01ef, 0x010f ), - ( 0x01f0, 0x0111 ), - ( 0x01f1, 0x0144 ), - ( 0x01f2, 0x0148 ), - ( 0x01f5, 0x0151 ), - ( 0x01f8, 0x0159 ), - ( 0x01f9, 0x016f ), - ( 0x01fb, 0x0171 ), - ( 0x01fe, 0x0163 ), - ( 0x01ff, 0x02d9 ), - ( 0x02a1, 0x0126 ), - ( 0x02a6, 0x0124 ), - ( 0x02a9, 0x0130 ), - ( 0x02ab, 0x011e ), - ( 0x02ac, 0x0134 ), - ( 0x02b1, 0x0127 ), - ( 0x02b6, 0x0125 ), - ( 0x02b9, 0x0131 ), - ( 0x02bb, 0x011f ), - ( 0x02bc, 0x0135 ), - ( 0x02c5, 0x010a ), - ( 0x02c6, 0x0108 ), - ( 0x02d5, 0x0120 ), - ( 0x02d8, 0x011c ), - ( 0x02dd, 0x016c ), - ( 0x02de, 0x015c ), - ( 0x02e5, 0x010b ), - ( 0x02e6, 0x0109 ), - ( 0x02f5, 0x0121 ), - ( 0x02f8, 0x011d ), - ( 0x02fd, 0x016d ), - ( 0x02fe, 0x015d ), - ( 0x03a2, 0x0138 ), - ( 0x03a3, 0x0156 ), - ( 0x03a5, 0x0128 ), - ( 0x03a6, 0x013b ), - ( 0x03aa, 0x0112 ), - ( 0x03ab, 0x0122 ), - ( 0x03ac, 0x0166 ), - ( 0x03b3, 0x0157 ), - ( 0x03b5, 0x0129 ), - ( 0x03b6, 0x013c ), - ( 0x03ba, 0x0113 ), - ( 0x03bb, 0x0123 ), - ( 0x03bc, 0x0167 ), - ( 0x03bd, 0x014a ), - ( 0x03bf, 0x014b ), - ( 0x03c0, 0x0100 ), - ( 0x03c7, 0x012e ), - ( 0x03cc, 0x0116 ), - ( 0x03cf, 0x012a ), - ( 0x03d1, 0x0145 ), - ( 0x03d2, 0x014c ), - ( 0x03d3, 0x0136 ), - ( 0x03d9, 0x0172 ), - ( 0x03dd, 0x0168 ), - ( 0x03de, 0x016a ), - ( 0x03e0, 0x0101 ), - ( 0x03e7, 0x012f ), - ( 0x03ec, 0x0117 ), - ( 0x03ef, 0x012b ), - ( 0x03f1, 0x0146 ), - ( 0x03f2, 0x014d ), - ( 0x03f3, 0x0137 ), - ( 0x03f9, 0x0173 ), - ( 0x03fd, 0x0169 ), - ( 0x03fe, 0x016b ), - ( 0x047e, 0x203e ), - ( 0x04a1, 0x3002 ), - ( 0x04a2, 0x300c ), - ( 0x04a3, 0x300d ), - ( 0x04a4, 0x3001 ), - ( 0x04a5, 0x30fb ), - ( 0x04a6, 0x30f2 ), - ( 0x04a7, 0x30a1 ), - ( 0x04a8, 0x30a3 ), - ( 0x04a9, 0x30a5 ), - ( 0x04aa, 0x30a7 ), - ( 0x04ab, 0x30a9 ), - ( 0x04ac, 0x30e3 ), - ( 0x04ad, 0x30e5 ), - ( 0x04ae, 0x30e7 ), - ( 0x04af, 0x30c3 ), - ( 0x04b0, 0x30fc ), - ( 0x04b1, 0x30a2 ), - ( 0x04b2, 0x30a4 ), - ( 0x04b3, 0x30a6 ), - ( 0x04b4, 0x30a8 ), - ( 0x04b5, 0x30aa ), - ( 0x04b6, 0x30ab ), - ( 0x04b7, 0x30ad ), - ( 0x04b8, 0x30af ), - ( 0x04b9, 0x30b1 ), - ( 0x04ba, 0x30b3 ), - ( 0x04bb, 0x30b5 ), - ( 0x04bc, 0x30b7 ), - ( 0x04bd, 0x30b9 ), - ( 0x04be, 0x30bb ), - ( 0x04bf, 0x30bd ), - ( 0x04c0, 0x30bf ), - ( 0x04c1, 0x30c1 ), - ( 0x04c2, 0x30c4 ), - ( 0x04c3, 0x30c6 ), - ( 0x04c4, 0x30c8 ), - ( 0x04c5, 0x30ca ), - ( 0x04c6, 0x30cb ), - ( 0x04c7, 0x30cc ), - ( 0x04c8, 0x30cd ), - ( 0x04c9, 0x30ce ), - ( 0x04ca, 0x30cf ), - ( 0x04cb, 0x30d2 ), - ( 0x04cc, 0x30d5 ), - ( 0x04cd, 0x30d8 ), - ( 0x04ce, 0x30db ), - ( 0x04cf, 0x30de ), - ( 0x04d0, 0x30df ), - ( 0x04d1, 0x30e0 ), - ( 0x04d2, 0x30e1 ), - ( 0x04d3, 0x30e2 ), - ( 0x04d4, 0x30e4 ), - ( 0x04d5, 0x30e6 ), - ( 0x04d6, 0x30e8 ), - ( 0x04d7, 0x30e9 ), - ( 0x04d8, 0x30ea ), - ( 0x04d9, 0x30eb ), - ( 0x04da, 0x30ec ), - ( 0x04db, 0x30ed ), - ( 0x04dc, 0x30ef ), - ( 0x04dd, 0x30f3 ), - ( 0x04de, 0x309b ), - ( 0x04df, 0x309c ), - ( 0x05ac, 0x060c ), - ( 0x05bb, 0x061b ), - ( 0x05bf, 0x061f ), - ( 0x05c1, 0x0621 ), - ( 0x05c2, 0x0622 ), - ( 0x05c3, 0x0623 ), - ( 0x05c4, 0x0624 ), - ( 0x05c5, 0x0625 ), - ( 0x05c6, 0x0626 ), - ( 0x05c7, 0x0627 ), - ( 0x05c8, 0x0628 ), - ( 0x05c9, 0x0629 ), - ( 0x05ca, 0x062a ), - ( 0x05cb, 0x062b ), - ( 0x05cc, 0x062c ), - ( 0x05cd, 0x062d ), - ( 0x05ce, 0x062e ), - ( 0x05cf, 0x062f ), - ( 0x05d0, 0x0630 ), - ( 0x05d1, 0x0631 ), - ( 0x05d2, 0x0632 ), - ( 0x05d3, 0x0633 ), - ( 0x05d4, 0x0634 ), - ( 0x05d5, 0x0635 ), - ( 0x05d6, 0x0636 ), - ( 0x05d7, 0x0637 ), - ( 0x05d8, 0x0638 ), - ( 0x05d9, 0x0639 ), - ( 0x05da, 0x063a ), - ( 0x05e0, 0x0640 ), - ( 0x05e1, 0x0641 ), - ( 0x05e2, 0x0642 ), - ( 0x05e3, 0x0643 ), - ( 0x05e4, 0x0644 ), - ( 0x05e5, 0x0645 ), - ( 0x05e6, 0x0646 ), - ( 0x05e7, 0x0647 ), - ( 0x05e8, 0x0648 ), - ( 0x05e9, 0x0649 ), - ( 0x05ea, 0x064a ), - ( 0x05eb, 0x064b ), - ( 0x05ec, 0x064c ), - ( 0x05ed, 0x064d ), - ( 0x05ee, 0x064e ), - ( 0x05ef, 0x064f ), - ( 0x05f0, 0x0650 ), - ( 0x05f1, 0x0651 ), - ( 0x05f2, 0x0652 ), - ( 0x06a1, 0x0452 ), - ( 0x06a2, 0x0453 ), - ( 0x06a3, 0x0451 ), - ( 0x06a4, 0x0454 ), - ( 0x06a5, 0x0455 ), - ( 0x06a6, 0x0456 ), - ( 0x06a7, 0x0457 ), - ( 0x06a8, 0x0458 ), - ( 0x06a9, 0x0459 ), - ( 0x06aa, 0x045a ), - ( 0x06ab, 0x045b ), - ( 0x06ac, 0x045c ), - ( 0x06ae, 0x045e ), - ( 0x06af, 0x045f ), - ( 0x06b0, 0x2116 ), - ( 0x06b1, 0x0402 ), - ( 0x06b2, 0x0403 ), - ( 0x06b3, 0x0401 ), - ( 0x06b4, 0x0404 ), - ( 0x06b5, 0x0405 ), - ( 0x06b6, 0x0406 ), - ( 0x06b7, 0x0407 ), - ( 0x06b8, 0x0408 ), - ( 0x06b9, 0x0409 ), - ( 0x06ba, 0x040a ), - ( 0x06bb, 0x040b ), - ( 0x06bc, 0x040c ), - ( 0x06be, 0x040e ), - ( 0x06bf, 0x040f ), - ( 0x06c0, 0x044e ), - ( 0x06c1, 0x0430 ), - ( 0x06c2, 0x0431 ), - ( 0x06c3, 0x0446 ), - ( 0x06c4, 0x0434 ), - ( 0x06c5, 0x0435 ), - ( 0x06c6, 0x0444 ), - ( 0x06c7, 0x0433 ), - ( 0x06c8, 0x0445 ), - ( 0x06c9, 0x0438 ), - ( 0x06ca, 0x0439 ), - ( 0x06cb, 0x043a ), - ( 0x06cc, 0x043b ), - ( 0x06cd, 0x043c ), - ( 0x06ce, 0x043d ), - ( 0x06cf, 0x043e ), - ( 0x06d0, 0x043f ), - ( 0x06d1, 0x044f ), - ( 0x06d2, 0x0440 ), - ( 0x06d3, 0x0441 ), - ( 0x06d4, 0x0442 ), - ( 0x06d5, 0x0443 ), - ( 0x06d6, 0x0436 ), - ( 0x06d7, 0x0432 ), - ( 0x06d8, 0x044c ), - ( 0x06d9, 0x044b ), - ( 0x06da, 0x0437 ), - ( 0x06db, 0x0448 ), - ( 0x06dc, 0x044d ), - ( 0x06dd, 0x0449 ), - ( 0x06de, 0x0447 ), - ( 0x06df, 0x044a ), - ( 0x06e0, 0x042e ), - ( 0x06e1, 0x0410 ), - ( 0x06e2, 0x0411 ), - ( 0x06e3, 0x0426 ), - ( 0x06e4, 0x0414 ), - ( 0x06e5, 0x0415 ), - ( 0x06e6, 0x0424 ), - ( 0x06e7, 0x0413 ), - ( 0x06e8, 0x0425 ), - ( 0x06e9, 0x0418 ), - ( 0x06ea, 0x0419 ), - ( 0x06eb, 0x041a ), - ( 0x06ec, 0x041b ), - ( 0x06ed, 0x041c ), - ( 0x06ee, 0x041d ), - ( 0x06ef, 0x041e ), - ( 0x06f0, 0x041f ), - ( 0x06f1, 0x042f ), - ( 0x06f2, 0x0420 ), - ( 0x06f3, 0x0421 ), - ( 0x06f4, 0x0422 ), - ( 0x06f5, 0x0423 ), - ( 0x06f6, 0x0416 ), - ( 0x06f7, 0x0412 ), - ( 0x06f8, 0x042c ), - ( 0x06f9, 0x042b ), - ( 0x06fa, 0x0417 ), - ( 0x06fb, 0x0428 ), - ( 0x06fc, 0x042d ), - ( 0x06fd, 0x0429 ), - ( 0x06fe, 0x0427 ), - ( 0x06ff, 0x042a ), - ( 0x07a1, 0x0386 ), - ( 0x07a2, 0x0388 ), - ( 0x07a3, 0x0389 ), - ( 0x07a4, 0x038a ), - ( 0x07a5, 0x03aa ), - ( 0x07a7, 0x038c ), - ( 0x07a8, 0x038e ), - ( 0x07a9, 0x03ab ), - ( 0x07ab, 0x038f ), - ( 0x07ae, 0x0385 ), - ( 0x07af, 0x2015 ), - ( 0x07b1, 0x03ac ), - ( 0x07b2, 0x03ad ), - ( 0x07b3, 0x03ae ), - ( 0x07b4, 0x03af ), - ( 0x07b5, 0x03ca ), - ( 0x07b6, 0x0390 ), - ( 0x07b7, 0x03cc ), - ( 0x07b8, 0x03cd ), - ( 0x07b9, 0x03cb ), - ( 0x07ba, 0x03b0 ), - ( 0x07bb, 0x03ce ), - ( 0x07c1, 0x0391 ), - ( 0x07c2, 0x0392 ), - ( 0x07c3, 0x0393 ), - ( 0x07c4, 0x0394 ), - ( 0x07c5, 0x0395 ), - ( 0x07c6, 0x0396 ), - ( 0x07c7, 0x0397 ), - ( 0x07c8, 0x0398 ), - ( 0x07c9, 0x0399 ), - ( 0x07ca, 0x039a ), - ( 0x07cb, 0x039b ), - ( 0x07cc, 0x039c ), - ( 0x07cd, 0x039d ), - ( 0x07ce, 0x039e ), - ( 0x07cf, 0x039f ), - ( 0x07d0, 0x03a0 ), - ( 0x07d1, 0x03a1 ), - ( 0x07d2, 0x03a3 ), - ( 0x07d4, 0x03a4 ), - ( 0x07d5, 0x03a5 ), - ( 0x07d6, 0x03a6 ), - ( 0x07d7, 0x03a7 ), - ( 0x07d8, 0x03a8 ), - ( 0x07d9, 0x03a9 ), - ( 0x07e1, 0x03b1 ), - ( 0x07e2, 0x03b2 ), - ( 0x07e3, 0x03b3 ), - ( 0x07e4, 0x03b4 ), - ( 0x07e5, 0x03b5 ), - ( 0x07e6, 0x03b6 ), - ( 0x07e7, 0x03b7 ), - ( 0x07e8, 0x03b8 ), - ( 0x07e9, 0x03b9 ), - ( 0x07ea, 0x03ba ), - ( 0x07eb, 0x03bb ), - ( 0x07ec, 0x03bc ), - ( 0x07ed, 0x03bd ), - ( 0x07ee, 0x03be ), - ( 0x07ef, 0x03bf ), - ( 0x07f0, 0x03c0 ), - ( 0x07f1, 0x03c1 ), - ( 0x07f2, 0x03c3 ), - ( 0x07f3, 0x03c2 ), - ( 0x07f4, 0x03c4 ), - ( 0x07f5, 0x03c5 ), - ( 0x07f6, 0x03c6 ), - ( 0x07f7, 0x03c7 ), - ( 0x07f8, 0x03c8 ), - ( 0x07f9, 0x03c9 ), - ( 0x08a1, 0x23b7 ), - ( 0x08a2, 0x250c ), - ( 0x08a3, 0x2500 ), - ( 0x08a4, 0x2320 ), - ( 0x08a5, 0x2321 ), - ( 0x08a6, 0x2502 ), - ( 0x08a7, 0x23a1 ), - ( 0x08a8, 0x23a3 ), - ( 0x08a9, 0x23a4 ), - ( 0x08aa, 0x23a6 ), - ( 0x08ab, 0x239b ), - ( 0x08ac, 0x239d ), - ( 0x08ad, 0x239e ), - ( 0x08ae, 0x23a0 ), - ( 0x08af, 0x23a8 ), - ( 0x08b0, 0x23ac ), - ( 0x08bc, 0x2264 ), - ( 0x08bd, 0x2260 ), - ( 0x08be, 0x2265 ), - ( 0x08bf, 0x222b ), - ( 0x08c0, 0x2234 ), - ( 0x08c1, 0x221d ), - ( 0x08c2, 0x221e ), - ( 0x08c5, 0x2207 ), - ( 0x08c8, 0x223c ), - ( 0x08c9, 0x2243 ), - ( 0x08cd, 0x21d4 ), - ( 0x08ce, 0x21d2 ), - ( 0x08cf, 0x2261 ), - ( 0x08d6, 0x221a ), - ( 0x08da, 0x2282 ), - ( 0x08db, 0x2283 ), - ( 0x08dc, 0x2229 ), - ( 0x08dd, 0x222a ), - ( 0x08de, 0x2227 ), - ( 0x08df, 0x2228 ), - ( 0x08ef, 0x2202 ), - ( 0x08f6, 0x0192 ), - ( 0x08fb, 0x2190 ), - ( 0x08fc, 0x2191 ), - ( 0x08fd, 0x2192 ), - ( 0x08fe, 0x2193 ), - ( 0x09e0, 0x25c6 ), - ( 0x09e1, 0x2592 ), - ( 0x09e2, 0x2409 ), - ( 0x09e3, 0x240c ), - ( 0x09e4, 0x240d ), - ( 0x09e5, 0x240a ), - ( 0x09e8, 0x2424 ), - ( 0x09e9, 0x240b ), - ( 0x09ea, 0x2518 ), - ( 0x09eb, 0x2510 ), - ( 0x09ec, 0x250c ), - ( 0x09ed, 0x2514 ), - ( 0x09ee, 0x253c ), - ( 0x09ef, 0x23ba ), - ( 0x09f0, 0x23bb ), - ( 0x09f1, 0x2500 ), - ( 0x09f2, 0x23bc ), - ( 0x09f3, 0x23bd ), - ( 0x09f4, 0x251c ), - ( 0x09f5, 0x2524 ), - ( 0x09f6, 0x2534 ), - ( 0x09f7, 0x252c ), - ( 0x09f8, 0x2502 ), - ( 0x0aa1, 0x2003 ), - ( 0x0aa2, 0x2002 ), - ( 0x0aa3, 0x2004 ), - ( 0x0aa4, 0x2005 ), - ( 0x0aa5, 0x2007 ), - ( 0x0aa6, 0x2008 ), - ( 0x0aa7, 0x2009 ), - ( 0x0aa8, 0x200a ), - ( 0x0aa9, 0x2014 ), - ( 0x0aaa, 0x2013 ), - ( 0x0aae, 0x2026 ), - ( 0x0aaf, 0x2025 ), - ( 0x0ab0, 0x2153 ), - ( 0x0ab1, 0x2154 ), - ( 0x0ab2, 0x2155 ), - ( 0x0ab3, 0x2156 ), - ( 0x0ab4, 0x2157 ), - ( 0x0ab5, 0x2158 ), - ( 0x0ab6, 0x2159 ), - ( 0x0ab7, 0x215a ), - ( 0x0ab8, 0x2105 ), - ( 0x0abb, 0x2012 ), - ( 0x0abc, 0x2329 ), - ( 0x0abe, 0x232a ), - ( 0x0ac3, 0x215b ), - ( 0x0ac4, 0x215c ), - ( 0x0ac5, 0x215d ), - ( 0x0ac6, 0x215e ), - ( 0x0ac9, 0x2122 ), - ( 0x0aca, 0x2613 ), - ( 0x0acc, 0x25c1 ), - ( 0x0acd, 0x25b7 ), - ( 0x0ace, 0x25cb ), - ( 0x0acf, 0x25af ), - ( 0x0ad0, 0x2018 ), - ( 0x0ad1, 0x2019 ), - ( 0x0ad2, 0x201c ), - ( 0x0ad3, 0x201d ), - ( 0x0ad4, 0x211e ), - ( 0x0ad6, 0x2032 ), - ( 0x0ad7, 0x2033 ), - ( 0x0ad9, 0x271d ), - ( 0x0adb, 0x25ac ), - ( 0x0adc, 0x25c0 ), - ( 0x0add, 0x25b6 ), - ( 0x0ade, 0x25cf ), - ( 0x0adf, 0x25ae ), - ( 0x0ae0, 0x25e6 ), - ( 0x0ae1, 0x25ab ), - ( 0x0ae2, 0x25ad ), - ( 0x0ae3, 0x25b3 ), - ( 0x0ae4, 0x25bd ), - ( 0x0ae5, 0x2606 ), - ( 0x0ae6, 0x2022 ), - ( 0x0ae7, 0x25aa ), - ( 0x0ae8, 0x25b2 ), - ( 0x0ae9, 0x25bc ), - ( 0x0aea, 0x261c ), - ( 0x0aeb, 0x261e ), - ( 0x0aec, 0x2663 ), - ( 0x0aed, 0x2666 ), - ( 0x0aee, 0x2665 ), - ( 0x0af0, 0x2720 ), - ( 0x0af1, 0x2020 ), - ( 0x0af2, 0x2021 ), - ( 0x0af3, 0x2713 ), - ( 0x0af4, 0x2717 ), - ( 0x0af5, 0x266f ), - ( 0x0af6, 0x266d ), - ( 0x0af7, 0x2642 ), - ( 0x0af8, 0x2640 ), - ( 0x0af9, 0x260e ), - ( 0x0afa, 0x2315 ), - ( 0x0afb, 0x2117 ), - ( 0x0afc, 0x2038 ), - ( 0x0afd, 0x201a ), - ( 0x0afe, 0x201e ), - ( 0x0ba3, 0x003c ), - ( 0x0ba6, 0x003e ), - ( 0x0ba8, 0x2228 ), - ( 0x0ba9, 0x2227 ), - ( 0x0bc0, 0x00af ), - ( 0x0bc2, 0x22a5 ), - ( 0x0bc3, 0x2229 ), - ( 0x0bc4, 0x230a ), - ( 0x0bc6, 0x005f ), - ( 0x0bca, 0x2218 ), - ( 0x0bcc, 0x2395 ), - ( 0x0bce, 0x22a4 ), - ( 0x0bcf, 0x25cb ), - ( 0x0bd3, 0x2308 ), - ( 0x0bd6, 0x222a ), - ( 0x0bd8, 0x2283 ), - ( 0x0bda, 0x2282 ), - ( 0x0bdc, 0x22a2 ), - ( 0x0bfc, 0x22a3 ), - ( 0x0cdf, 0x2017 ), - ( 0x0ce0, 0x05d0 ), - ( 0x0ce1, 0x05d1 ), - ( 0x0ce2, 0x05d2 ), - ( 0x0ce3, 0x05d3 ), - ( 0x0ce4, 0x05d4 ), - ( 0x0ce5, 0x05d5 ), - ( 0x0ce6, 0x05d6 ), - ( 0x0ce7, 0x05d7 ), - ( 0x0ce8, 0x05d8 ), - ( 0x0ce9, 0x05d9 ), - ( 0x0cea, 0x05da ), - ( 0x0ceb, 0x05db ), - ( 0x0cec, 0x05dc ), - ( 0x0ced, 0x05dd ), - ( 0x0cee, 0x05de ), - ( 0x0cef, 0x05df ), - ( 0x0cf0, 0x05e0 ), - ( 0x0cf1, 0x05e1 ), - ( 0x0cf2, 0x05e2 ), - ( 0x0cf3, 0x05e3 ), - ( 0x0cf4, 0x05e4 ), - ( 0x0cf5, 0x05e5 ), - ( 0x0cf6, 0x05e6 ), - ( 0x0cf7, 0x05e7 ), - ( 0x0cf8, 0x05e8 ), - ( 0x0cf9, 0x05e9 ), - ( 0x0cfa, 0x05ea ), - ( 0x0da1, 0x0e01 ), - ( 0x0da2, 0x0e02 ), - ( 0x0da3, 0x0e03 ), - ( 0x0da4, 0x0e04 ), - ( 0x0da5, 0x0e05 ), - ( 0x0da6, 0x0e06 ), - ( 0x0da7, 0x0e07 ), - ( 0x0da8, 0x0e08 ), - ( 0x0da9, 0x0e09 ), - ( 0x0daa, 0x0e0a ), - ( 0x0dab, 0x0e0b ), - ( 0x0dac, 0x0e0c ), - ( 0x0dad, 0x0e0d ), - ( 0x0dae, 0x0e0e ), - ( 0x0daf, 0x0e0f ), - ( 0x0db0, 0x0e10 ), - ( 0x0db1, 0x0e11 ), - ( 0x0db2, 0x0e12 ), - ( 0x0db3, 0x0e13 ), - ( 0x0db4, 0x0e14 ), - ( 0x0db5, 0x0e15 ), - ( 0x0db6, 0x0e16 ), - ( 0x0db7, 0x0e17 ), - ( 0x0db8, 0x0e18 ), - ( 0x0db9, 0x0e19 ), - ( 0x0dba, 0x0e1a ), - ( 0x0dbb, 0x0e1b ), - ( 0x0dbc, 0x0e1c ), - ( 0x0dbd, 0x0e1d ), - ( 0x0dbe, 0x0e1e ), - ( 0x0dbf, 0x0e1f ), - ( 0x0dc0, 0x0e20 ), - ( 0x0dc1, 0x0e21 ), - ( 0x0dc2, 0x0e22 ), - ( 0x0dc3, 0x0e23 ), - ( 0x0dc4, 0x0e24 ), - ( 0x0dc5, 0x0e25 ), - ( 0x0dc6, 0x0e26 ), - ( 0x0dc7, 0x0e27 ), - ( 0x0dc8, 0x0e28 ), - ( 0x0dc9, 0x0e29 ), - ( 0x0dca, 0x0e2a ), - ( 0x0dcb, 0x0e2b ), - ( 0x0dcc, 0x0e2c ), - ( 0x0dcd, 0x0e2d ), - ( 0x0dce, 0x0e2e ), - ( 0x0dcf, 0x0e2f ), - ( 0x0dd0, 0x0e30 ), - ( 0x0dd1, 0x0e31 ), - ( 0x0dd2, 0x0e32 ), - ( 0x0dd3, 0x0e33 ), - ( 0x0dd4, 0x0e34 ), - ( 0x0dd5, 0x0e35 ), - ( 0x0dd6, 0x0e36 ), - ( 0x0dd7, 0x0e37 ), - ( 0x0dd8, 0x0e38 ), - ( 0x0dd9, 0x0e39 ), - ( 0x0dda, 0x0e3a ), - ( 0x0ddf, 0x0e3f ), - ( 0x0de0, 0x0e40 ), - ( 0x0de1, 0x0e41 ), - ( 0x0de2, 0x0e42 ), - ( 0x0de3, 0x0e43 ), - ( 0x0de4, 0x0e44 ), - ( 0x0de5, 0x0e45 ), - ( 0x0de6, 0x0e46 ), - ( 0x0de7, 0x0e47 ), - ( 0x0de8, 0x0e48 ), - ( 0x0de9, 0x0e49 ), - ( 0x0dea, 0x0e4a ), - ( 0x0deb, 0x0e4b ), - ( 0x0dec, 0x0e4c ), - ( 0x0ded, 0x0e4d ), - ( 0x0df0, 0x0e50 ), - ( 0x0df1, 0x0e51 ), - ( 0x0df2, 0x0e52 ), - ( 0x0df3, 0x0e53 ), - ( 0x0df4, 0x0e54 ), - ( 0x0df5, 0x0e55 ), - ( 0x0df6, 0x0e56 ), - ( 0x0df7, 0x0e57 ), - ( 0x0df8, 0x0e58 ), - ( 0x0df9, 0x0e59 ), - ( 0x0ea1, 0x3131 ), - ( 0x0ea2, 0x3132 ), - ( 0x0ea3, 0x3133 ), - ( 0x0ea4, 0x3134 ), - ( 0x0ea5, 0x3135 ), - ( 0x0ea6, 0x3136 ), - ( 0x0ea7, 0x3137 ), - ( 0x0ea8, 0x3138 ), - ( 0x0ea9, 0x3139 ), - ( 0x0eaa, 0x313a ), - ( 0x0eab, 0x313b ), - ( 0x0eac, 0x313c ), - ( 0x0ead, 0x313d ), - ( 0x0eae, 0x313e ), - ( 0x0eaf, 0x313f ), - ( 0x0eb0, 0x3140 ), - ( 0x0eb1, 0x3141 ), - ( 0x0eb2, 0x3142 ), - ( 0x0eb3, 0x3143 ), - ( 0x0eb4, 0x3144 ), - ( 0x0eb5, 0x3145 ), - ( 0x0eb6, 0x3146 ), - ( 0x0eb7, 0x3147 ), - ( 0x0eb8, 0x3148 ), - ( 0x0eb9, 0x3149 ), - ( 0x0eba, 0x314a ), - ( 0x0ebb, 0x314b ), - ( 0x0ebc, 0x314c ), - ( 0x0ebd, 0x314d ), - ( 0x0ebe, 0x314e ), - ( 0x0ebf, 0x314f ), - ( 0x0ec0, 0x3150 ), - ( 0x0ec1, 0x3151 ), - ( 0x0ec2, 0x3152 ), - ( 0x0ec3, 0x3153 ), - ( 0x0ec4, 0x3154 ), - ( 0x0ec5, 0x3155 ), - ( 0x0ec6, 0x3156 ), - ( 0x0ec7, 0x3157 ), - ( 0x0ec8, 0x3158 ), - ( 0x0ec9, 0x3159 ), - ( 0x0eca, 0x315a ), - ( 0x0ecb, 0x315b ), - ( 0x0ecc, 0x315c ), - ( 0x0ecd, 0x315d ), - ( 0x0ece, 0x315e ), - ( 0x0ecf, 0x315f ), - ( 0x0ed0, 0x3160 ), - ( 0x0ed1, 0x3161 ), - ( 0x0ed2, 0x3162 ), - ( 0x0ed3, 0x3163 ), - ( 0x0ed4, 0x11a8 ), - ( 0x0ed5, 0x11a9 ), - ( 0x0ed6, 0x11aa ), - ( 0x0ed7, 0x11ab ), - ( 0x0ed8, 0x11ac ), - ( 0x0ed9, 0x11ad ), - ( 0x0eda, 0x11ae ), - ( 0x0edb, 0x11af ), - ( 0x0edc, 0x11b0 ), - ( 0x0edd, 0x11b1 ), - ( 0x0ede, 0x11b2 ), - ( 0x0edf, 0x11b3 ), - ( 0x0ee0, 0x11b4 ), - ( 0x0ee1, 0x11b5 ), - ( 0x0ee2, 0x11b6 ), - ( 0x0ee3, 0x11b7 ), - ( 0x0ee4, 0x11b8 ), - ( 0x0ee5, 0x11b9 ), - ( 0x0ee6, 0x11ba ), - ( 0x0ee7, 0x11bb ), - ( 0x0ee8, 0x11bc ), - ( 0x0ee9, 0x11bd ), - ( 0x0eea, 0x11be ), - ( 0x0eeb, 0x11bf ), - ( 0x0eec, 0x11c0 ), - ( 0x0eed, 0x11c1 ), - ( 0x0eee, 0x11c2 ), - ( 0x0eef, 0x316d ), - ( 0x0ef0, 0x3171 ), - ( 0x0ef1, 0x3178 ), - ( 0x0ef2, 0x317f ), - ( 0x0ef3, 0x3181 ), - ( 0x0ef4, 0x3184 ), - ( 0x0ef5, 0x3186 ), - ( 0x0ef6, 0x318d ), - ( 0x0ef7, 0x318e ), - ( 0x0ef8, 0x11eb ), - ( 0x0ef9, 0x11f0 ), - ( 0x0efa, 0x11f9 ), - ( 0x0eff, 0x20a9 ), - ( 0x13a4, 0x20ac ), - ( 0x13bc, 0x0152 ), - ( 0x13bd, 0x0153 ), - ( 0x13be, 0x0178 ), - ( 0x20ac, 0x20ac ), - +const keysymtab: [CodePair; LENGTH] = [ + (0x01a1, 0x0104), + (0x01a2, 0x02d8), + (0x01a3, 0x0141), + (0x01a5, 0x013d), + (0x01a6, 0x015a), + (0x01a9, 0x0160), + (0x01aa, 0x015e), + (0x01ab, 0x0164), + (0x01ac, 0x0179), + (0x01ae, 0x017d), + (0x01af, 0x017b), + (0x01b1, 0x0105), + (0x01b2, 0x02db), + (0x01b3, 0x0142), + (0x01b5, 0x013e), + (0x01b6, 0x015b), + (0x01b7, 0x02c7), + (0x01b9, 0x0161), + (0x01ba, 0x015f), + (0x01bb, 0x0165), + (0x01bc, 0x017a), + (0x01bd, 0x02dd), + (0x01be, 0x017e), + (0x01bf, 0x017c), + (0x01c0, 0x0154), + (0x01c3, 0x0102), + (0x01c5, 0x0139), + (0x01c6, 0x0106), + (0x01c8, 0x010c), + (0x01ca, 0x0118), + (0x01cc, 0x011a), + (0x01cf, 0x010e), + (0x01d0, 0x0110), + (0x01d1, 0x0143), + (0x01d2, 0x0147), + (0x01d5, 0x0150), + (0x01d8, 0x0158), + (0x01d9, 0x016e), + (0x01db, 0x0170), + (0x01de, 0x0162), + (0x01e0, 0x0155), + (0x01e3, 0x0103), + (0x01e5, 0x013a), + (0x01e6, 0x0107), + (0x01e8, 0x010d), + (0x01ea, 0x0119), + (0x01ec, 0x011b), + (0x01ef, 0x010f), + (0x01f0, 0x0111), + (0x01f1, 0x0144), + (0x01f2, 0x0148), + (0x01f5, 0x0151), + (0x01f8, 0x0159), + (0x01f9, 0x016f), + (0x01fb, 0x0171), + (0x01fe, 0x0163), + (0x01ff, 0x02d9), + (0x02a1, 0x0126), + (0x02a6, 0x0124), + (0x02a9, 0x0130), + (0x02ab, 0x011e), + (0x02ac, 0x0134), + (0x02b1, 0x0127), + (0x02b6, 0x0125), + (0x02b9, 0x0131), + (0x02bb, 0x011f), + (0x02bc, 0x0135), + (0x02c5, 0x010a), + (0x02c6, 0x0108), + (0x02d5, 0x0120), + (0x02d8, 0x011c), + (0x02dd, 0x016c), + (0x02de, 0x015c), + (0x02e5, 0x010b), + (0x02e6, 0x0109), + (0x02f5, 0x0121), + (0x02f8, 0x011d), + (0x02fd, 0x016d), + (0x02fe, 0x015d), + (0x03a2, 0x0138), + (0x03a3, 0x0156), + (0x03a5, 0x0128), + (0x03a6, 0x013b), + (0x03aa, 0x0112), + (0x03ab, 0x0122), + (0x03ac, 0x0166), + (0x03b3, 0x0157), + (0x03b5, 0x0129), + (0x03b6, 0x013c), + (0x03ba, 0x0113), + (0x03bb, 0x0123), + (0x03bc, 0x0167), + (0x03bd, 0x014a), + (0x03bf, 0x014b), + (0x03c0, 0x0100), + (0x03c7, 0x012e), + (0x03cc, 0x0116), + (0x03cf, 0x012a), + (0x03d1, 0x0145), + (0x03d2, 0x014c), + (0x03d3, 0x0136), + (0x03d9, 0x0172), + (0x03dd, 0x0168), + (0x03de, 0x016a), + (0x03e0, 0x0101), + (0x03e7, 0x012f), + (0x03ec, 0x0117), + (0x03ef, 0x012b), + (0x03f1, 0x0146), + (0x03f2, 0x014d), + (0x03f3, 0x0137), + (0x03f9, 0x0173), + (0x03fd, 0x0169), + (0x03fe, 0x016b), + (0x047e, 0x203e), + (0x04a1, 0x3002), + (0x04a2, 0x300c), + (0x04a3, 0x300d), + (0x04a4, 0x3001), + (0x04a5, 0x30fb), + (0x04a6, 0x30f2), + (0x04a7, 0x30a1), + (0x04a8, 0x30a3), + (0x04a9, 0x30a5), + (0x04aa, 0x30a7), + (0x04ab, 0x30a9), + (0x04ac, 0x30e3), + (0x04ad, 0x30e5), + (0x04ae, 0x30e7), + (0x04af, 0x30c3), + (0x04b0, 0x30fc), + (0x04b1, 0x30a2), + (0x04b2, 0x30a4), + (0x04b3, 0x30a6), + (0x04b4, 0x30a8), + (0x04b5, 0x30aa), + (0x04b6, 0x30ab), + (0x04b7, 0x30ad), + (0x04b8, 0x30af), + (0x04b9, 0x30b1), + (0x04ba, 0x30b3), + (0x04bb, 0x30b5), + (0x04bc, 0x30b7), + (0x04bd, 0x30b9), + (0x04be, 0x30bb), + (0x04bf, 0x30bd), + (0x04c0, 0x30bf), + (0x04c1, 0x30c1), + (0x04c2, 0x30c4), + (0x04c3, 0x30c6), + (0x04c4, 0x30c8), + (0x04c5, 0x30ca), + (0x04c6, 0x30cb), + (0x04c7, 0x30cc), + (0x04c8, 0x30cd), + (0x04c9, 0x30ce), + (0x04ca, 0x30cf), + (0x04cb, 0x30d2), + (0x04cc, 0x30d5), + (0x04cd, 0x30d8), + (0x04ce, 0x30db), + (0x04cf, 0x30de), + (0x04d0, 0x30df), + (0x04d1, 0x30e0), + (0x04d2, 0x30e1), + (0x04d3, 0x30e2), + (0x04d4, 0x30e4), + (0x04d5, 0x30e6), + (0x04d6, 0x30e8), + (0x04d7, 0x30e9), + (0x04d8, 0x30ea), + (0x04d9, 0x30eb), + (0x04da, 0x30ec), + (0x04db, 0x30ed), + (0x04dc, 0x30ef), + (0x04dd, 0x30f3), + (0x04de, 0x309b), + (0x04df, 0x309c), + (0x05ac, 0x060c), + (0x05bb, 0x061b), + (0x05bf, 0x061f), + (0x05c1, 0x0621), + (0x05c2, 0x0622), + (0x05c3, 0x0623), + (0x05c4, 0x0624), + (0x05c5, 0x0625), + (0x05c6, 0x0626), + (0x05c7, 0x0627), + (0x05c8, 0x0628), + (0x05c9, 0x0629), + (0x05ca, 0x062a), + (0x05cb, 0x062b), + (0x05cc, 0x062c), + (0x05cd, 0x062d), + (0x05ce, 0x062e), + (0x05cf, 0x062f), + (0x05d0, 0x0630), + (0x05d1, 0x0631), + (0x05d2, 0x0632), + (0x05d3, 0x0633), + (0x05d4, 0x0634), + (0x05d5, 0x0635), + (0x05d6, 0x0636), + (0x05d7, 0x0637), + (0x05d8, 0x0638), + (0x05d9, 0x0639), + (0x05da, 0x063a), + (0x05e0, 0x0640), + (0x05e1, 0x0641), + (0x05e2, 0x0642), + (0x05e3, 0x0643), + (0x05e4, 0x0644), + (0x05e5, 0x0645), + (0x05e6, 0x0646), + (0x05e7, 0x0647), + (0x05e8, 0x0648), + (0x05e9, 0x0649), + (0x05ea, 0x064a), + (0x05eb, 0x064b), + (0x05ec, 0x064c), + (0x05ed, 0x064d), + (0x05ee, 0x064e), + (0x05ef, 0x064f), + (0x05f0, 0x0650), + (0x05f1, 0x0651), + (0x05f2, 0x0652), + (0x06a1, 0x0452), + (0x06a2, 0x0453), + (0x06a3, 0x0451), + (0x06a4, 0x0454), + (0x06a5, 0x0455), + (0x06a6, 0x0456), + (0x06a7, 0x0457), + (0x06a8, 0x0458), + (0x06a9, 0x0459), + (0x06aa, 0x045a), + (0x06ab, 0x045b), + (0x06ac, 0x045c), + (0x06ae, 0x045e), + (0x06af, 0x045f), + (0x06b0, 0x2116), + (0x06b1, 0x0402), + (0x06b2, 0x0403), + (0x06b3, 0x0401), + (0x06b4, 0x0404), + (0x06b5, 0x0405), + (0x06b6, 0x0406), + (0x06b7, 0x0407), + (0x06b8, 0x0408), + (0x06b9, 0x0409), + (0x06ba, 0x040a), + (0x06bb, 0x040b), + (0x06bc, 0x040c), + (0x06be, 0x040e), + (0x06bf, 0x040f), + (0x06c0, 0x044e), + (0x06c1, 0x0430), + (0x06c2, 0x0431), + (0x06c3, 0x0446), + (0x06c4, 0x0434), + (0x06c5, 0x0435), + (0x06c6, 0x0444), + (0x06c7, 0x0433), + (0x06c8, 0x0445), + (0x06c9, 0x0438), + (0x06ca, 0x0439), + (0x06cb, 0x043a), + (0x06cc, 0x043b), + (0x06cd, 0x043c), + (0x06ce, 0x043d), + (0x06cf, 0x043e), + (0x06d0, 0x043f), + (0x06d1, 0x044f), + (0x06d2, 0x0440), + (0x06d3, 0x0441), + (0x06d4, 0x0442), + (0x06d5, 0x0443), + (0x06d6, 0x0436), + (0x06d7, 0x0432), + (0x06d8, 0x044c), + (0x06d9, 0x044b), + (0x06da, 0x0437), + (0x06db, 0x0448), + (0x06dc, 0x044d), + (0x06dd, 0x0449), + (0x06de, 0x0447), + (0x06df, 0x044a), + (0x06e0, 0x042e), + (0x06e1, 0x0410), + (0x06e2, 0x0411), + (0x06e3, 0x0426), + (0x06e4, 0x0414), + (0x06e5, 0x0415), + (0x06e6, 0x0424), + (0x06e7, 0x0413), + (0x06e8, 0x0425), + (0x06e9, 0x0418), + (0x06ea, 0x0419), + (0x06eb, 0x041a), + (0x06ec, 0x041b), + (0x06ed, 0x041c), + (0x06ee, 0x041d), + (0x06ef, 0x041e), + (0x06f0, 0x041f), + (0x06f1, 0x042f), + (0x06f2, 0x0420), + (0x06f3, 0x0421), + (0x06f4, 0x0422), + (0x06f5, 0x0423), + (0x06f6, 0x0416), + (0x06f7, 0x0412), + (0x06f8, 0x042c), + (0x06f9, 0x042b), + (0x06fa, 0x0417), + (0x06fb, 0x0428), + (0x06fc, 0x042d), + (0x06fd, 0x0429), + (0x06fe, 0x0427), + (0x06ff, 0x042a), + (0x07a1, 0x0386), + (0x07a2, 0x0388), + (0x07a3, 0x0389), + (0x07a4, 0x038a), + (0x07a5, 0x03aa), + (0x07a7, 0x038c), + (0x07a8, 0x038e), + (0x07a9, 0x03ab), + (0x07ab, 0x038f), + (0x07ae, 0x0385), + (0x07af, 0x2015), + (0x07b1, 0x03ac), + (0x07b2, 0x03ad), + (0x07b3, 0x03ae), + (0x07b4, 0x03af), + (0x07b5, 0x03ca), + (0x07b6, 0x0390), + (0x07b7, 0x03cc), + (0x07b8, 0x03cd), + (0x07b9, 0x03cb), + (0x07ba, 0x03b0), + (0x07bb, 0x03ce), + (0x07c1, 0x0391), + (0x07c2, 0x0392), + (0x07c3, 0x0393), + (0x07c4, 0x0394), + (0x07c5, 0x0395), + (0x07c6, 0x0396), + (0x07c7, 0x0397), + (0x07c8, 0x0398), + (0x07c9, 0x0399), + (0x07ca, 0x039a), + (0x07cb, 0x039b), + (0x07cc, 0x039c), + (0x07cd, 0x039d), + (0x07ce, 0x039e), + (0x07cf, 0x039f), + (0x07d0, 0x03a0), + (0x07d1, 0x03a1), + (0x07d2, 0x03a3), + (0x07d4, 0x03a4), + (0x07d5, 0x03a5), + (0x07d6, 0x03a6), + (0x07d7, 0x03a7), + (0x07d8, 0x03a8), + (0x07d9, 0x03a9), + (0x07e1, 0x03b1), + (0x07e2, 0x03b2), + (0x07e3, 0x03b3), + (0x07e4, 0x03b4), + (0x07e5, 0x03b5), + (0x07e6, 0x03b6), + (0x07e7, 0x03b7), + (0x07e8, 0x03b8), + (0x07e9, 0x03b9), + (0x07ea, 0x03ba), + (0x07eb, 0x03bb), + (0x07ec, 0x03bc), + (0x07ed, 0x03bd), + (0x07ee, 0x03be), + (0x07ef, 0x03bf), + (0x07f0, 0x03c0), + (0x07f1, 0x03c1), + (0x07f2, 0x03c3), + (0x07f3, 0x03c2), + (0x07f4, 0x03c4), + (0x07f5, 0x03c5), + (0x07f6, 0x03c6), + (0x07f7, 0x03c7), + (0x07f8, 0x03c8), + (0x07f9, 0x03c9), + (0x08a1, 0x23b7), + (0x08a2, 0x250c), + (0x08a3, 0x2500), + (0x08a4, 0x2320), + (0x08a5, 0x2321), + (0x08a6, 0x2502), + (0x08a7, 0x23a1), + (0x08a8, 0x23a3), + (0x08a9, 0x23a4), + (0x08aa, 0x23a6), + (0x08ab, 0x239b), + (0x08ac, 0x239d), + (0x08ad, 0x239e), + (0x08ae, 0x23a0), + (0x08af, 0x23a8), + (0x08b0, 0x23ac), + (0x08bc, 0x2264), + (0x08bd, 0x2260), + (0x08be, 0x2265), + (0x08bf, 0x222b), + (0x08c0, 0x2234), + (0x08c1, 0x221d), + (0x08c2, 0x221e), + (0x08c5, 0x2207), + (0x08c8, 0x223c), + (0x08c9, 0x2243), + (0x08cd, 0x21d4), + (0x08ce, 0x21d2), + (0x08cf, 0x2261), + (0x08d6, 0x221a), + (0x08da, 0x2282), + (0x08db, 0x2283), + (0x08dc, 0x2229), + (0x08dd, 0x222a), + (0x08de, 0x2227), + (0x08df, 0x2228), + (0x08ef, 0x2202), + (0x08f6, 0x0192), + (0x08fb, 0x2190), + (0x08fc, 0x2191), + (0x08fd, 0x2192), + (0x08fe, 0x2193), + (0x09e0, 0x25c6), + (0x09e1, 0x2592), + (0x09e2, 0x2409), + (0x09e3, 0x240c), + (0x09e4, 0x240d), + (0x09e5, 0x240a), + (0x09e8, 0x2424), + (0x09e9, 0x240b), + (0x09ea, 0x2518), + (0x09eb, 0x2510), + (0x09ec, 0x250c), + (0x09ed, 0x2514), + (0x09ee, 0x253c), + (0x09ef, 0x23ba), + (0x09f0, 0x23bb), + (0x09f1, 0x2500), + (0x09f2, 0x23bc), + (0x09f3, 0x23bd), + (0x09f4, 0x251c), + (0x09f5, 0x2524), + (0x09f6, 0x2534), + (0x09f7, 0x252c), + (0x09f8, 0x2502), + (0x0aa1, 0x2003), + (0x0aa2, 0x2002), + (0x0aa3, 0x2004), + (0x0aa4, 0x2005), + (0x0aa5, 0x2007), + (0x0aa6, 0x2008), + (0x0aa7, 0x2009), + (0x0aa8, 0x200a), + (0x0aa9, 0x2014), + (0x0aaa, 0x2013), + (0x0aae, 0x2026), + (0x0aaf, 0x2025), + (0x0ab0, 0x2153), + (0x0ab1, 0x2154), + (0x0ab2, 0x2155), + (0x0ab3, 0x2156), + (0x0ab4, 0x2157), + (0x0ab5, 0x2158), + (0x0ab6, 0x2159), + (0x0ab7, 0x215a), + (0x0ab8, 0x2105), + (0x0abb, 0x2012), + (0x0abc, 0x2329), + (0x0abe, 0x232a), + (0x0ac3, 0x215b), + (0x0ac4, 0x215c), + (0x0ac5, 0x215d), + (0x0ac6, 0x215e), + (0x0ac9, 0x2122), + (0x0aca, 0x2613), + (0x0acc, 0x25c1), + (0x0acd, 0x25b7), + (0x0ace, 0x25cb), + (0x0acf, 0x25af), + (0x0ad0, 0x2018), + (0x0ad1, 0x2019), + (0x0ad2, 0x201c), + (0x0ad3, 0x201d), + (0x0ad4, 0x211e), + (0x0ad6, 0x2032), + (0x0ad7, 0x2033), + (0x0ad9, 0x271d), + (0x0adb, 0x25ac), + (0x0adc, 0x25c0), + (0x0add, 0x25b6), + (0x0ade, 0x25cf), + (0x0adf, 0x25ae), + (0x0ae0, 0x25e6), + (0x0ae1, 0x25ab), + (0x0ae2, 0x25ad), + (0x0ae3, 0x25b3), + (0x0ae4, 0x25bd), + (0x0ae5, 0x2606), + (0x0ae6, 0x2022), + (0x0ae7, 0x25aa), + (0x0ae8, 0x25b2), + (0x0ae9, 0x25bc), + (0x0aea, 0x261c), + (0x0aeb, 0x261e), + (0x0aec, 0x2663), + (0x0aed, 0x2666), + (0x0aee, 0x2665), + (0x0af0, 0x2720), + (0x0af1, 0x2020), + (0x0af2, 0x2021), + (0x0af3, 0x2713), + (0x0af4, 0x2717), + (0x0af5, 0x266f), + (0x0af6, 0x266d), + (0x0af7, 0x2642), + (0x0af8, 0x2640), + (0x0af9, 0x260e), + (0x0afa, 0x2315), + (0x0afb, 0x2117), + (0x0afc, 0x2038), + (0x0afd, 0x201a), + (0x0afe, 0x201e), + (0x0ba3, 0x003c), + (0x0ba6, 0x003e), + (0x0ba8, 0x2228), + (0x0ba9, 0x2227), + (0x0bc0, 0x00af), + (0x0bc2, 0x22a5), + (0x0bc3, 0x2229), + (0x0bc4, 0x230a), + (0x0bc6, 0x005f), + (0x0bca, 0x2218), + (0x0bcc, 0x2395), + (0x0bce, 0x22a4), + (0x0bcf, 0x25cb), + (0x0bd3, 0x2308), + (0x0bd6, 0x222a), + (0x0bd8, 0x2283), + (0x0bda, 0x2282), + (0x0bdc, 0x22a2), + (0x0bfc, 0x22a3), + (0x0cdf, 0x2017), + (0x0ce0, 0x05d0), + (0x0ce1, 0x05d1), + (0x0ce2, 0x05d2), + (0x0ce3, 0x05d3), + (0x0ce4, 0x05d4), + (0x0ce5, 0x05d5), + (0x0ce6, 0x05d6), + (0x0ce7, 0x05d7), + (0x0ce8, 0x05d8), + (0x0ce9, 0x05d9), + (0x0cea, 0x05da), + (0x0ceb, 0x05db), + (0x0cec, 0x05dc), + (0x0ced, 0x05dd), + (0x0cee, 0x05de), + (0x0cef, 0x05df), + (0x0cf0, 0x05e0), + (0x0cf1, 0x05e1), + (0x0cf2, 0x05e2), + (0x0cf3, 0x05e3), + (0x0cf4, 0x05e4), + (0x0cf5, 0x05e5), + (0x0cf6, 0x05e6), + (0x0cf7, 0x05e7), + (0x0cf8, 0x05e8), + (0x0cf9, 0x05e9), + (0x0cfa, 0x05ea), + (0x0da1, 0x0e01), + (0x0da2, 0x0e02), + (0x0da3, 0x0e03), + (0x0da4, 0x0e04), + (0x0da5, 0x0e05), + (0x0da6, 0x0e06), + (0x0da7, 0x0e07), + (0x0da8, 0x0e08), + (0x0da9, 0x0e09), + (0x0daa, 0x0e0a), + (0x0dab, 0x0e0b), + (0x0dac, 0x0e0c), + (0x0dad, 0x0e0d), + (0x0dae, 0x0e0e), + (0x0daf, 0x0e0f), + (0x0db0, 0x0e10), + (0x0db1, 0x0e11), + (0x0db2, 0x0e12), + (0x0db3, 0x0e13), + (0x0db4, 0x0e14), + (0x0db5, 0x0e15), + (0x0db6, 0x0e16), + (0x0db7, 0x0e17), + (0x0db8, 0x0e18), + (0x0db9, 0x0e19), + (0x0dba, 0x0e1a), + (0x0dbb, 0x0e1b), + (0x0dbc, 0x0e1c), + (0x0dbd, 0x0e1d), + (0x0dbe, 0x0e1e), + (0x0dbf, 0x0e1f), + (0x0dc0, 0x0e20), + (0x0dc1, 0x0e21), + (0x0dc2, 0x0e22), + (0x0dc3, 0x0e23), + (0x0dc4, 0x0e24), + (0x0dc5, 0x0e25), + (0x0dc6, 0x0e26), + (0x0dc7, 0x0e27), + (0x0dc8, 0x0e28), + (0x0dc9, 0x0e29), + (0x0dca, 0x0e2a), + (0x0dcb, 0x0e2b), + (0x0dcc, 0x0e2c), + (0x0dcd, 0x0e2d), + (0x0dce, 0x0e2e), + (0x0dcf, 0x0e2f), + (0x0dd0, 0x0e30), + (0x0dd1, 0x0e31), + (0x0dd2, 0x0e32), + (0x0dd3, 0x0e33), + (0x0dd4, 0x0e34), + (0x0dd5, 0x0e35), + (0x0dd6, 0x0e36), + (0x0dd7, 0x0e37), + (0x0dd8, 0x0e38), + (0x0dd9, 0x0e39), + (0x0dda, 0x0e3a), + (0x0ddf, 0x0e3f), + (0x0de0, 0x0e40), + (0x0de1, 0x0e41), + (0x0de2, 0x0e42), + (0x0de3, 0x0e43), + (0x0de4, 0x0e44), + (0x0de5, 0x0e45), + (0x0de6, 0x0e46), + (0x0de7, 0x0e47), + (0x0de8, 0x0e48), + (0x0de9, 0x0e49), + (0x0dea, 0x0e4a), + (0x0deb, 0x0e4b), + (0x0dec, 0x0e4c), + (0x0ded, 0x0e4d), + (0x0df0, 0x0e50), + (0x0df1, 0x0e51), + (0x0df2, 0x0e52), + (0x0df3, 0x0e53), + (0x0df4, 0x0e54), + (0x0df5, 0x0e55), + (0x0df6, 0x0e56), + (0x0df7, 0x0e57), + (0x0df8, 0x0e58), + (0x0df9, 0x0e59), + (0x0ea1, 0x3131), + (0x0ea2, 0x3132), + (0x0ea3, 0x3133), + (0x0ea4, 0x3134), + (0x0ea5, 0x3135), + (0x0ea6, 0x3136), + (0x0ea7, 0x3137), + (0x0ea8, 0x3138), + (0x0ea9, 0x3139), + (0x0eaa, 0x313a), + (0x0eab, 0x313b), + (0x0eac, 0x313c), + (0x0ead, 0x313d), + (0x0eae, 0x313e), + (0x0eaf, 0x313f), + (0x0eb0, 0x3140), + (0x0eb1, 0x3141), + (0x0eb2, 0x3142), + (0x0eb3, 0x3143), + (0x0eb4, 0x3144), + (0x0eb5, 0x3145), + (0x0eb6, 0x3146), + (0x0eb7, 0x3147), + (0x0eb8, 0x3148), + (0x0eb9, 0x3149), + (0x0eba, 0x314a), + (0x0ebb, 0x314b), + (0x0ebc, 0x314c), + (0x0ebd, 0x314d), + (0x0ebe, 0x314e), + (0x0ebf, 0x314f), + (0x0ec0, 0x3150), + (0x0ec1, 0x3151), + (0x0ec2, 0x3152), + (0x0ec3, 0x3153), + (0x0ec4, 0x3154), + (0x0ec5, 0x3155), + (0x0ec6, 0x3156), + (0x0ec7, 0x3157), + (0x0ec8, 0x3158), + (0x0ec9, 0x3159), + (0x0eca, 0x315a), + (0x0ecb, 0x315b), + (0x0ecc, 0x315c), + (0x0ecd, 0x315d), + (0x0ece, 0x315e), + (0x0ecf, 0x315f), + (0x0ed0, 0x3160), + (0x0ed1, 0x3161), + (0x0ed2, 0x3162), + (0x0ed3, 0x3163), + (0x0ed4, 0x11a8), + (0x0ed5, 0x11a9), + (0x0ed6, 0x11aa), + (0x0ed7, 0x11ab), + (0x0ed8, 0x11ac), + (0x0ed9, 0x11ad), + (0x0eda, 0x11ae), + (0x0edb, 0x11af), + (0x0edc, 0x11b0), + (0x0edd, 0x11b1), + (0x0ede, 0x11b2), + (0x0edf, 0x11b3), + (0x0ee0, 0x11b4), + (0x0ee1, 0x11b5), + (0x0ee2, 0x11b6), + (0x0ee3, 0x11b7), + (0x0ee4, 0x11b8), + (0x0ee5, 0x11b9), + (0x0ee6, 0x11ba), + (0x0ee7, 0x11bb), + (0x0ee8, 0x11bc), + (0x0ee9, 0x11bd), + (0x0eea, 0x11be), + (0x0eeb, 0x11bf), + (0x0eec, 0x11c0), + (0x0eed, 0x11c1), + (0x0eee, 0x11c2), + (0x0eef, 0x316d), + (0x0ef0, 0x3171), + (0x0ef1, 0x3178), + (0x0ef2, 0x317f), + (0x0ef3, 0x3181), + (0x0ef4, 0x3184), + (0x0ef5, 0x3186), + (0x0ef6, 0x318d), + (0x0ef7, 0x318e), + (0x0ef8, 0x11eb), + (0x0ef9, 0x11f0), + (0x0efa, 0x11f9), + (0x0eff, 0x20a9), + (0x13a4, 0x20ac), + (0x13bc, 0x0152), + (0x13bd, 0x0153), + (0x13be, 0x0178), + (0x20ac, 0x20ac), // Numeric keypad with numlock on - ( 0xff80 /*XKB_KEY_KP_Space*/, ' ' as u32 ), - ( 0xffaa /*XKB_KEY_KP_Multiply*/, '*' as u32 ), - ( 0xffab /*XKB_KEY_KP_Add*/, '+' as u32 ), - ( 0xffac /*XKB_KEY_KP_Separator*/, ',' as u32 ), - ( 0xffad /*XKB_KEY_KP_Subtract*/, '-' as u32 ), - ( 0xffae /*XKB_KEY_KP_Decimal*/, '.' as u32 ), - ( 0xffaf /*XKB_KEY_KP_Divide*/, '/' as u32 ), - ( 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 ), - ( 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 ), - ( 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 ), - ( 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 ), - ( 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 ), - ( 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 ), - ( 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 ), - ( 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 ), - ( 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 ), - ( 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 ), - ( 0xffbd /*XKB_KEY_KP_Equal*/, '=' as u32 ), + (0xff80 /*XKB_KEY_KP_Space*/, ' ' as u32), + (0xffaa /*XKB_KEY_KP_Multiply*/, '*' as u32), + (0xffab /*XKB_KEY_KP_Add*/, '+' as u32), + (0xffac /*XKB_KEY_KP_Separator*/, ',' as u32), + (0xffad /*XKB_KEY_KP_Subtract*/, '-' as u32), + (0xffae /*XKB_KEY_KP_Decimal*/, '.' as u32), + (0xffaf /*XKB_KEY_KP_Divide*/, '/' as u32), + (0xffb0 /*XKB_KEY_KP_0*/, 0x0030), + (0xffb1 /*XKB_KEY_KP_1*/, 0x0031), + (0xffb2 /*XKB_KEY_KP_2*/, 0x0032), + (0xffb3 /*XKB_KEY_KP_3*/, 0x0033), + (0xffb4 /*XKB_KEY_KP_4*/, 0x0034), + (0xffb5 /*XKB_KEY_KP_5*/, 0x0035), + (0xffb6 /*XKB_KEY_KP_6*/, 0x0036), + (0xffb7 /*XKB_KEY_KP_7*/, 0x0037), + (0xffb8 /*XKB_KEY_KP_8*/, 0x0038), + (0xffb9 /*XKB_KEY_KP_9*/, 0x0039), + (0xffbd /*XKB_KEY_KP_Equal*/, '=' as u32), ]; - fn binary_search(value: u32, min: isize, max: isize) -> Option { if max >= min { - let mid = (min + max) / 2; + let mid = (min + max) / 2; let pair = keysymtab[mid as usize]; if pair.0 == value { @@ -871,12 +868,9 @@ fn binary_search(value: u32, min: isize, max: isize) -> Option { } } - pub fn keysym_to_unicode(keysym: u32) -> Option { // First check for Latin-1 characters (1:1 mapping) - if (keysym >= 0x0020 && keysym <= 0x007e) || - (keysym >= 0x00a0 && keysym <= 0x00ff) - { + if (keysym >= 0x0020 && keysym <= 0x007e) || (keysym >= 0x00a0 && keysym <= 0x00ff) { return Some(keysym); } @@ -889,19 +883,18 @@ pub fn keysym_to_unicode(keysym: u32) -> Option { binary_search(keysym, 0, (LENGTH - 1) as isize) } - #[allow(dead_code)] pub fn test_it() { assert_eq!(keysym_to_unicode('1' as u32), Some('1' as u32)); assert_eq!(keysym_to_unicode('a' as u32), Some('a' as u32)); - assert_eq!(keysym_to_unicode( 127), None); - assert_eq!(keysym_to_unicode( 0x123), None); + assert_eq!(keysym_to_unicode(127), None); + assert_eq!(keysym_to_unicode(0x123), None); assert_eq!(keysym_to_unicode(0xfffe), None); // check table is sorted - for k in 0..LENGTH-1 { - assert!(keysymtab[k+1].0 > keysymtab[k].0); + for k in 0..LENGTH - 1 { + assert!(keysymtab[k + 1].0 > keysymtab[k].0); } // check ability to find every value in the table @@ -909,4 +902,3 @@ pub fn test_it() { assert_eq!(keysym_to_unicode(p.0), Some(p.1)); } } - diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index 00f37ad..eaad05a 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -178,9 +178,7 @@ impl DisplayInfo { fn load_cursor(&mut self, name: &'static str) -> xlib::Cursor { let name = CString::new(name).expect("static data"); - unsafe { - (self.cursor_lib.XcursorLibraryLoadCursor)(self.display, name.as_ptr()) - } + unsafe { (self.cursor_lib.XcursorLibraryLoadCursor)(self.display, name.as_ptr()) } } fn init_atoms(&mut self) { @@ -259,7 +257,8 @@ impl Window { let mut d = DisplayInfo::new()?; - let scale = Self::get_scale_factor(width, height, d.screen_width, d.screen_height, opts.scale); + let scale = + Self::get_scale_factor(width, height, d.screen_width, d.screen_height, opts.scale); let width = width * scale; let height = height * scale; @@ -274,8 +273,16 @@ impl Window { attributes.backing_store = xlib::NotUseful; - let x = if d.screen_width > width { (d.screen_width - width) / 2 } else { 0 }; - let y = if d.screen_height > height { (d.screen_height - height) / 2 } else { 0 }; + let x = if d.screen_width > width { + (d.screen_width - width) / 2 + } else { + 0 + }; + let y = if d.screen_height > height { + (d.screen_height - height) / 2 + } else { + 0 + }; let handle = (d.lib.XCreateWindow)( d.display, @@ -363,7 +370,12 @@ impl Window { } } - unsafe fn alloc_image(d: &DisplayInfo, width: usize, height: usize, draw_buffer: &mut Vec) -> Option<*mut xlib::XImage> { + unsafe fn alloc_image( + d: &DisplayInfo, + width: usize, + height: usize, + draw_buffer: &mut Vec, + ) -> Option<*mut xlib::XImage> { let bytes_per_line = (width as i32) * 4; draw_buffer.resize(width * height, 0); @@ -550,7 +562,13 @@ impl Window { true } - fn get_scale_factor(width: usize, height: usize, screen_width: usize, screen_height: usize, scale: Scale) -> usize { + fn get_scale_factor( + width: usize, + height: usize, + screen_width: usize, + screen_height: usize, + scale: Scale, + ) -> usize { match scale { Scale::X1 => 1, Scale::X2 => 2, @@ -743,7 +761,9 @@ impl Window { &self.d, cast::usize(self.width), cast::usize(self.height), - &mut self.draw_buffer).expect("todo"); + &mut self.draw_buffer, + ) + .expect("todo"); } _ => {} @@ -997,13 +1017,7 @@ macro_rules! gen_scale_x( ) ); -gen_scale_x!( - scale_2x, 2, - scale_4x, 4, - scale_8x, 8, - scale_16x, 16, - scale_32x, 32, -); +gen_scale_x!(scale_2x, 2, scale_4x, 4, scale_8x, 8, scale_16x, 16, scale_32x, 32,); impl Drop for Window { fn drop(&mut self) { diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index 93eb36f..727508e 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -1,33 +1,33 @@ #![cfg(target_os = "windows")] -extern crate winapi; extern crate time; +extern crate winapi; const INVALID_ACCEL: usize = 0xffffffff; -use {Scale, Key, KeyRepeat, MouseButton, MouseMode, WindowOptions, InputCallback}; -use key_handler::KeyHandler; use error::Error; +use key_handler::KeyHandler; use Result; -use {CursorStyle, MenuItem, MenuItemHandle, MenuHandle}; -use {MENU_KEY_WIN, MENU_KEY_SHIFT, MENU_KEY_CTRL, MENU_KEY_ALT}; +use {CursorStyle, MenuHandle, MenuItem, MenuItemHandle}; +use {InputCallback, Key, KeyRepeat, MouseButton, MouseMode, Scale, WindowOptions}; +use {MENU_KEY_ALT, MENU_KEY_CTRL, MENU_KEY_SHIFT, MENU_KEY_WIN}; -use std::ptr; -use std::os::windows::ffi::OsStrExt; +use buffer_helper; +use mouse_handler; use std::ffi::OsStr; use std::mem; use std::os::raw; -use mouse_handler; -use buffer_helper; +use std::os::windows::ffi::OsStrExt; +use std::ptr; use self::winapi::shared::basetsd; -use self::winapi::um::winuser; use self::winapi::shared::minwindef; -use self::winapi::shared::windef; -use self::winapi::um::wingdi; use self::winapi::shared::ntdef; -use self::winapi::um::libloaderapi; +use self::winapi::shared::windef; use self::winapi::um::errhandlingapi; +use self::winapi::um::libloaderapi; +use self::winapi::um::wingdi; +use self::winapi::um::winuser; // Wrap this so we can have a proper numbef of bmiColors to write in #[repr(C)] @@ -167,11 +167,12 @@ unsafe fn get_window_long(window: windef::HWND) -> ntdef::LONG { winuser::GetWindowLongW(window, winuser::GWLP_USERDATA) } -unsafe extern "system" fn wnd_proc(window: windef::HWND, - msg: minwindef::UINT, - wparam: minwindef::WPARAM, - lparam: minwindef::LPARAM) - -> minwindef::LRESULT { +unsafe extern "system" fn wnd_proc( + window: windef::HWND, + msg: minwindef::UINT, + wparam: minwindef::WPARAM, + lparam: minwindef::LPARAM, +) -> minwindef::LRESULT { // This make sure we actually don't do anything before the user data has been setup for the // window @@ -212,29 +213,17 @@ unsafe extern "system" fn wnd_proc(window: windef::HWND, char_down(wnd, wparam as u32); } - winuser::WM_LBUTTONDOWN => { - wnd.mouse.state[0] = true - } + winuser::WM_LBUTTONDOWN => wnd.mouse.state[0] = true, - winuser::WM_LBUTTONUP => { - wnd.mouse.state[0] = false - } + winuser::WM_LBUTTONUP => wnd.mouse.state[0] = false, - winuser::WM_MBUTTONDOWN => { - wnd.mouse.state[1] = true - } + winuser::WM_MBUTTONDOWN => wnd.mouse.state[1] = true, - winuser::WM_MBUTTONUP => { - wnd.mouse.state[1] = false - } + winuser::WM_MBUTTONUP => wnd.mouse.state[1] = false, - winuser::WM_RBUTTONDOWN => { - wnd.mouse.state[2] = true - } + winuser::WM_RBUTTONDOWN => wnd.mouse.state[2] = true, - winuser::WM_RBUTTONUP => { - wnd.mouse.state[2] = false - } + winuser::WM_RBUTTONUP => wnd.mouse.state[2] = false, winuser::WM_CLOSE => { wnd.is_open = false; @@ -259,7 +248,6 @@ unsafe extern "system" fn wnd_proc(window: windef::HWND, } winuser::WM_PAINT => { - // if we have nothing to draw here we return the default function if wnd.buffer.len() == 0 { return winuser::DefWindowProcW(window, msg, wparam, lparam); @@ -277,19 +265,21 @@ unsafe extern "system" fn wnd_proc(window: windef::HWND, bitmap_info.bmi_colors[1].rgbGreen = 0xff; bitmap_info.bmi_colors[2].rgbBlue = 0xff; - wingdi::StretchDIBits(wnd.dc.unwrap(), - 0, - 0, - wnd.width * wnd.scale_factor, - wnd.height * wnd.scale_factor, - 0, - 0, - wnd.width, - wnd.height, - mem::transmute(wnd.buffer.as_ptr()), - mem::transmute(&bitmap_info), - wingdi::DIB_RGB_COLORS, - wingdi::SRCCOPY); + wingdi::StretchDIBits( + wnd.dc.unwrap(), + 0, + 0, + wnd.width * wnd.scale_factor, + wnd.height * wnd.scale_factor, + 0, + 0, + wnd.width, + wnd.height, + mem::transmute(wnd.buffer.as_ptr()), + mem::transmute(&bitmap_info), + wingdi::DIB_RGB_COLORS, + wingdi::SRCCOPY, + ); winuser::ValidateRect(window, ptr::null_mut()); @@ -307,7 +297,10 @@ pub enum MinifbError { } fn to_wstring(str: &str) -> Vec { - let v: Vec = OsStr::new(str).encode_wide().chain(Some(0).into_iter()).collect(); + let v: Vec = OsStr::new(str) + .encode_wide() + .chain(Some(0).into_iter()) + .collect(); v } @@ -332,7 +325,7 @@ pub struct Window { dc: Option, window: Option, buffer: Vec, - is_open : bool, + is_open: bool, scale_factor: i32, width: i32, height: i32, @@ -353,7 +346,13 @@ pub struct Window { // } impl Window { - fn open_window(name: &str, width: usize, height: usize, opts: WindowOptions, scale_factor: i32) -> Option { + fn open_window( + name: &str, + width: usize, + height: usize, + opts: WindowOptions, + scale_factor: i32, + ) -> Option { unsafe { let class_name = to_wstring("minifb_window"); let class = winuser::WNDCLASSW { @@ -372,7 +371,10 @@ impl Window { if winuser::RegisterClassW(&class) == 0 { // ignore the "Class already exists" error for multiple windows if errhandlingapi::GetLastError() as u32 != 1410 { - println!("Unable to register class, error {}", errhandlingapi::GetLastError() as u32); + println!( + "Unable to register class, error {}", + errhandlingapi::GetLastError() as u32 + ); return None; } } @@ -387,9 +389,11 @@ impl Window { bottom: new_height as ntdef::LONG, }; - winuser::AdjustWindowRect(&mut rect, - winuser::WS_POPUP | winuser::WS_SYSMENU | winuser::WS_CAPTION, - 0); + winuser::AdjustWindowRect( + &mut rect, + winuser::WS_POPUP | winuser::WS_SYSMENU | winuser::WS_CAPTION, + 0, + ); rect.right -= rect.left; rect.bottom -= rect.top; @@ -403,8 +407,7 @@ impl Window { } if opts.resize { - flags |= winuser::WS_THICKFRAME as u32 | winuser::WS_MAXIMIZEBOX as u32 ; - + flags |= winuser::WS_THICKFRAME as u32 | winuser::WS_MAXIMIZEBOX as u32; } else { flags &= !winuser::WS_MAXIMIZEBOX; flags &= !winuser::WS_THICKFRAME; @@ -414,20 +417,25 @@ impl Window { flags &= !winuser::WS_THICKFRAME; } - let handle = winuser::CreateWindowExW(0, - class_name.as_ptr(), - window_name.as_ptr(), - flags, - winuser::CW_USEDEFAULT, - winuser::CW_USEDEFAULT, - rect.right, - rect.bottom, - ptr::null_mut(), - ptr::null_mut(), - ptr::null_mut(), - ptr::null_mut()); + let handle = winuser::CreateWindowExW( + 0, + class_name.as_ptr(), + window_name.as_ptr(), + flags, + winuser::CW_USEDEFAULT, + winuser::CW_USEDEFAULT, + rect.right, + rect.bottom, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + ); if handle.is_null() { - println!("Unable to create window, error {}", errhandlingapi::GetLastError() as u32); + println!( + "Unable to create window, error {}", + errhandlingapi::GetLastError() as u32 + ); return None; } @@ -437,11 +445,7 @@ impl Window { } } - pub fn new(name: &str, - width: usize, - height: usize, - opts: WindowOptions) - -> Result { + pub fn new(name: &str, width: usize, height: usize, opts: WindowOptions) -> Result { unsafe { let scale_factor = Self::get_scale_factor(width, height, opts.scale); @@ -497,8 +501,15 @@ impl Window { #[inline] pub fn set_position(&mut self, x: isize, y: isize) { unsafe { - winuser::SetWindowPos(self.window.unwrap(), ptr::null_mut(), x as i32, y as i32, - 0, 0, winuser::SWP_SHOWWINDOW | winuser::SWP_NOSIZE); + winuser::SetWindowPos( + self.window.unwrap(), + ptr::null_mut(), + x as i32, + y as i32, + 0, + 0, + winuser::SWP_SHOWWINDOW | winuser::SWP_NOSIZE, + ); } } @@ -570,7 +581,7 @@ impl Window { } #[inline] - pub fn set_input_callback(&mut self, callback: Box) { + pub fn set_input_callback(&mut self, callback: Box) { self.key_handler.set_input_callback(callback) } @@ -596,7 +607,7 @@ impl Window { #[inline] pub fn is_open(&self) -> bool { - return self.is_open + return self.is_open; } fn generic_update(&mut self, window: windef::HWND) { @@ -625,7 +636,12 @@ impl Window { winuser::TranslateMessage(&mut msg); winuser::DispatchMessageW(&mut msg); } else { - if winuser::TranslateAcceleratorW(msg.hwnd, mem::transmute(self.accel_table), &mut msg) == 0 { + if winuser::TranslateAcceleratorW( + msg.hwnd, + mem::transmute(self.accel_table), + &mut msg, + ) == 0 + { winuser::TranslateMessage(&mut msg); winuser::DispatchMessageW(&mut msg); } @@ -639,10 +655,12 @@ impl Window { Self::generic_update(self, window); - let check_res = buffer_helper::check_buffer_size(self.width as usize, - self.height as usize, - self.scale_factor as usize, - buffer); + let check_res = buffer_helper::check_buffer_size( + self.width as usize, + self.height as usize, + self.scale_factor as usize, + buffer, + ); if check_res.is_err() { return check_res; } @@ -712,12 +730,14 @@ impl Window { let menu_height = winuser::GetSystemMetrics(winuser::SM_CYMENU); winuser::GetWindowRect(handle, &mut rect); - winuser::MoveWindow(handle, - rect.left, - rect.top, - rect.right - rect.left, - (rect.bottom - rect.top) + menu_height, - 1); + winuser::MoveWindow( + handle, + rect.left, + rect.top, + rect.right - rect.left, + (rect.bottom - rect.top) + menu_height, + 1, + ); } unsafe fn set_accel_table(&mut self) { @@ -734,13 +754,14 @@ impl Window { winuser::DestroyAcceleratorTable(self.accel_table); } - self.accel_table = winuser::CreateAcceleratorTableW(temp_accel_table.as_mut_ptr(), - temp_accel_table.len() as i32); + self.accel_table = winuser::CreateAcceleratorTableW( + temp_accel_table.as_mut_ptr(), + temp_accel_table.len() as i32, + ); println!("accel {:?}", self.accel_table); } - pub fn add_menu(&mut self, menu: &Menu) -> MenuHandle { unsafe { let window = self.window.unwrap(); @@ -752,10 +773,12 @@ impl Window { Self::adjust_window_size_for_menu(window); } - winuser::AppendMenuW(main_menu, - 0x10, - menu.menu_handle as basetsd::UINT_PTR, - menu.name.as_ptr()); + winuser::AppendMenuW( + main_menu, + 0x10, + menu.menu_handle as basetsd::UINT_PTR, + menu.name.as_ptr(), + ); self.menus.push(menu.clone()); // TODO: Setup accel table @@ -932,15 +955,17 @@ impl Menu { pub fn add_sub_menu(&mut self, name: &str, menu: &Menu) { unsafe { let menu_name = to_wstring(name); - winuser::AppendMenuW(self.menu_handle, - 0x10, - menu.menu_handle as basetsd::UINT_PTR, - menu_name.as_ptr()); - self.accel_table.extend_from_slice(menu.accel_table.as_slice()); + winuser::AppendMenuW( + self.menu_handle, + 0x10, + menu.menu_handle as basetsd::UINT_PTR, + menu_name.as_ptr(), + ); + self.accel_table + .extend_from_slice(menu.accel_table.as_slice()); } } - fn format_name(menu_item: &MenuItem, key_name: &'static str) -> String { let mut name = menu_item.label.clone(); @@ -1004,7 +1029,8 @@ impl Menu { let accel = winuser::ACCEL { fVirt: virt as minwindef::BYTE, cmd: menu_item.id as minwindef::WORD, - key: vk_accel.0 as minwindef::WORD }; + key: vk_accel.0 as minwindef::WORD, + }; self.accel_table.push(accel); } @@ -1016,12 +1042,22 @@ impl Menu { match vk_accel.0 { 0 => { let item_name = to_wstring(&menu_item.label); - winuser::AppendMenuW(self.menu_handle, 0x10, menu_item.id as basetsd::UINT_PTR, item_name.as_ptr()); - }, + winuser::AppendMenuW( + self.menu_handle, + 0x10, + menu_item.id as basetsd::UINT_PTR, + item_name.as_ptr(), + ); + } _ => { let menu_name = Self::format_name(menu_item, vk_accel.1); let w_name = to_wstring(&menu_name); - winuser::AppendMenuW(self.menu_handle, 0x10, menu_item.id as basetsd::UINT_PTR, w_name.as_ptr()); + winuser::AppendMenuW( + self.menu_handle, + 0x10, + menu_item.id as basetsd::UINT_PTR, + w_name.as_ptr(), + ); self.add_accel(vk_accel.0, menu_item); } } @@ -1039,7 +1075,6 @@ impl Menu { } } - impl Drop for Window { fn drop(&mut self) { unsafe { diff --git a/src/window_flags.rs b/src/window_flags.rs index 7ef59a4..4235133 100644 --- a/src/window_flags.rs +++ b/src/window_flags.rs @@ -1,9 +1,9 @@ #[allow(dead_code)] -const WINDOW_BORDERLESS: u32 = 1 << 1; +const WINDOW_BORDERLESS: u32 = 1 << 1; #[allow(dead_code)] -const WINDOW_RESIZE: u32 = 1 << 2; +const WINDOW_RESIZE: u32 = 1 << 2; #[allow(dead_code)] -const WINDOW_TITLE: u32 = 1 << 3; +const WINDOW_TITLE: u32 = 1 << 3; use WindowOptions;