mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-11 13:51:16 -03:00
Buffer OSC 0 terminal title writing
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::ffi::CStr;
|
||||
use std::io::{Result, Write};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::os::fd::RawFd;
|
||||
use std::sync::atomic::{AtomicU8, Ordering};
|
||||
|
||||
@@ -481,6 +482,20 @@ fn drop(&mut self) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for BufferedOutputter<'_> {
|
||||
type Target = Outputter;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for BufferedOutputter<'_> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Output for BufferedOutputter<'a> {
|
||||
fn write_bytes(&mut self, buf: &[u8]) {
|
||||
self.0.write_bytes(buf);
|
||||
|
||||
@@ -4535,6 +4535,7 @@ pub fn reader_write_title(
|
||||
Some(&mut lst),
|
||||
/*apply_exit_status=*/ false,
|
||||
);
|
||||
let mut out = BufferedOutputter::new(Outputter::stdoutput());
|
||||
if !lst.is_empty() {
|
||||
let mut title_line = L!("\x1B]0;").to_owned();
|
||||
for val in &lst {
|
||||
@@ -4542,15 +4543,13 @@ pub fn reader_write_title(
|
||||
}
|
||||
title_line.push_str("\x07"); // BEL
|
||||
let narrow = wcs2string(&title_line);
|
||||
let _ = write_loop(&STDOUT_FILENO, &narrow);
|
||||
out.write_bytes(&narrow);
|
||||
}
|
||||
|
||||
Outputter::stdoutput()
|
||||
.borrow_mut()
|
||||
.set_color(RgbColor::RESET, RgbColor::RESET);
|
||||
out.set_color(RgbColor::RESET, RgbColor::RESET);
|
||||
if reset_cursor_position && !lst.is_empty() {
|
||||
// Put the cursor back at the beginning of the line (issue #2453).
|
||||
let _ = write_loop(&STDOUT_FILENO, b"\r");
|
||||
out.write_bytes(b"\r");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user