From ec3a80427b717bb13d56c3031f4195bdae9c011a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 24 Sep 2018 21:06:12 +0200 Subject: Add standalone terminfo definition This replaces the current definitions, which depend on the system's 'xterm-256color' terminfo definition with the `alacritty` and `alacritty-direct` definitions. The new definitions are completely standalone. The default `TERM` value has been changed to be dynamically set based on the definitions installed on the system. Alacritty will try to use the `alacritty` definition first and fall back to `xterm-256color` if the `alacritty` definition is not present. --- src/lib.rs | 1 + src/tty.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index d9006fe0..fcc55799 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,7 @@ extern crate unicode_width; extern crate vte; extern crate xdg; extern crate base64; +extern crate terminfo; #[macro_use] pub mod macros; diff --git a/src/tty.rs b/src/tty.rs index 9f6a2e64..b9d00fa5 100644 --- a/src/tty.rs +++ b/src/tty.rs @@ -22,12 +22,14 @@ use std::ptr; use std::process::{Command, Stdio}; use libc::{self, winsize, c_int, pid_t, WNOHANG, SIGCHLD, TIOCSCTTY}; +use terminfo::Database; use term::SizeInfo; use display::OnResize; use config::{Config, Shell}; use cli::Options; + /// Process ID of child process /// /// Necessary to put this in static storage for `sigchld` to have access @@ -210,7 +212,16 @@ pub fn new(config: &Config, options: &Options, size: &T, window_id builder.env("USER", pw.name); builder.env("SHELL", shell.program()); builder.env("HOME", pw.dir); - builder.env("TERM", "xterm-256color"); // default term until we can supply our own + + // TERM; default to 'alacritty' if it is available, otherwise + // default to 'xterm-256color'. May be overridden by user's config + // below. + let mut term = "alacritty"; + if let Err(_) = Database::from_name("alacritty") { + term = "xterm-256color"; + } + builder.env("TERM", term); + builder.env("COLORTERM", "truecolor"); // advertise 24-bit support if let Some(window_id) = window_id { builder.env("WINDOWID", format!("{}", window_id)); -- cgit