clarify Blocking enum; Blocking::No -> DoNotWait
This commit is contained in:
1 parent
a781d8eb5a
commit
d1ea0588a3
4 files changed
+7
-7
No files matched your search
+1
-1
@@ -38,7 +38,7 @@ fn main() -> Result<(), Error> {
|
||||
|
||||
buf.terminal().set_raw_mode()?;
|
||||
loop {
|
||||
match buf.terminal().poll_input(Blocking::Yes) {
|
||||
match buf.terminal().poll_input(Blocking::Wait) {
|
||||
Ok(Some(input)) => match input {
|
||||
InputEvent::Key(KeyEvent {
|
||||
key: KeyCode::Escape,
|
||||
|
||||
+2
-2
@@ -41,8 +41,8 @@ pub struct ScreenSize {
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Blocking {
|
||||
No,
|
||||
Yes,
|
||||
DoNotWait,
|
||||
Wait,
|
||||
}
|
||||
|
||||
/// `Terminal` abstracts over some basic terminal capabilities.
|
||||
|
||||
@@ -94,8 +94,8 @@ impl TtyReadHandle {
|
||||
|
||||
fn set_blocking(&mut self, blocking: Blocking) -> Result<(), Error> {
|
||||
let value: libc::c_int = match blocking {
|
||||
Blocking::Yes => 0,
|
||||
Blocking::No => 1,
|
||||
Blocking::Wait => 0,
|
||||
Blocking::DoNotWait => 1,
|
||||
};
|
||||
if unsafe { libc::ioctl(*self.fd, libc::FIONBIO, &value as *const _) } != 0 {
|
||||
bail!("failed to ioctl(FIONBIO): {:?}", IoError::last_os_error());
|
||||
|
||||
@@ -449,8 +449,8 @@ impl Terminal for WindowsTerminal {
|
||||
}
|
||||
|
||||
let pending = match (self.input_handle.get_number_of_input_events()?, blocking) {
|
||||
(0, Blocking::No) => return Ok(None),
|
||||
(0, Blocking::Yes) => 1,
|
||||
(0, Blocking::DoNotWait) => return Ok(None),
|
||||
(0, Blocking::Wait) => 1,
|
||||
(pending, _) => pending,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user