#![allow(deprecated)]
use std::convert::TryFrom;
use ncursesw::{CharacterResult, WideChar, WideString, WINDOW};
use crate::{NonBlockingResult, Timeout, NCurseswWinError, gen::{HasHandle, HasNonBlocking}};
pub trait HasGetFunctions: HasHandle<WINDOW> + HasNonBlocking {
fn getch(&self) -> result!(CharacterResult<char>) {
Ok(ncursesw::wgetch(self._handle())?)
}
fn getnstr(&self, length: u16) -> result!(String) {
Ok(ncursesw::wgetnstr(self._handle(), i32::try_from(length)?)?)
}
fn getn_wstr(&self, length: u16) -> result!(WideString) {
Ok(ncursesw::wgetn_wstr(self._handle(), i32::try_from(length)?)?)
}
#[deprecated(since = "0.1.1", note = "underlying native function can cause issues. Use getnstr() instead")]
fn getstr(&self) -> result!(String) {
Ok(ncursesw::wgetstr(self._handle())?)
}
fn get_wch(&self) -> result!(CharacterResult<WideChar>) {
Ok(ncursesw::wget_wch(self._handle())?)
}
#[deprecated(since = "0.1.1", note = "underlying native function can cause issues. Use getn_wstr() instead")]
fn get_wstr(&self) -> result!(WideString) {
Ok(ncursesw::wget_wstr(self._handle())?)
}
nonblocking_get!(getch_nonblocking, getch, "wgetch", char);
nonblocking_get!(get_wch_nonblocking, get_wch, "wget_wch", WideChar);
}