linux_io/tty.rs
1use crate::fd::ioctl::{ioctl_read, ioctl_write, IoctlReqRead, IoctlReqWrite};
2
3/// `ioctl` request for retrieving the current window size of a tty.
4// NOTE: This ioctl number isn't valid for all Linux architectures, but is valid
5// for all of the ones linux-unsafe supoorts at the time of writing.
6pub const TIOCGWINSZ: IoctlReqRead<TtyDevice, WindowSize> = unsafe { ioctl_read(0x5413) };
7
8/// `ioctl` request for changing the window size of a tty.
9// NOTE: This ioctl number isn't valid for all Linux architectures, but is valid
10// for all of the ones linux-unsafe supoorts at the time of writing.
11pub const TIOCSWINSZ: IoctlReqWrite<TtyDevice, WindowSize> = unsafe { ioctl_write(0x5414) };
12
13/// Represents the size of the window (or equivalent) that a tty is presented
14/// through.
15#[derive(Clone, Copy, Debug)]
16#[repr(C)]
17pub struct WindowSize {
18 /// The number of rows in the window.
19 pub ws_row: linux_unsafe::ushort,
20
21 /// The number of columns in the window.
22 pub ws_col: linux_unsafe::ushort,
23
24 /// Not actually used.
25 pub ws_xpixel: linux_unsafe::ushort,
26
27 /// Not actually used.
28 pub ws_ypixel: linux_unsafe::ushort,
29}
30
31/// A marker type for [`super::File`] objects that represent tty devices.
32pub struct TtyDevice;
33
34impl super::fd::ioctl::IoDevice for TtyDevice {}