summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/term/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-04-17 23:20:13 +0000
committerGitHub <noreply@github.com>2021-04-17 23:20:13 +0000
commit28abb1f9c78ab316126bdf94e2ca12f034f1d8fd (patch)
tree623eabe9b4760fc4674f36a8f953e344b0e655e3 /alacritty_terminal/src/term/mod.rs
parenta312e415951fcb9156572f124b42f68c09f60ae9 (diff)
downloadalacritty-28abb1f9c78ab316126bdf94e2ca12f034f1d8fd.tar.gz
alacritty-28abb1f9c78ab316126bdf94e2ca12f034f1d8fd.zip
Fix out of order terminal query responses
This forces all responses made to the PTY through the indirection of the UI event loop, making sure that the writes to the PTY are in the same order as the original requests. This just delays all escape sequences by forcing them through the event loop, ideally all responses which are not asynchronous (like a clipboard read) would be made immediately. However since some escapes require feedback from the UI to mutable structures like the config (e.g. color query escapes), this would require additional locking. Fixes #4872.
Diffstat (limited to 'alacritty_terminal/src/term/mod.rs')
-rw-r--r--alacritty_terminal/src/term/mod.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index c4425916..199fd207 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -3,7 +3,7 @@
use std::cmp::{max, min};
use std::ops::{Index, IndexMut, Range};
use std::sync::Arc;
-use std::{io, mem, ptr, str};
+use std::{mem, ptr, str};
use bitflags::bitflags;
use log::{debug, trace};
@@ -968,32 +968,35 @@ impl<T: EventListener> Handler for Term<T> {
}
#[inline]
- fn identify_terminal<W: io::Write>(&mut self, writer: &mut W, intermediate: Option<char>) {
+ fn identify_terminal(&mut self, intermediate: Option<char>) {
match intermediate {
None => {
trace!("Reporting primary device attributes");
- let _ = writer.write_all(b"\x1b[?6c");
+ let text = String::from("\x1b[?6c");
+ self.event_proxy.send_event(Event::PtyWrite(text));
},
Some('>') => {
trace!("Reporting secondary device attributes");
let version = version_number(env!("CARGO_PKG_VERSION"));
- let _ = writer.write_all(format!("\x1b[>0;{};1c", version).as_bytes());
+ let text = format!("\x1b[>0;{};1c", version);
+ self.event_proxy.send_event(Event::PtyWrite(text));
},
_ => debug!("Unsupported device attributes intermediate"),
}
}
#[inline]
- fn device_status<W: io::Write>(&mut self, writer: &mut W, arg: usize) {
+ fn device_status(&mut self, arg: usize) {
trace!("Reporting device status: {}", arg);
match arg {
5 => {
- let _ = writer.write_all(b"\x1b[0n");
+ let text = String::from("\x1b[0n");
+ self.event_proxy.send_event(Event::PtyWrite(text));
},
6 => {
let pos = self.grid.cursor.point;
- let response = format!("\x1b[{};{}R", pos.line + 1, pos.column + 1);
- let _ = writer.write_all(response.as_bytes());
+ let text = format!("\x1b[{};{}R", pos.line + 1, pos.column + 1);
+ self.event_proxy.send_event(Event::PtyWrite(text));
},
_ => debug!("unknown device status query: {}", arg),
};
@@ -1687,15 +1690,17 @@ impl<T: EventListener> Handler for Term<T> {
}
#[inline]
- fn text_area_size_pixels<W: io::Write>(&mut self, writer: &mut W) {
+ fn text_area_size_pixels(&mut self) {
let width = self.cell_width * self.columns();
let height = self.cell_height * self.screen_lines();
- let _ = write!(writer, "\x1b[4;{};{}t", height, width);
+ let text = format!("\x1b[4;{};{}t", height, width);
+ self.event_proxy.send_event(Event::PtyWrite(text));
}
#[inline]
- fn text_area_size_chars<W: io::Write>(&mut self, writer: &mut W) {
- let _ = write!(writer, "\x1b[8;{};{}t", self.screen_lines(), self.columns());
+ fn text_area_size_chars(&mut self) {
+ let text = format!("\x1b[8;{};{}t", self.screen_lines(), self.columns());
+ self.event_proxy.send_event(Event::PtyWrite(text));
}
}