@@ -2,10 +2,9 @@ use anyhow::{Context as _, Result};
22use base64:: { engine, Engine } ;
33use image:: { imageops:: FilterType , DynamicImage } ;
44
5- use nix:: poll:: { poll, PollFd , PollFlags , PollTimeout } ;
6- use nix:: sys:: termios:: { tcgetattr, tcsetattr, LocalFlags , SetArg } ;
7- use nix:: unistd:: read;
8- use rustix:: termios:: tcgetwinsize;
5+ use rustix:: event:: { poll, PollFd , PollFlags , Timespec } ;
6+ use rustix:: io:: read;
7+ use rustix:: termios:: { tcgetattr, tcgetwinsize, tcsetattr, LocalModes , OptionalActions } ;
98
109use std:: io:: { stdout, Write } ;
1110use std:: os:: fd:: AsFd as _;
@@ -21,9 +20,9 @@ impl KittyBackend {
2120 let old = tcgetattr ( & stdin) . context ( "Failed to recieve terminal attibutes" ) ?;
2221
2322 let mut new = old. clone ( ) ;
24- new. local_flags &= !LocalFlags :: ICANON ;
25- new. local_flags &= !LocalFlags :: ECHO ;
26- tcsetattr ( & stdin, SetArg :: TCSANOW , & new)
23+ new. local_modes &= !LocalModes :: ICANON ;
24+ new. local_modes &= !LocalModes :: ECHO ;
25+ tcsetattr ( & stdin, OptionalActions :: Now , & new)
2726 . context ( "Failed to update terminal attributes" ) ?;
2827 old
2928 } ;
@@ -40,14 +39,15 @@ impl KittyBackend {
4039 stdout ( ) . flush ( ) ?;
4140
4241 let start_time = Instant :: now ( ) ;
43- let mut stdin_pollfd = [ PollFd :: new ( stdin. as_fd ( ) , PollFlags :: POLLIN ) ] ;
42+ let stdin_fd = stdin. as_fd ( ) ;
43+ let mut stdin_pollfd = [ PollFd :: new ( & stdin_fd, PollFlags :: IN ) ] ;
4444 let allowed_bytes = [ 0x1B , b'_' , b'G' , b'\\' ] ;
4545 let mut buf = Vec :: < u8 > :: new ( ) ;
4646 loop {
4747 // check for timeout while polling to avoid blocking the main thread
48- while poll ( & mut stdin_pollfd, PollTimeout :: ZERO ) ? < 1 {
48+ while poll ( & mut stdin_pollfd, Some ( & Timespec :: default ( ) ) ) ? < 1 {
4949 if start_time. elapsed ( ) . as_millis ( ) > 50 {
50- tcsetattr ( & stdin, SetArg :: TCSANOW , & old_attributes)
50+ tcsetattr ( & stdin, OptionalActions :: Now , & old_attributes)
5151 . context ( "Failed to update terminal attributes" ) ?;
5252 return Ok ( false ) ;
5353 }
@@ -58,7 +58,7 @@ impl KittyBackend {
5858 buf. push ( byte[ 0 ] ) ;
5959 }
6060 if buf. starts_with ( & [ 0x1B , b'_' , b'G' ] ) && buf. ends_with ( & [ 0x1B , b'\\' ] ) {
61- tcsetattr ( & stdin, SetArg :: TCSANOW , & old_attributes)
61+ tcsetattr ( & stdin, OptionalActions :: Now , & old_attributes)
6262 . context ( "Failed to update terminal attributes" ) ?;
6363 return Ok ( true ) ;
6464 }
0 commit comments