From d18a96a0308b0b46b420f330dfd29c4b4efdac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Tue, 27 Dec 2022 14:49:00 +1300 Subject: [PATCH 1/4] Explicitely support tmux and zellij, fallback if terminfo isn't available Within tmux and zellij (and screen but that's pre-existing) we can assume the escape and avoid looking up terminfo. This can help on systems which are a bit bare or broken and don't have a functional terminfo. Even outside of these, we can detect for terminfo and not select the variant if we don't find one, which will fall back to the hardcoded sequence more often. --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c2122dd..31ae3ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -392,7 +392,9 @@ impl Default for ClearScreen { // - screen supports CSI 3J only within the XtermClear sequence, without E3 capability. // - Konsole handles CSI 3J correctly only within the XtermClear sequence. - if term.starts_with("screen") || term.starts_with("konsole") { + // - assume tmux TERMs are only used within tmux, and avoid the requirement for a functioning terminfo then + // - do the same for running inside zellij + if term.starts_with("screen") || term.starts_with("konsole") || term.starts_with("tmux") || varfull("ZELLIJ") { return Self::XtermClear; } @@ -406,7 +408,7 @@ impl Default for ClearScreen { return Self::XtermClear; } - if !term.is_empty() { + if !term.is_empty() && Database::from_env().is_ok() { return Self::Terminfo; } } From 58c03b0a9f392dfc7b8cd654ccd53fd9142c9a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Tue, 27 Dec 2022 14:57:51 +1300 Subject: [PATCH 2/4] Update TERMINALS.md --- TERMINALS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TERMINALS.md b/TERMINALS.md index 15af696..c702c77 100644 --- a/TERMINALS.md +++ b/TERMINALS.md @@ -72,6 +72,9 @@ On macOS, the terminfo for `xterm` and variants does not by default include E3, the terminal in question actually does support E3. For that reason, default behaviour on macOS is switched to use `XtermClear` if the `TERM` starts with `xterm` and the terminfo doesn’t have E3. +If the terminfo database is not available, `::default()` falls back to `XTermClear` instead of +supplying a useless `Terminfo`. When testing, it's expected to have a functional terminfo where +practical. Emulator libraries ------------------ From 8774d4f54fd395151d71f0088b2cdc539bdccba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Tue, 27 Dec 2022 14:59:02 +1300 Subject: [PATCH 3/4] Zellij was already explicitly supported --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 31ae3ae..b4133e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -393,8 +393,7 @@ impl Default for ClearScreen { // - screen supports CSI 3J only within the XtermClear sequence, without E3 capability. // - Konsole handles CSI 3J correctly only within the XtermClear sequence. // - assume tmux TERMs are only used within tmux, and avoid the requirement for a functioning terminfo then - // - do the same for running inside zellij - if term.starts_with("screen") || term.starts_with("konsole") || term.starts_with("tmux") || varfull("ZELLIJ") { + if term.starts_with("screen") || term.starts_with("konsole") || term.starts_with("tmux") { return Self::XtermClear; } From 11c0b1b9e289ac7c573dfd65063a9cb8fa6003c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Wed, 28 Dec 2022 15:36:57 +1300 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 646e6bd..3934e96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Update dependencies. - Update to nix 0.26. - Change MSRV policy to stable-5 supported, and bump MSRV to 1.60.0. +- Handle tmux explicitly ([#9](https://github.com/watchexec/clearscreen/pull/9)). +- Fall back to hardcoded sequence if terminfo is not available ([#9](https://github.com/watchexec/clearscreen/pull/9)). ## v1.0.10 (2022-06-01)