mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: DECSET and DECRQM tmux passthrough (#1564)
This commit is contained in:
parent
caacd15110
commit
90b1e525b8
4 changed files with 21 additions and 11 deletions
|
|
@ -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"}
|
||||
|
|
@ -7,7 +7,7 @@ use tokio::{io::{AsyncReadExt, BufReader}, time::timeout};
|
|||
use tracing::{error, warn};
|
||||
use yazi_shared::env_exists;
|
||||
|
||||
use crate::{Adapter, CLOSE, ESCAPE, START, TMUX};
|
||||
use crate::{tcsi, Adapter, TMUX};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Emulator {
|
||||
|
|
@ -123,10 +123,7 @@ impl Emulator {
|
|||
execute!(
|
||||
LineWriter::new(stderr()),
|
||||
SavePosition,
|
||||
Print(format!(
|
||||
"{}[>q{}_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA{}\\{}[c{}",
|
||||
START, ESCAPE, ESCAPE, ESCAPE, CLOSE
|
||||
)),
|
||||
Print(tcsi("\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")),
|
||||
RestorePosition
|
||||
)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ static SHOWN: RoCell<arc_swap::ArcSwapOption<ratatui::layout::Rect>> = RoCell::n
|
|||
|
||||
pub fn init() {
|
||||
TMUX.init(env_exists("TMUX") && env_exists("TMUX_PANE"));
|
||||
ESCAPE.init(if *TMUX { "\x1b\x1b" } else { "\x1b" });
|
||||
START.init(if *TMUX { "\x1bPtmux;\x1b\x1b" } else { "\x1b" });
|
||||
CLOSE.init(if *TMUX { "\x1b\\" } else { "" });
|
||||
ESCAPE.init(if *TMUX { "\x1b\x1b" } else { "\x1b" });
|
||||
|
||||
if *TMUX {
|
||||
_ = std::process::Command::new("tmux")
|
||||
|
|
@ -55,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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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::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("\x1b[?12$p"), // Request cursor blink status (DECSET)
|
||||
Print("\x1bP$q q\x1b\\"), // Request cursor shape (DECRQM)
|
||||
Print("\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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue