Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for latest Rust #157

Merged
merged 1 commit into from
May 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ window_callback!(fn window_refresh_callback()
window_callback!(fn window_focus_callback(focused: c_int) => FocusEvent(focused == ffi::TRUE))
window_callback!(fn window_iconify_callback(iconified: c_int) => IconifyEvent(iconified == ffi::TRUE))
window_callback!(fn framebuffer_size_callback(width: c_int, height: c_int) => FramebufferSizeEvent(width as i32, height as i32))
window_callback!(fn mouse_button_callback(button: c_int, action: c_int, mods: c_int) => MouseButtonEvent(mem::transmute(button), mem::transmute(action), Modifiers::from_bits(mods)))
window_callback!(fn mouse_button_callback(button: c_int, action: c_int, mods: c_int) => MouseButtonEvent(mem::transmute(button), mem::transmute(action), Modifiers::from_bits(mods).unwrap()))
window_callback!(fn cursor_pos_callback(xpos: c_double, ypos: c_double) => CursorPosEvent(xpos as f64, ypos as f64))
window_callback!(fn cursor_enter_callback(entered: c_int) => CursorEnterEvent(entered == ffi::TRUE))
window_callback!(fn scroll_callback(xpos: c_double, ypos: c_double) => ScrollEvent(xpos as f64, ypos as f64))
window_callback!(fn key_callback(key: c_int, scancode: c_int, action: c_int, mods: c_int) => KeyEvent(mem::transmute(key), scancode, mem::transmute(action), Modifiers::from_bits(mods)))
window_callback!(fn key_callback(key: c_int, scancode: c_int, action: c_int, mods: c_int) => KeyEvent(mem::transmute(key), scancode, mem::transmute(action), Modifiers::from_bits(mods).unwrap()))
window_callback!(fn char_callback(character: c_uint) => CharEvent(::std::char::from_u32(character).unwrap()))
20 changes: 10 additions & 10 deletions src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ impl fmt::Show for ShowAliases<MouseButton> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ShowAliases(button) = *self;
match button {
MouseButtonLeft => write!(f.buf, "MouseButtonLeft"),
MouseButtonRight => write!(f.buf, "MouseButtonRight"),
MouseButtonMiddle => write!(f.buf, "MouseButtonMiddle"),
MouseButtonLeft => write!(f, "MouseButtonLeft"),
MouseButtonRight => write!(f, "MouseButtonRight"),
MouseButtonMiddle => write!(f, "MouseButtonMiddle"),
button => button.fmt(f),
}
}
Expand Down Expand Up @@ -852,7 +852,7 @@ impl fmt::Show for VidMode {
/// ~"[width] x [height], [total_bits] ([red_bits] [green_bits] [blue_bits]) [refresh_rate] Hz"
/// ~~~
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{} x {}, {} = {} + {} + {}, {} Hz",
write!(f, "{} x {}, {} = {} + {} + {}, {} Hz",
self.width, self.height,
self.red_bits + self.green_bits + self.blue_bits,
self.red_bits, self.green_bits, self.blue_bits,
Expand Down Expand Up @@ -1017,12 +1017,12 @@ bitflags! {
impl fmt::Show for Modifiers {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (i, x) in [Shift, Control, Alt, Super].iter().filter(|x| self.contains(**x)).enumerate() {
if i != 0 { try!(write!(f.buf, ", ")) };
if *x == Shift { try!(write!(f.buf, "Shift" )) }
else if *x == Control { try!(write!(f.buf, "Control" )) }
else if *x == Alt { try!(write!(f.buf, "Alt" )) }
else if *x == Super { try!(write!(f.buf, "Super" )) }
else { try!(write!(f.buf, "???" )) }
if i != 0 { try!(write!(f, ", ")) };
if *x == Shift { try!(write!(f, "Shift" )) }
else if *x == Control { try!(write!(f, "Control" )) }
else if *x == Alt { try!(write!(f, "Alt" )) }
else if *x == Super { try!(write!(f, "Super" )) }
else { try!(write!(f, "???" )) }
}
Ok(())
}
Expand Down