From 9a50566fc2732767275ac538a2058b7a2aa0a747 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Fri, 3 Jan 2025 17:26:56 -0800 Subject: [PATCH] Enable support for ghostty (animated emotes don't worth though) --- src/emotes/graphics_protocol.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/emotes/graphics_protocol.rs b/src/emotes/graphics_protocol.rs index f9305541..74e50648 100644 --- a/src/emotes/graphics_protocol.rs +++ b/src/emotes/graphics_protocol.rs @@ -420,15 +420,19 @@ fn query_terminal(command: &[u8]) -> Result { /// Then check that it supports the graphics protocol using temporary files, by sending a graphics protocol request followed by a request for terminal attributes. /// If we receive the terminal attributes without receiving the response for the graphics protocol, it does not support it. pub fn support_graphics_protocol() -> Result { - Ok(env::var("TERM")? == "xterm-kitty" - && query_terminal( - format!( - concat!(gp!("i=31,s=1,v=1,a=q,t=d,f=24;{}"), csi!("c")), - STANDARD.encode("AAAA"), - ) - .as_bytes(), - )? - .contains("OK")) + let supported_terminals = ["xterm-kitty", "xterm-ghostty"]; + + Ok( + env::var("TERM").map_or(false, |term| supported_terminals.contains(&term.as_str())) + && query_terminal( + format!( + concat!(gp!("i=31,s=1,v=1,a=q,t=d,f=24;{}"), csi!("c")), + STANDARD.encode("AAAA"), + ) + .as_bytes(), + )? + .contains("OK"), + ) } #[cfg(test)]