mirror of
https://github.com/wez/wezterm.git
synced 2024-11-28 01:06:37 +03:00
run down an off-by-one in VPA handling
This manifested with vim-inside-tmux losing my top tmux status line. Add a test!
This commit is contained in:
parent
0870e6c7e4
commit
ad3524bfc8
@ -486,7 +486,7 @@ impl<'a> Iterator for CSIParser<'a> {
|
|||||||
|
|
||||||
// VPA: Line Position Absolute
|
// VPA: Line Position Absolute
|
||||||
('d', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Absolute(0))),
|
('d', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Absolute(0))),
|
||||||
('d', &[], Some(&[n])) => Some(CSIAction::LinePosition(Position::Absolute(n))),
|
('d', &[], Some(&[n])) => Some(CSIAction::LinePosition(Position::Absolute(n - 1))),
|
||||||
|
|
||||||
// VPR: Line Position Relative
|
// VPR: Line Position Relative
|
||||||
('e', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Relative(0))),
|
('e', &[], Some(&[])) => Some(CSIAction::LinePosition(Position::Relative(0))),
|
||||||
|
@ -97,11 +97,11 @@ impl Screen {
|
|||||||
) -> &Cell {
|
) -> &Cell {
|
||||||
let line_idx = self.phys_row(y);
|
let line_idx = self.phys_row(y);
|
||||||
debug!(
|
debug!(
|
||||||
"set_cell x,y {},{}, line_idx = {} {} {:?}",
|
"set_cell {} x={} y={} phys={} {:?}",
|
||||||
|
c,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
line_idx,
|
line_idx,
|
||||||
c,
|
|
||||||
attr
|
attr
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -177,6 +177,7 @@ impl Screen {
|
|||||||
/// If the top of the region is the top of the visible display, rather than
|
/// If the top of the region is the top of the visible display, rather than
|
||||||
/// removing the lines we let them go into the scrollback.
|
/// removing the lines we let them go into the scrollback.
|
||||||
pub fn scroll_up(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
|
pub fn scroll_up(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
|
||||||
|
debug!("scroll_up {:?} {}", scroll_region, num_rows);
|
||||||
let phys_scroll = self.phys_range(&scroll_region);
|
let phys_scroll = self.phys_range(&scroll_region);
|
||||||
assert!(num_rows <= phys_scroll.end - phys_scroll.start);
|
assert!(num_rows <= phys_scroll.end - phys_scroll.start);
|
||||||
|
|
||||||
@ -233,6 +234,7 @@ impl Screen {
|
|||||||
/// In other words, we remove (bottom-num_rows..bottom) and then insert num_rows
|
/// In other words, we remove (bottom-num_rows..bottom) and then insert num_rows
|
||||||
/// at scroll_top.
|
/// at scroll_top.
|
||||||
pub fn scroll_down(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
|
pub fn scroll_down(&mut self, scroll_region: &Range<VisibleRowIndex>, num_rows: usize) {
|
||||||
|
debug!("scroll_down {:?} {}", scroll_region, num_rows);
|
||||||
let phys_scroll = self.phys_range(&scroll_region);
|
let phys_scroll = self.phys_range(&scroll_region);
|
||||||
assert!(num_rows <= phys_scroll.end - phys_scroll.start);
|
assert!(num_rows <= phys_scroll.end - phys_scroll.start);
|
||||||
|
|
||||||
|
@ -1147,10 +1147,12 @@ impl vte::Perform for TerminalState {
|
|||||||
(b'\\', &[], &[]) => {}
|
(b'\\', &[], &[]) => {}
|
||||||
// Application Keypad (DECKPAM)
|
// Application Keypad (DECKPAM)
|
||||||
(b'=', &[], &[]) => {
|
(b'=', &[], &[]) => {
|
||||||
|
debug!("DECKPAM on");
|
||||||
self.application_keypad = true;
|
self.application_keypad = true;
|
||||||
}
|
}
|
||||||
// Normal Keypad (DECKPAM)
|
// Normal Keypad (DECKPAM)
|
||||||
(b'>', &[], &[]) => {
|
(b'>', &[], &[]) => {
|
||||||
|
debug!("DECKPAM off");
|
||||||
self.application_keypad = false;
|
self.application_keypad = false;
|
||||||
}
|
}
|
||||||
// Reverse Index (RI)
|
// Reverse Index (RI)
|
||||||
@ -1163,9 +1165,13 @@ impl vte::Perform for TerminalState {
|
|||||||
(b'H', &[], &[]) => self.c1_hts(),
|
(b'H', &[], &[]) => self.c1_hts(),
|
||||||
|
|
||||||
// Enable alternate character set mode (smacs)
|
// Enable alternate character set mode (smacs)
|
||||||
(b'0', &[b'('], &[]) => {}
|
(b'0', &[b'('], &[]) => {
|
||||||
|
debug!("ESC: smacs");
|
||||||
|
}
|
||||||
// Exit alternate character set mode (rmacs)
|
// Exit alternate character set mode (rmacs)
|
||||||
(b'B', &[b'('], &[]) => {}
|
(b'B', &[b'('], &[]) => {
|
||||||
|
debug!("ESC: rmacs");
|
||||||
|
}
|
||||||
|
|
||||||
// DECSC - Save Cursor
|
// DECSC - Save Cursor
|
||||||
(b'7', &[], &[]) => self.perform_csi(CSIAction::SaveCursor),
|
(b'7', &[], &[]) => self.perform_csi(CSIAction::SaveCursor),
|
||||||
|
18
term/src/test/csi.rs
Normal file
18
term/src/test/csi.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_vpa() {
|
||||||
|
let mut term = TestTerm::new(3, 4, 0);
|
||||||
|
term.assert_cursor_pos(0, 0, None);
|
||||||
|
term.print("a\nb\nc");
|
||||||
|
term.assert_cursor_pos(1, 2, None);
|
||||||
|
term.print("\x1b[d");
|
||||||
|
term.assert_cursor_pos(1, 0, None);
|
||||||
|
term.print("\n\n");
|
||||||
|
term.assert_cursor_pos(0, 2, None);
|
||||||
|
|
||||||
|
// escapes are 1-based, so check that we're handling that
|
||||||
|
// when we parse them!
|
||||||
|
term.print("\x1b[2d");
|
||||||
|
term.assert_cursor_pos(0, 1, None);
|
||||||
|
}
|
@ -5,6 +5,7 @@ use super::*;
|
|||||||
mod selection;
|
mod selection;
|
||||||
mod c0;
|
mod c0;
|
||||||
mod c1;
|
mod c1;
|
||||||
|
mod csi;
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct TestHost {
|
struct TestHost {
|
||||||
|
Loading…
Reference in New Issue
Block a user