mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
fix: DECSCUSR over DECSET 12 (#3165)
This commit is contained in:
parent
3713478753
commit
01fd967fa3
2 changed files with 6 additions and 6 deletions
|
|
@ -34,7 +34,7 @@ impl Term {
|
|||
TTY.writer(),
|
||||
yazi_term::If(!TMUX.get(), EnterAlternateScreen),
|
||||
Print("\x1bP$q q\x1b\\"), // Request cursor shape (DECRQSS query for DECSCUSR)
|
||||
Print(Mux::csi("\x1b[?12$p")), // Request cursor blink status (DECSET)
|
||||
Print(Mux::csi("\x1b[?12$p")), // Request cursor blink status (DECRQM query for DECSET 12)
|
||||
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
|
||||
Print(Mux::csi("\x1b[0c")), // Request device attributes
|
||||
yazi_term::If(TMUX.get(), EnterAlternateScreen),
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
|||
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
|
||||
static BLINK: AtomicBool = AtomicBool::new(false);
|
||||
static SHAPE: AtomicU8 = AtomicU8::new(0);
|
||||
static BLINK: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub struct RestoreCursor;
|
||||
|
||||
impl RestoreCursor {
|
||||
pub fn store(resp: &str) {
|
||||
BLINK.store(resp.contains("\x1b[?12;1$y"), Ordering::Relaxed);
|
||||
SHAPE.store(
|
||||
resp
|
||||
.split_once("\x1bP1$r")
|
||||
|
|
@ -18,17 +17,18 @@ impl RestoreCursor {
|
|||
.map_or(u8::MAX, |b| b - b'0'),
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
BLINK.store(resp.contains("\x1b[?12;1$y"), Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
impl crossterm::Command for RestoreCursor {
|
||||
fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result {
|
||||
let (shape, shape_blink) = match SHAPE.load(Ordering::Relaxed) {
|
||||
u8::MAX => (0, false),
|
||||
n => (n.max(1).div_ceil(2), n.max(1) & 1 == 1),
|
||||
u8::MAX => (0, None),
|
||||
n => (n.max(1).div_ceil(2), Some(n.max(1) & 1 == 1)),
|
||||
};
|
||||
|
||||
let blink = BLINK.load(Ordering::Relaxed) ^ shape_blink;
|
||||
let blink = shape_blink.unwrap_or(BLINK.load(Ordering::Relaxed));
|
||||
Ok(match shape {
|
||||
2 if blink => SetCursorStyle::BlinkingUnderScore.write_ansi(f)?,
|
||||
2 if !blink => SetCursorStyle::SteadyUnderScore.write_ansi(f)?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue