diff options
author | Owen Law <81528246+someone13574@users.noreply.github.com> | 2024-05-01 01:27:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 05:27:54 +0000 |
commit | ed3fac8a033acf10293712339185920849d45a0a (patch) | |
tree | e8c97359165c4b31d1177278c90e3cff4e54c78b | |
parent | ce800bfde2a2121a830c2b0854749875b3aebf79 (diff) | |
download | alacritty-ed3fac8a033acf10293712339185920849d45a0a.tar.gz alacritty-ed3fac8a033acf10293712339185920849d45a0a.zip |
Add `from_file_descriptors()` to `tty::unix`
-rw-r--r-- | alacritty_terminal/CHANGELOG.md | 4 | ||||
-rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/alacritty_terminal/CHANGELOG.md b/alacritty_terminal/CHANGELOG.md index b8dd33e8..8f416235 100644 --- a/alacritty_terminal/CHANGELOG.md +++ b/alacritty_terminal/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## 0.23.0-dev +### Added + +- `tty::unix::from_fd()` to create a TTY from a pre-opened PTY's file-descriptors + ### Changed - **`Term` is not focused by default anymore** diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index a4b07b74..54118a58 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -4,6 +4,7 @@ use std::ffi::CStr; use std::fs::File; use std::io::{Error, ErrorKind, Read, Result}; use std::mem::MaybeUninit; +use std::os::fd::OwnedFd; use std::os::unix::io::{AsRawFd, FromRawFd}; use std::os::unix::net::UnixStream; use std::os::unix::process::CommandExt; @@ -184,6 +185,11 @@ fn default_shell_command(shell: &str, user: &str) -> Command { pub fn new(config: &Options, window_size: WindowSize, window_id: u64) -> Result<Pty> { let pty = openpty(None, Some(&window_size.to_winsize()))?; let (master, slave) = (pty.controller, pty.user); + from_fd(config, window_id, master, slave) +} + +/// Create a new TTY from a PTY's file descriptors. +pub fn from_fd(config: &Options, window_id: u64, master: OwnedFd, slave: OwnedFd) -> Result<Pty> { let master_fd = master.as_raw_fd(); let slave_fd = slave.as_raw_fd(); |