This commit is contained in:
sxyazi 2024-08-28 03:08:17 +08:00
parent a18a5e6957
commit df3d8af854
No known key found for this signature in database
5 changed files with 23 additions and 26 deletions

View file

@ -1 +1 @@
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","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","imagesize","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"],"version":"0.2"}
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","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","imagesize","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"],"language":"en","version":"0.2"}

View file

@ -7,7 +7,7 @@ use tokio::{io::{AsyncReadExt, BufReader}, time::timeout};
use tracing::{error, warn};
use yazi_shared::env_exists;
use crate::{tmux, Adapter, TMUX};
use crate::{tcsi, Adapter, TMUX};
#[derive(Clone, Debug)]
pub enum Emulator {
@ -123,7 +123,7 @@ impl Emulator {
execute!(
LineWriter::new(stderr()),
SavePosition,
Print(tmux!("\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")),
Print(tcsi("\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")),
RestorePosition
)?;

View file

@ -8,7 +8,6 @@ mod image;
mod iterm2;
mod kitty;
mod kitty_old;
mod macros;
mod sixel;
mod ueberzug;
@ -29,9 +28,9 @@ pub static ADAPTOR: RoCell<Adapter> = RoCell::new();
// Tmux support
pub static TMUX: RoCell<bool> = RoCell::new();
pub static ESCAPE: RoCell<&'static str> = RoCell::new();
pub static START: RoCell<&'static str> = RoCell::new();
pub static CLOSE: RoCell<&'static str> = RoCell::new();
static ESCAPE: RoCell<&'static str> = RoCell::new();
static START: RoCell<&'static str> = RoCell::new();
static CLOSE: RoCell<&'static str> = RoCell::new();
// Image state
static SHOWN: RoCell<arc_swap::ArcSwapOption<ratatui::layout::Rect>> = RoCell::new();
@ -56,3 +55,16 @@ pub fn init() {
ADAPTOR.init(Adapter::matches());
ADAPTOR.start();
}
pub fn tcsi(s: &str) -> std::borrow::Cow<str> {
if *TMUX {
std::borrow::Cow::Owned(format!(
"{}{}{}",
*START,
s.trim_start_matches('\x1b').replace('\x1b', *ESCAPE),
*CLOSE
))
} else {
std::borrow::Cow::Borrowed(s)
}
}

View file

@ -1,15 +0,0 @@
#[macro_export]
macro_rules! tmux {
($s:literal) => {
if *$crate::TMUX {
std::borrow::Cow::Owned(format!(
"{}{}{}",
*$crate::START,
$s.trim_start_matches('\x1b').replace('\x1b', *$crate::ESCAPE),
*$crate::CLOSE
))
} else {
std::borrow::Cow::Borrowed($s)
}
};
}

View file

@ -4,7 +4,7 @@ use anyhow::Result;
use crossterm::{event::{DisableBracketedPaste, EnableBracketedPaste, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, style::Print, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen, SetTitle}};
use cursor::RestoreCursor;
use ratatui::{backend::CrosstermBackend, buffer::Buffer, layout::Rect, CompletedFrame, Frame, Terminal};
use yazi_adapter::{tmux, Emulator};
use yazi_adapter::{tcsi, Emulator};
use yazi_config::{INPUT, MANAGER};
static CSI_U: AtomicBool = AtomicBool::new(false);
@ -28,9 +28,9 @@ impl Term {
enable_raw_mode()?;
execute!(
BufWriter::new(stderr()),
Print(tmux!("\x1b[?12$p")), // Request cursor blink status (DECSET)
Print(tmux!("\x1bP$q q\x1b\\")), // Request cursor shape (DECRQM)
Print(tmux!("\x1b[?u\x1b[c")), // Request keyboard enhancement flags (CSI u)
Print(tcsi("\x1b[?12$p")), // Request cursor blink status (DECSET)
Print(tcsi("\x1bP$q q\x1b\\")), // Request cursor shape (DECRQM)
Print(tcsi("\x1b[?u\x1b[c")), // Request keyboard enhancement flags (CSI u)
EnterAlternateScreen,
EnableBracketedPaste,
mouse::SetMouse(true),