#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
use crate::{bindings, shims};
type WINDOW = shims::ncurses::WINDOW;
type SCREEN = shims::ncurses::SCREEN;
pub type mmask_t = bindings::mmask_t;
pub type MEVENT = *mut bindings::MEVENT;
static MODULE_PATH: &str = "ncursesw::shims::nmouse::";
pub unsafe fn getmouse(event: MEVENT) -> i32 {
assert!(!event.is_null(), "{}getmouse() : event.is_null()", MODULE_PATH);
bindings::getmouse(event)
}
pub fn has_mouse() -> bool {
unsafe { bindings::has_mouse() }
}
pub unsafe fn mouse_trafo(py: *mut i32, px: *mut i32, to_screen: bool) -> bool {
assert!(!py.is_null(), "{}mouse_trafo : py.is_null()", MODULE_PATH);
assert!(!px.is_null(), "{}mouse_trafo : px.is_null()", MODULE_PATH);
bindings::mouse_trafo(py, px, to_screen)
}
pub fn mouseinterval(erval: i32) -> i32 {
assert!(erval >= -1, "{}mouseinterval() : erval = {}", MODULE_PATH, erval);
unsafe { bindings::mouseinterval(erval) }
}
pub unsafe fn mousemask(newmask: mmask_t, oldmask: Option<*mut mmask_t>) -> mmask_t {
assert!(oldmask.map_or_else(|| true, |oldmask| !oldmask.is_null()), "{}mousemask() : oldmask.is_null()", MODULE_PATH);
bindings::mousemask(newmask, return_mut_ptr!(oldmask))
}
pub unsafe fn ungetmouse(event: MEVENT) -> i32 {
assert!(!event.is_null(), "{}ungetmouse() : event.is_null()", MODULE_PATH);
bindings::ungetmouse(event)
}
pub unsafe fn wenclose(win: WINDOW, y: i32, x: i32) -> bool {
assert!(!win.is_null(), "{}wenclose() : win.is_null()", MODULE_PATH);
assert!(y >= 0, "{}wenclose() : y = {}", MODULE_PATH, y);
assert!(x >= 0, "{}wenclose() : x = {}", MODULE_PATH, x);
bindings::wenclose(win, y, x)
}
pub unsafe fn wmouse_trafo(win: WINDOW, py: *mut i32, px: *mut i32, to_screen: bool) -> bool {
assert!(!win.is_null(), "{}wmouse_trafo() : win.is_null()", MODULE_PATH);
assert!(!py.is_null(), "{}wmouse_trafo : py.is_null()", MODULE_PATH);
assert!(!px.is_null(), "{}wmouse_trafo : px.is_null()", MODULE_PATH);
bindings::wmouse_trafo(win, py, px, to_screen)
}
pub unsafe fn getmouse_sp(sp: SCREEN, event: MEVENT) -> i32 {
assert!(!sp.is_null(), "{}getmouse_sp() : sp.is_null()", MODULE_PATH);
assert!(!event.is_null(), "{}getmouse_sp() : event.is_null()", MODULE_PATH);
bindings::getmouse_sp(sp, event)
}
pub unsafe fn has_mouse_sp(sp: SCREEN) -> bool {
assert!(!sp.is_null(), "{}has_mouse_sp() : sp.is_null()", MODULE_PATH);
bindings::has_mouse_sp(sp)
}
pub unsafe fn mouseinterval_sp(sp: SCREEN, erval: i32) -> i32 {
assert!(!sp.is_null(), "{}mouseinterval_sp() : sp.is_null()", MODULE_PATH);
assert!(erval >= -1, "{}mouseinterval_sp() : erval = {}", MODULE_PATH, erval);
bindings::mouseinterval_sp(sp, erval)
}
pub unsafe fn mousemask_sp(sp: SCREEN, newmask: mmask_t, oldmask: Option<*mut mmask_t>) -> mmask_t {
assert!(!sp.is_null(), "{}mousemask_sp() : sp.is_null()", MODULE_PATH);
assert!(oldmask.map_or_else(|| true, |oldmask| !oldmask.is_null()), "{}mousemask_sp() : oldmask.is_null()", MODULE_PATH);
bindings::mousemask_sp(sp, newmask, return_mut_ptr!(oldmask))
}
pub unsafe fn ungetmouse_sp(sp: SCREEN, event: MEVENT) -> i32 {
assert!(!sp.is_null(), "{}ungetmouse_sp() : sp.is_null()", MODULE_PATH);
assert!(!event.is_null(), "{}ungetmouse_sp() : event.is_null()", MODULE_PATH);
bindings::ungetmouse_sp(sp, event)
}