1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

term: fix XTGETTCAP response

refs: https://github.com/wez/wezterm/issues/1781
refs: https://github.com/dankamongmen/notcurses/issues/2637
This commit is contained in:
Wez Furlong 2022-03-27 19:34:12 -07:00
parent a7f70ccf35
commit 6bd6d844ca
2 changed files with 21 additions and 18 deletions

View File

@ -31,6 +31,7 @@ As features stabilize some brief notes about them will accumulate here.
* On Windows, touchpad scrolling was janky. Many thanks to [@davidrios](https://github.coim/davidrios)! [#1773](https://github.com/wez/wezterm/pull/1773) [#1725](https://github.com/wez/wezterm/pull/1725) [#949](https://github.com/wez/wezterm/pull/949)
* X11: workaround i3-gaps not sending initial CONFIGURE_NOTIFY or FOCUS events, leading to weird initial window size and broken focus status. [#1710](https://github.com/wez/wezterm/issues/1710) [#1757](https://github.com/wez/wezterm/issues/1757)
* Hyperlink rules with more captures than replacements could panic wezterm when text matched. [#1780](https://github.com/wez/wezterm/issues/1780)
* Malformed XTGETTCAP response. [#1781](https://github.com/wez/wezterm/issues/1781)
### 20220319-142410-0fcdea07

View File

@ -1097,13 +1097,12 @@ impl TerminalState {
}
/// <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Device-Control-functions:DCS-plus-q-Pt-ST.F95>
/// XTGETTCAP
fn xt_get_tcap(&mut self, names: Vec<String>) {
let mut res = "\x1bP".to_string();
let mut res = String::new();
for (i, name) in names.iter().enumerate() {
if i > 0 {
res.push(';');
}
for name in &names {
res.push_str("\x1bP");
let encoded_name = hex::encode_upper(&name);
match name.as_str() {
@ -1120,14 +1119,16 @@ impl TerminalState {
res.push_str("1+r");
res.push_str(&encoded_name);
res.push('=');
res.push_str(&256.to_string());
let encoded_val = hex::encode_upper("256");
res.push_str(&encoded_val);
}
"RGB" => {
res.push_str("1+r");
res.push_str(&encoded_name);
res.push('=');
res.push_str("8/8/8");
let encoded_val = hex::encode_upper("8/8/8");
res.push_str(&encoded_val);
}
_ => {
@ -1135,15 +1136,12 @@ impl TerminalState {
res.push_str("1+r");
res.push_str(&encoded_name);
res.push('=');
match value {
Value::True => res.push('1'),
Value::Number(n) => res.push_str(&n.to_string()),
Value::String(s) => {
for &b in s {
res.push(b as char);
}
}
}
let value = match value {
Value::True => hex::encode_upper("1"),
Value::Number(n) => hex::encode_upper(&n.to_string()),
Value::String(s) => hex::encode_upper(s),
};
res.push_str(&value);
} else {
log::trace!("xt_get_tcap: unknown name {}", name);
res.push_str("0+r");
@ -1151,10 +1149,14 @@ impl TerminalState {
}
}
}
res.push_str("\x1b\\");
}
res.push_str("\x1b\\");
log::trace!("responding with {}", res.escape_debug());
log::trace!(
"XTGETTCAP {:?} responding with {}",
names,
res.escape_debug()
);
self.writer.write_all(res.as_bytes()).ok();
}