diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-10-11 03:23:19 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 03:23:19 +0400 |
commit | b4130ddf24d9612cce4cb043e9b15acc086369a1 (patch) | |
tree | 6df4d7ad8dc2b4b3124945b140814c3a90dcadce /alacritty_terminal | |
parent | e1859e80f6196da6f52aacf8829c039378e13275 (diff) | |
download | alacritty-b4130ddf24d9612cce4cb043e9b15acc086369a1.tar.gz alacritty-b4130ddf24d9612cce4cb043e9b15acc086369a1.zip |
Use openpty-rustix instead of nix
Follow upstream libraries and use rustix to reduce the amount of
dependencies in the future.
Co-authored-by: Christian Duerr <contact@christianduerr.com>
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/Cargo.toml | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 29 |
2 files changed, 16 insertions, 15 deletions
diff --git a/alacritty_terminal/Cargo.toml b/alacritty_terminal/Cargo.toml index e6712de3..a0bdac49 100644 --- a/alacritty_terminal/Cargo.toml +++ b/alacritty_terminal/Cargo.toml @@ -33,7 +33,7 @@ unicode-width = "0.1" vte = { version = "0.12.0", default-features = false, features = ["ansi", "serde"] } [target.'cfg(unix)'.dependencies] -nix = { version = "0.27.1", default-features = false, features = ["term"] } +rustix-openpty = "0.1.1" signal-hook = "0.3.10" [target.'cfg(windows)'.dependencies] diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 3fecaef8..6b543437 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -12,12 +12,13 @@ use std::process::{Child, Command, Stdio}; use std::sync::Arc; use std::{env, ptr}; -use libc::{self, c_int, winsize, TIOCSCTTY}; +use libc::{self, c_int, TIOCSCTTY}; use log::error; -use nix::pty::openpty; -#[cfg(any(target_os = "linux", target_os = "macos"))] -use nix::sys::termios::{self, InputFlags, SetArg}; use polling::{Event, PollMode, Poller}; +use rustix_openpty::openpty; +use rustix_openpty::rustix::termios::Winsize; +#[cfg(any(target_os = "linux", target_os = "macos"))] +use rustix_openpty::rustix::termios::{self, InputModes, OptionalActions}; use signal_hook::consts as sigconsts; use signal_hook::low_level::pipe as signal_pipe; @@ -39,14 +40,14 @@ macro_rules! die { } /// Get raw fds for master/slave ends of a new PTY. -fn make_pty(size: winsize) -> Result<(OwnedFd, OwnedFd)> { +fn make_pty(size: Winsize) -> Result<(OwnedFd, OwnedFd)> { let mut window_size = size; window_size.ws_xpixel = 0; window_size.ws_ypixel = 0; - let ends = openpty(Some(&window_size), None)?; + let ends = openpty(None, Some(&window_size))?; - Ok((ends.master, ends.slave)) + Ok((ends.controller, ends.user)) } /// Really only needed on BSD, but should be fine elsewhere. @@ -201,8 +202,8 @@ pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: u64) -> Resul #[cfg(any(target_os = "linux", target_os = "macos"))] if let Ok(mut termios) = termios::tcgetattr(&master) { // Set character encoding to UTF-8. - termios.input_flags.set(InputFlags::IUTF8, true); - let _ = termios::tcsetattr(&master, SetArg::TCSANOW, &termios); + termios.input_modes.set(InputModes::IUTF8, true); + let _ = termios::tcsetattr(&master, OptionalActions::Now, &termios); } let user = ShellUser::from_env()?; @@ -404,20 +405,20 @@ impl OnResize for Pty { } } -/// Types that can produce a `libc::winsize`. +/// Types that can produce a `Winsize`. pub trait ToWinsize { - /// Get a `libc::winsize`. - fn to_winsize(self) -> winsize; + /// Get a `Winsize`. + fn to_winsize(self) -> Winsize; } impl ToWinsize for WindowSize { - fn to_winsize(self) -> winsize { + fn to_winsize(self) -> Winsize { let ws_row = self.num_lines as libc::c_ushort; let ws_col = self.num_cols as libc::c_ushort; let ws_xpixel = ws_col * self.cell_width as libc::c_ushort; let ws_ypixel = ws_row * self.cell_height as libc::c_ushort; - winsize { ws_row, ws_col, ws_xpixel, ws_ypixel } + Winsize { ws_row, ws_col, ws_xpixel, ws_ypixel } } } |