#![macro_use]
macro_rules! result { ($type: ty) => { Result<$type, NCurseswError> } }
macro_rules! panels_result { ($type: ty) => { Result<$type, NCurseswPanelsError> } }
macro_rules! mouse_result { ($type: ty) => { Result<$type, NCurseswMouseError> } }
macro_rules! menu_result { ($type: ty) => { Result<$type, NCurseswMenuError> } }
macro_rules! form_result { ($type: ty) => { Result<$type, NCurseswFormError> } }
macro_rules! ncurses_function_error { ($func: expr) => { NCurseswError::LibraryError { func: String::from($func), rc: None } } }
macro_rules! ncurses_function_error_with_rc { ($func: expr, $rc: expr) => { NCurseswError::LibraryError { func: String::from($func), rc: Some($rc) } } }
macro_rules! ncurses_os_error { ($func: expr) => { NCurseswError::OSError { func: String::from($func), errno: errno::errno() } } }
macro_rules! panels_function_error { ($func: expr) => { NCurseswPanelsError::LibraryError { func: String::from($func), rc: None } } }
macro_rules! panels_function_error_with_rc { ($func: expr, $rc: expr) => { NCurseswPanelsError::LibraryError { func: String::from($func), rc: Some($rc) } } }
macro_rules! mouse_function_error { ($func: expr) => { NCurseswMouseError::LibraryError { func: String::from($func), rc: None } } }
macro_rules! mouse_function_error_with_rc { ($func: expr, $rc: expr) => { NCurseswMouseError::LibraryError { func: String::from($func), rc: Some($rc) } } }
macro_rules! menu_function_error { ($func: expr) => { ncursesw_menu_error_system_error($func) } }
macro_rules! menu_function_error_with_rc { ($func: expr, $rc: expr) => { ncursesw_menu_error_from_rc($func, $rc) } }
macro_rules! menu_function_unknown_error { ($func: expr, $rc: expr) => { NCurseswMenuError::UnknownError { func: String::from($func), errno: $rc } } }
macro_rules! form_function_error { ($func: expr) => { ncursesw_form_error_system_error($func) } }
macro_rules! form_function_error_with_rc { ($func: expr, $rc: expr) => { ncursesw_form_error_from_rc($func, $rc) } }
macro_rules! form_function_unknown_error { ($func: expr, $rc: expr) => { NCurseswFormError::UnknownError { func: String::from($func), errno: $rc } } }
macro_rules! wrap_const { ($name: ident : $type: ty) => { pub const $name: $type = bindings::$name as $type; } }
macro_rules! c_str_with_nul { ($name: ident) => { &*($name.to_c_str()?.as_bytes_with_nul() as *const [u8] as *const [i8]) } }
macro_rules! raw_with_nul_as_slice { ($name: ident) => { $name.clone().raw_with_nul().as_slice() } }
macro_rules! ptr_as_string { ($ptr: ident) => { std::str::from_utf8_unchecked(CStr::from_ptr($ptr).to_bytes()).to_owned() } }
macro_rules! option_str_as_ptr { ($name: ident) => { $name.map_or_else(std::ptr::null, |name| name.as_ptr()) as *const i8 } }
macro_rules! return_mut_ptr { ($ptr: ident) => { $ptr.unwrap_or(std::ptr::null_mut()) } }
macro_rules! option_getter {
($func: ident, $attr: ident) => {
pub fn $func(&self) -> bool {
(self.raw & constants::$attr) > 0
}
};
}
macro_rules! option_setter {
($func: ident, $attr: ident) => {
pub fn $func(&self, enabled: bool) -> Self {
Self { raw: if enabled {
self.raw | constants::$attr
} else {
self.raw ^ constants::$attr
}}
}
};
}