Skip to main content

novel_api/common/utils/
mod.rs

1mod dir;
2mod input;
3mod keyring;
4mod self_update;
5mod webp;
6mod zip;
7
8use std::io::IsTerminal;
9use std::{env, io};
10
11pub use dir::*;
12pub use input::*;
13pub use self_update::*;
14pub use webp::*;
15
16pub use self::keyring::*;
17pub use self::zip::*;
18
19pub fn support_osc94() -> bool {
20    supports_term_integration() && is_terminal()
21}
22
23fn supports_term_integration() -> bool {
24    let windows_terminal = env::var("WT_SESSION").is_ok();
25    let conemu = env::var("ConEmuANSI").ok() == Some("ON".into());
26    let wezterm = env::var("TERM_PROGRAM").ok() == Some("WezTerm".into());
27    let ghostty = env::var("TERM_PROGRAM").ok() == Some("ghostty".into());
28
29    windows_terminal || conemu || wezterm || ghostty
30}
31
32fn is_terminal() -> bool {
33    io::stdout().is_terminal()
34}