From a669f12793779fdb5a5b7c455c5b458c0f9a4dfc Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Wed, 27 May 2020 18:24:01 +0300 Subject: [PATCH] Set IUTF8 input setting on supported platforms Fixes #3769. --- CHANGELOG.md | 1 + alacritty_terminal/src/tty/unix.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf49648..9078db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Don't hide cursor on modifier press with `mouse.hide_when_typing` enabled - `Shift + Backspace` now sends `^?` instead of `^H` - Default color scheme is now `Tomorrow Night` with the bright colors of `Tomorrow Night Bright` +- Set IUTF8 termios flag for improved UTF8 input support ### Fixed diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index f275308..2db5951 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -22,6 +22,8 @@ use crate::tty::{ChildEvent, EventedPty, EventedReadWrite}; use libc::{self, c_int, pid_t, winsize, TIOCSCTTY}; use log::error; use nix::pty::openpty; +#[cfg(any(target_os = "linux", target_os = "macos"))] +use nix::sys::termios::{self, InputFlags, SetArg}; use signal_hook::{self as sighook, iterator::Signals}; use mio::unix::EventedFd; @@ -45,7 +47,7 @@ static PID: AtomicUsize = AtomicUsize::new(0); macro_rules! die { ($($arg:tt)*) => {{ error!($($arg)*); - ::std::process::exit(1); + std::process::exit(1); }} } @@ -148,6 +150,15 @@ pub fn new(config: &Config, size: &SizeInfo, window_id: Option) -> let (master, slave) = make_pty(win_size); + #[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); + } + } + let default_shell = if cfg!(target_os = "macos") { let shell_name = pw.shell.rsplit('/').next().unwrap(); let argv = vec![String::from("-c"), format!("exec -a -{} {}", shell_name, pw.shell)];