diff --git a/src/header/sys_ioctl/mod.rs b/src/header/sys_ioctl/mod.rs index 54d5f29aefde264db22d4b18543233c551cf0ae7..c1716d08613ffeb6c8a2371f8c250103748574f5 100644 --- a/src/header/sys_ioctl/mod.rs +++ b/src/header/sys_ioctl/mod.rs @@ -21,6 +21,12 @@ pub struct winsize { ws_ypixel: c_ushort, } +impl winsize { + pub fn get_row_col(&self) -> (c_ushort, c_ushort) { + (self.ws_row, self.ws_col) + } +} + pub use self::sys::*; #[cfg(target_os = "linux")] diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index d8fd118e508deb21098d52ac18e9a50dc91f18a6..096ecbef4a4cb368d9938953c3b4a4acf43c500b 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -1,7 +1,10 @@ //! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html use crate::{ - header::{errno, sys_ioctl}, + header::{ + errno, + sys_ioctl::{self, winsize}, + }, platform::{self, types::*}, }; @@ -171,6 +174,11 @@ pub unsafe extern "C" fn tcsendbreak(fd: c_int, _dur: c_int) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCSBRK, 0 as *mut _) } +#[no_mangle] +pub unsafe extern "C" fn tcsetwinsize(fd: c_int, mut sws: winsize) -> c_int { + sys_ioctl::ioctl(fd, sys_ioctl::TIOCSWINSZ, &mut sws as *mut _ as *mut c_void) +} + #[no_mangle] pub unsafe extern "C" fn tcflow(fd: c_int, action: c_int) -> c_int { // non-zero duration is ignored by musl due to it being