mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
rust: fix ncdirect_getc_blocking(), and corresponding method
This commit is contained in:
parent
70b74a749b
commit
a29e9f0014
@ -416,9 +416,9 @@ impl NcDirect {
|
||||
}
|
||||
|
||||
///
|
||||
/// *C style function: [ncdirect_getc_nblocking()][crate::ncdirect_getc_nblocking].*
|
||||
pub fn getc_nblocking(&mut self, input: &mut NcInput) -> char {
|
||||
crate::ncdirect_getc_nblocking(self, input)
|
||||
/// *C style function: [ncdirect_getc_blocking()][crate::ncdirect_getc_blocking].*
|
||||
pub fn getc_blocking(&mut self, input: &mut NcInput) -> char {
|
||||
crate::ncdirect_getc_blocking(self, input)
|
||||
}
|
||||
|
||||
/// Get a file descriptor suitable for input event poll()ing.
|
||||
|
@ -4,6 +4,20 @@ use core::ptr::null;
|
||||
|
||||
use crate::{NcColor, NcDirect, NcInput, NcIntResult, NcRgb, NcSignalSet, NcTime};
|
||||
|
||||
/// 'input' may be NULL if the caller is uninterested in event details.
|
||||
/// Blocks until an event is processed or a signal is received.
|
||||
///
|
||||
/// *Method: NcDirect.[getc_blocking()][NcDirect#method.getc_blocking].*
|
||||
// TODO: use from_u32 & return Option.
|
||||
#[inline]
|
||||
pub fn ncdirect_getc_blocking(nc: &mut NcDirect, input: &mut NcInput) -> char {
|
||||
unsafe {
|
||||
let mut sigmask = NcSignalSet::new();
|
||||
sigmask.emptyset();
|
||||
core::char::from_u32_unchecked(crate::ncdirect_getc(nc, null(), &mut sigmask, input))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// If no event is ready, returns 0.
|
||||
///
|
||||
@ -20,19 +34,6 @@ pub fn ncdirect_getc_nblock(nc: &mut NcDirect, input: &mut NcInput) -> char {
|
||||
}
|
||||
}
|
||||
|
||||
/// 'input' may be NULL if the caller is uninterested in event details.
|
||||
/// Blocks until an event is processed or a signal is received.
|
||||
///
|
||||
/// *Method: NcDirect.[getc_nblocking()][NcDirect#method.getc_nblocking].*
|
||||
#[inline]
|
||||
pub fn ncdirect_getc_nblocking(nc: &mut NcDirect, input: &mut NcInput) -> char {
|
||||
unsafe {
|
||||
let mut sigmask = NcSignalSet::new();
|
||||
sigmask.emptyset();
|
||||
core::char::from_u32_unchecked(crate::ncdirect_getc(nc, null(), &mut sigmask, input))
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the foreground [NcColor] components.
|
||||
///
|
||||
/// *Method: NcDirect.[set_fg_rgb8()][NcDirect#method.set_fg_rgb8].*
|
||||
|
Loading…
Reference in New Issue
Block a user