mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +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(),
|
TTY.writer(),
|
||||||
yazi_term::If(!TMUX.get(), EnterAlternateScreen),
|
yazi_term::If(!TMUX.get(), EnterAlternateScreen),
|
||||||
Print("\x1bP$q q\x1b\\"), // Request cursor shape (DECRQSS query for DECSCUSR)
|
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("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
|
||||||
Print(Mux::csi("\x1b[0c")), // Request device attributes
|
Print(Mux::csi("\x1b[0c")), // Request device attributes
|
||||||
yazi_term::If(TMUX.get(), EnterAlternateScreen),
|
yazi_term::If(TMUX.get(), EnterAlternateScreen),
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,13 @@ use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
||||||
|
|
||||||
use crossterm::cursor::SetCursorStyle;
|
use crossterm::cursor::SetCursorStyle;
|
||||||
|
|
||||||
static BLINK: AtomicBool = AtomicBool::new(false);
|
|
||||||
static SHAPE: AtomicU8 = AtomicU8::new(0);
|
static SHAPE: AtomicU8 = AtomicU8::new(0);
|
||||||
|
static BLINK: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
pub struct RestoreCursor;
|
pub struct RestoreCursor;
|
||||||
|
|
||||||
impl RestoreCursor {
|
impl RestoreCursor {
|
||||||
pub fn store(resp: &str) {
|
pub fn store(resp: &str) {
|
||||||
BLINK.store(resp.contains("\x1b[?12;1$y"), Ordering::Relaxed);
|
|
||||||
SHAPE.store(
|
SHAPE.store(
|
||||||
resp
|
resp
|
||||||
.split_once("\x1bP1$r")
|
.split_once("\x1bP1$r")
|
||||||
|
|
@ -18,17 +17,18 @@ impl RestoreCursor {
|
||||||
.map_or(u8::MAX, |b| b - b'0'),
|
.map_or(u8::MAX, |b| b - b'0'),
|
||||||
Ordering::Relaxed,
|
Ordering::Relaxed,
|
||||||
);
|
);
|
||||||
|
BLINK.store(resp.contains("\x1b[?12;1$y"), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crossterm::Command for RestoreCursor {
|
impl crossterm::Command for RestoreCursor {
|
||||||
fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result {
|
fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result {
|
||||||
let (shape, shape_blink) = match SHAPE.load(Ordering::Relaxed) {
|
let (shape, shape_blink) = match SHAPE.load(Ordering::Relaxed) {
|
||||||
u8::MAX => (0, false),
|
u8::MAX => (0, None),
|
||||||
n => (n.max(1).div_ceil(2), n.max(1) & 1 == 1),
|
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 {
|
Ok(match shape {
|
||||||
2 if blink => SetCursorStyle::BlinkingUnderScore.write_ansi(f)?,
|
2 if blink => SetCursorStyle::BlinkingUnderScore.write_ansi(f)?,
|
||||||
2 if !blink => SetCursorStyle::SteadyUnderScore.write_ansi(f)?,
|
2 if !blink => SetCursorStyle::SteadyUnderScore.write_ansi(f)?,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue