1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

term: Make CUB behave like Backspace, as xterm does

closes: https://github.com/wez/wezterm/issues/1273
This commit is contained in:
Wez Furlong 2021-12-02 20:50:11 -07:00
parent 9a25a6deed
commit a61fa57d97
2 changed files with 10 additions and 25 deletions

View File

@ -1951,32 +1951,9 @@ impl TerminalState {
Cursor::TabulationControl(_) => {}
Cursor::LineTabulation(_) => {}
Cursor::Left(n) => {
Cursor::Left(_n) => {
// https://vt100.net/docs/vt510-rm/CUB.html
let candidate = self.cursor.x as i64 - n as i64;
let new_x = if self.cursor.x < self.left_and_right_margins.start {
// outside the margin, so allow movement to the border
candidate
} else {
// Else constrain to margin
if candidate < self.left_and_right_margins.start as i64 {
if self.reverse_wraparound_mode && self.dec_auto_wrap {
self.left_and_right_margins.end as i64
- (self.left_and_right_margins.start as i64 - candidate)
} else {
self.left_and_right_margins.start as i64
}
} else {
candidate
}
};
let new_x = new_x.max(0) as usize;
self.cursor.x = new_x;
self.cursor.seqno = seqno;
self.wrap_next = false;
unreachable!("Actually handled in Performer::csi_dispatch by rewriting as ControlCode::Backspace");
}
Cursor::Right(n) => {

View File

@ -372,6 +372,14 @@ impl<'a> Performer<'a> {
self.flush_print();
match csi {
CSI::Sgr(sgr) => self.state.perform_csi_sgr(sgr),
CSI::Cursor(termwiz::escape::csi::Cursor::Left(n)) => {
// We treat CUB (Cursor::Left) the same as Backspace as
// that is what xterm does.
// <https://github.com/wez/wezterm/issues/1273>
for _ in 0..n {
self.control(ControlCode::Backspace);
}
}
CSI::Cursor(cursor) => self.state.perform_csi_cursor(cursor),
CSI::Edit(edit) => self.state.perform_csi_edit(edit),
CSI::Mode(mode) => self.state.perform_csi_mode(mode),