mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: DECSET and DECRQM tmux passthrough
This commit is contained in:
parent
caacd15110
commit
a18a5e6957
4 changed files with 26 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ use tokio::{io::{AsyncReadExt, BufReader}, time::timeout};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
use yazi_shared::env_exists;
|
use yazi_shared::env_exists;
|
||||||
|
|
||||||
use crate::{Adapter, CLOSE, ESCAPE, START, TMUX};
|
use crate::{tmux, Adapter, TMUX};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Emulator {
|
pub enum Emulator {
|
||||||
|
|
@ -123,10 +123,7 @@ impl Emulator {
|
||||||
execute!(
|
execute!(
|
||||||
LineWriter::new(stderr()),
|
LineWriter::new(stderr()),
|
||||||
SavePosition,
|
SavePosition,
|
||||||
Print(format!(
|
Print(tmux!("\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")),
|
||||||
"{}[>q{}_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA{}\\{}[c{}",
|
|
||||||
START, ESCAPE, ESCAPE, ESCAPE, CLOSE
|
|
||||||
)),
|
|
||||||
RestorePosition
|
RestorePosition
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ mod image;
|
||||||
mod iterm2;
|
mod iterm2;
|
||||||
mod kitty;
|
mod kitty;
|
||||||
mod kitty_old;
|
mod kitty_old;
|
||||||
|
mod macros;
|
||||||
mod sixel;
|
mod sixel;
|
||||||
mod ueberzug;
|
mod ueberzug;
|
||||||
|
|
||||||
|
|
@ -28,18 +29,18 @@ pub static ADAPTOR: RoCell<Adapter> = RoCell::new();
|
||||||
|
|
||||||
// Tmux support
|
// Tmux support
|
||||||
pub static TMUX: RoCell<bool> = RoCell::new();
|
pub static TMUX: RoCell<bool> = RoCell::new();
|
||||||
static ESCAPE: RoCell<&'static str> = RoCell::new();
|
pub static ESCAPE: RoCell<&'static str> = RoCell::new();
|
||||||
static START: RoCell<&'static str> = RoCell::new();
|
pub static START: RoCell<&'static str> = RoCell::new();
|
||||||
static CLOSE: RoCell<&'static str> = RoCell::new();
|
pub static CLOSE: RoCell<&'static str> = RoCell::new();
|
||||||
|
|
||||||
// Image state
|
// Image state
|
||||||
static SHOWN: RoCell<arc_swap::ArcSwapOption<ratatui::layout::Rect>> = RoCell::new();
|
static SHOWN: RoCell<arc_swap::ArcSwapOption<ratatui::layout::Rect>> = RoCell::new();
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
TMUX.init(env_exists("TMUX") && env_exists("TMUX_PANE"));
|
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" });
|
START.init(if *TMUX { "\x1bPtmux;\x1b\x1b" } else { "\x1b" });
|
||||||
CLOSE.init(if *TMUX { "\x1b\\" } else { "" });
|
CLOSE.init(if *TMUX { "\x1b\\" } else { "" });
|
||||||
ESCAPE.init(if *TMUX { "\x1b\x1b" } else { "\x1b" });
|
|
||||||
|
|
||||||
if *TMUX {
|
if *TMUX {
|
||||||
_ = std::process::Command::new("tmux")
|
_ = std::process::Command::new("tmux")
|
||||||
|
|
|
||||||
15
yazi-adapter/src/macros.rs
Normal file
15
yazi-adapter/src/macros.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#[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)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -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 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 cursor::RestoreCursor;
|
||||||
use ratatui::{backend::CrosstermBackend, buffer::Buffer, layout::Rect, CompletedFrame, Frame, Terminal};
|
use ratatui::{backend::CrosstermBackend, buffer::Buffer, layout::Rect, CompletedFrame, Frame, Terminal};
|
||||||
use yazi_adapter::Emulator;
|
use yazi_adapter::{tmux, Emulator};
|
||||||
use yazi_config::{INPUT, MANAGER};
|
use yazi_config::{INPUT, MANAGER};
|
||||||
|
|
||||||
static CSI_U: AtomicBool = AtomicBool::new(false);
|
static CSI_U: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
@ -28,9 +28,9 @@ impl Term {
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
execute!(
|
execute!(
|
||||||
BufWriter::new(stderr()),
|
BufWriter::new(stderr()),
|
||||||
Print("\x1b[?12$p"), // Request cursor blink status (DECSET)
|
Print(tmux!("\x1b[?12$p")), // Request cursor blink status (DECSET)
|
||||||
Print("\x1bP$q q\x1b\\"), // Request cursor shape (DECRQM)
|
Print(tmux!("\x1bP$q q\x1b\\")), // Request cursor shape (DECRQM)
|
||||||
Print("\x1b[?u\x1b[c"), // Request keyboard enhancement flags (CSI u)
|
Print(tmux!("\x1b[?u\x1b[c")), // Request keyboard enhancement flags (CSI u)
|
||||||
EnterAlternateScreen,
|
EnterAlternateScreen,
|
||||||
EnableBracketedPaste,
|
EnableBracketedPaste,
|
||||||
mouse::SetMouse(true),
|
mouse::SetMouse(true),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue