Skip to content

Commit ff65d6b

Browse files
committed
Fix QNX patch for libc::cfmakeraw
1 parent 90ea08d commit ff65d6b

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/unix_term.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
342342
c_result(|| unsafe { libc::tcgetattr(input.as_raw_fd(), termios.as_mut_ptr()) })?;
343343
let mut termios = unsafe { termios.assume_init() };
344344
let original = termios;
345-
unsafe { libc::cfmakeraw(&mut termios) };
345+
make_raw(&mut termios);
346346
termios.c_oflag = original.c_oflag;
347347
c_result(|| unsafe { libc::tcsetattr(input.as_raw_fd(), libc::TCSADRAIN, &termios) })?;
348348
let rv = read_single_key_impl(input.as_raw_fd());
@@ -392,3 +392,27 @@ pub(crate) fn wants_emoji() -> bool {
392392
pub(crate) fn set_title<T: Display>(title: T) {
393393
print!("\x1b]0;{title}\x07");
394394
}
395+
396+
#[cfg(target_os = "nto")]
397+
fn make_raw(termios: &mut libc::termios) {
398+
// This is the manual implementation for QNX, which does not have cfmakeraw.
399+
termios.c_iflag &= !(libc::IGNBRK
400+
| libc::BRKINT
401+
| libc::PARMRK
402+
| libc::ISTRIP
403+
| libc::INLCR
404+
| libc::IGNCR
405+
| libc::ICRNL
406+
| libc::IXON);
407+
termios.c_oflag &= !libc::OPOST;
408+
termios.c_lflag &= !(libc::ECHO | libc::ECHONL | libc::ICANON | libc::ISIG | libc::IEXTEN);
409+
termios.c_cflag &= !(libc::CSIZE | libc::PARENB);
410+
termios.c_cflag |= libc::CS8;
411+
}
412+
413+
// This version will be compiled for all targets that are NOT QNX.
414+
#[cfg(not(target_os = "nto"))]
415+
fn make_raw(termios: &mut libc::termios) {
416+
// For other systems (Linux, macOS, BSD, etc.), use the standard libc call.
417+
unsafe { libc::cfmakeraw(termios) };
418+
}

0 commit comments

Comments
 (0)