summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2018-09-24 21:06:12 +0200
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-09-24 19:06:12 +0000
commitec3a80427b717bb13d56c3031f4195bdae9c011a (patch)
tree85f9119f88c2dfe56d8839150fc136623e14c624 /src
parent3d7e88e8a975f40996aaa71d951842db6f2fccbb (diff)
downloadalacritty-ec3a80427b717bb13d56c3031f4195bdae9c011a.tar.gz
alacritty-ec3a80427b717bb13d56c3031f4195bdae9c011a.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs1
-rw-r--r--src/tty.rs13
2 files changed, 13 insertions, 1 deletions
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<T: ToWinsize>(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));