-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: auto switch between dark and light icons/flavors based on term…
…inal backgrounds (#1946)
- Loading branch information
Showing
30 changed files
with
1,778 additions
and
863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","Sysinfo","ffprobe","vframes"],"version":"0.2"} | ||
{"version":"0.2","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","Sysinfo","ffprobe","vframes","luma"],"language":"en"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
use tracing::warn; | ||
use yazi_shared::env_exists; | ||
|
||
use crate::Mux; | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
pub enum Brand { | ||
Kitty, | ||
Konsole, | ||
Iterm2, | ||
WezTerm, | ||
Foot, | ||
Ghostty, | ||
Microsoft, | ||
Rio, | ||
BlackBox, | ||
VSCode, | ||
Tabby, | ||
Hyper, | ||
Mintty, | ||
Neovim, | ||
Apple, | ||
Urxvt, | ||
} | ||
|
||
impl Brand { | ||
pub fn from_env() -> Option<Self> { | ||
use Brand as B; | ||
|
||
if env_exists("NVIM_LOG_FILE") && env_exists("NVIM") { | ||
return Some(Self::Neovim); | ||
} | ||
|
||
let vars = [ | ||
("KITTY_WINDOW_ID", B::Kitty), | ||
("KONSOLE_VERSION", B::Konsole), | ||
("ITERM_SESSION_ID", B::Iterm2), | ||
("WEZTERM_EXECUTABLE", B::WezTerm), | ||
("GHOSTTY_RESOURCES_DIR", B::Ghostty), | ||
("WT_Session", B::Microsoft), | ||
("VSCODE_INJECTION", B::VSCode), | ||
("TABBY_CONFIG_DIRECTORY", B::Tabby), | ||
]; | ||
match vars.into_iter().find(|&(s, _)| env_exists(s)) { | ||
Some((_, brand)) => return Some(brand), | ||
None => warn!("[Adapter] No special environment variables detected"), | ||
} | ||
|
||
let (term, program) = B::env(); | ||
match program.as_str() { | ||
"iTerm.app" => return Some(B::Iterm2), | ||
"WezTerm" => return Some(B::WezTerm), | ||
"ghostty" => return Some(B::Ghostty), | ||
"rio" => return Some(B::Rio), | ||
"BlackBox" => return Some(B::BlackBox), | ||
"vscode" => return Some(B::VSCode), | ||
"Tabby" => return Some(B::Tabby), | ||
"Hyper" => return Some(B::Hyper), | ||
"mintty" => return Some(B::Mintty), | ||
"Apple_Terminal" => return Some(B::Apple), | ||
_ => warn!("[Adapter] Unknown TERM_PROGRAM: {program}"), | ||
} | ||
match term.as_str() { | ||
"xterm-kitty" => return Some(B::Kitty), | ||
"foot" => return Some(B::Foot), | ||
"foot-extra" => return Some(B::Foot), | ||
"xterm-ghostty" => return Some(B::Ghostty), | ||
"rio" => return Some(B::Rio), | ||
"rxvt-unicode-256color" => return Some(B::Urxvt), | ||
_ => warn!("[Adapter] Unknown TERM: {term}"), | ||
} | ||
None | ||
} | ||
|
||
pub(super) fn from_csi(resp: &str) -> Option<Self> { | ||
let names = [ | ||
("kitty", Self::Kitty), | ||
("Konsole", Self::Konsole), | ||
("iTerm2", Self::Iterm2), | ||
("WezTerm", Self::WezTerm), | ||
("foot", Self::Foot), | ||
("ghostty", Self::Ghostty), | ||
]; | ||
names.into_iter().find(|&(n, _)| resp.contains(n)).map(|(_, b)| b) | ||
} | ||
|
||
pub(super) fn adapters(self) -> &'static [crate::Adapter] { | ||
use Brand as B; | ||
|
||
use crate::Adapter as A; | ||
|
||
match self { | ||
B::Kitty => &[A::Kgp], | ||
B::Konsole => &[A::KgpOld], | ||
B::Iterm2 => &[A::Iip, A::Sixel], | ||
B::WezTerm => &[A::Iip, A::Sixel], | ||
B::Foot => &[A::Sixel], | ||
B::Ghostty => &[A::Kgp], | ||
B::Microsoft => &[A::Sixel], | ||
B::Rio => &[A::Iip, A::Sixel], | ||
B::BlackBox => &[A::Sixel], | ||
B::VSCode => &[A::Iip, A::Sixel], | ||
B::Tabby => &[A::Iip, A::Sixel], | ||
B::Hyper => &[A::Iip, A::Sixel], | ||
B::Mintty => &[A::Iip], | ||
B::Neovim => &[], | ||
B::Apple => &[], | ||
B::Urxvt => &[], | ||
} | ||
} | ||
|
||
fn env() -> (String, String) { | ||
let (term, program) = Mux::term_program(); | ||
( | ||
term.unwrap_or(std::env::var("TERM").unwrap_or_default()), | ||
program.unwrap_or(std::env::var("TERM_PROGRAM").unwrap_or_default()), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yazi_macro::mod_flat!(chafa iip kgp kgp_old sixel ueberzug); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.