Skip to content

Commit

Permalink
Upgrade nix to v0.28.0 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Apr 11, 2024
1 parent dbec2d5 commit 03ff232
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0.38"
which = "4.3.0"

[target.'cfg(unix)'.dependencies.nix]
version = "0.26.1"
version = "0.28.0"
default-features = false
features = ["fs", "term"]

Expand Down
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,14 @@ mod unix {
use super::Error;

use nix::{
libc::STDIN_FILENO,
sys::termios::{
tcgetattr, tcsetattr, ControlFlags, InputFlags, LocalFlags, OutputFlags,
SetArg::TCSANOW, Termios,
},
unistd::isatty,
};

use std::{fs::OpenOptions, os::unix::prelude::AsRawFd};
use std::{fs::OpenOptions, io::stdin, os::fd::AsFd, os::unix::prelude::AsRawFd};

pub(crate) fn vt_cooked() -> Result<(), Error> {
write_termios(|t| {
Expand Down Expand Up @@ -759,14 +758,14 @@ mod unix {
}

fn write_termios(f: impl Fn(&mut Termios)) -> Result<(), Error> {
if isatty(STDIN_FILENO)? {
let mut t = tcgetattr(STDIN_FILENO)?;
if isatty(stdin().as_raw_fd())? {
let mut t = tcgetattr(stdin().as_fd())?;
reset_termios(&mut t);
f(&mut t);
tcsetattr(STDIN_FILENO, TCSANOW, &t)?;
tcsetattr(stdin().as_fd(), TCSANOW, &t)?;
} else {
let tty = OpenOptions::new().read(true).write(true).open("/dev/tty")?;
let fd = tty.as_raw_fd();
let fd = tty.as_fd();

let mut t = tcgetattr(fd)?;
reset_termios(&mut t);
Expand Down Expand Up @@ -1167,7 +1166,7 @@ impl<'a> Capability<'a> for ResetScrollback<'a> {

#[inline]
fn from(value: Option<&'a Value>) -> Option<Self> {
if let Some(&Value::String(ref value)) = value {
if let Some(Value::String(value)) = value {
Some(Self(Cow::Borrowed(value)))
} else {
None
Expand Down

0 comments on commit 03ff232

Please sign in to comment.