#![allow(clippy::upper_case_acronyms)]
use crate::{
Origin,
shims::{ncurses, npanels, constants::OK},
panels::{NCurseswPanelsError, PanelUserPtr}
};
type WINDOW = ncurses::WINDOW;
type SCREEN = *mut crate::shims::bindings::SCREEN;
pub type PANEL = npanels::PANEL;
pub fn new_panel(window: WINDOW) -> panels_result!(PANEL) {
unsafe { npanels::new_panel(window).ok_or(panels_function_error!("new_panel")) }
}
pub fn bottom_panel(panel: PANEL) -> panels_result!(()) {
match unsafe { npanels::bottom_panel(panel) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("bottom_panel", rc))
}
}
pub fn top_panel(panel: PANEL) -> panels_result!(()) {
match unsafe { npanels::top_panel(panel) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("top_panel", rc))
}
}
pub fn show_panel(panel: PANEL) -> panels_result!(()) {
match unsafe { npanels::show_panel(panel) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("show_panel", rc))
}
}
pub fn update_panels() {
npanels::update_panels();
}
pub fn hide_panel(panel: PANEL) -> panels_result!(()) {
match unsafe { npanels::hide_panel(panel) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("hide_panel", rc))
}
}
pub fn panel_window(panel: PANEL) -> panels_result!(WINDOW) {
unsafe { npanels::panel_window(panel).ok_or(panels_function_error!("panel_window")) }
}
pub fn replace_panel(panel: PANEL, window: WINDOW) -> panels_result!(()) {
match unsafe { npanels::replace_panel(panel, window) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("replace_panel", rc))
}
}
pub fn move_panel(panel: PANEL, origin: Origin) -> panels_result!(()) {
match unsafe { npanels::move_panel(panel, origin.y, origin.x) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("move_panel", rc))
}
}
pub fn panel_hidden(panel: PANEL) -> panels_result!(bool) {
unsafe { npanels::panel_hidden(panel).ok_or(panels_function_error!("panel_hidden")) }
}
pub fn panel_above(panel: Option<PANEL>) -> panels_result!(PANEL) {
unsafe { npanels::panel_above(panel).ok_or(panels_function_error!("panel_above")) }
}
pub fn panel_below(panel: Option<PANEL>) -> panels_result!(PANEL) {
unsafe { npanels::panel_below(panel).ok_or(panels_function_error!("panel_below")) }
}
pub fn set_panel_userptr(panel: PANEL, userptr: PanelUserPtr) -> panels_result!(()) {
match unsafe { npanels::set_panel_userptr(panel, userptr) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("set_panel_userptr", rc))
}
}
pub fn panel_userptr(panel: PANEL) -> PanelUserPtr {
unsafe { npanels::panel_userptr(panel) }
}
pub fn del_panel(panel: PANEL) -> panels_result!(()) {
match unsafe { npanels::del_panel(panel) } {
OK => Ok(()),
rc => Err(panels_function_error_with_rc!("del_panel", rc))
}
}
pub fn ceiling_panel(screen: SCREEN) -> panels_result!(PANEL) {
unsafe { npanels::ceiling_panel(screen).ok_or(panels_function_error!("ceiling_panel")) }
}
pub fn ground_panel(screen: SCREEN) -> panels_result!(PANEL) {
unsafe { npanels::ground_panel(screen).ok_or(panels_function_error!("ground_panel")) }
}
pub fn update_panels_sp(screen: SCREEN) {
unsafe { npanels::update_panels_sp(screen) }
}