From 2de60e379193ef352f3fab507811a94208cb82dd Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 25 Jan 2020 20:35:33 -0800 Subject: [PATCH] vttest: handle dec origin mode This makes us pass the cursor positioning tests (with the exception of the 132 column mode) refs: https://github.com/wez/wezterm/issues/133 --- term/src/terminalstate.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index 1b01c1a9b..6d12a3608 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -788,7 +788,6 @@ impl TerminalState { /// Sets the cursor position. x and y are 0-based and relative to the /// top left of the visible screen. - /// TODO: DEC origin mode impacts the interpreation of these fn set_cursor_pos(&mut self, x: &Position, y: &Position) { let x = match *x { Position::Relative(x) => (self.cursor.x as i64 + x).max(0), @@ -802,12 +801,17 @@ impl TerminalState { let rows = self.screen().physical_rows; let cols = self.screen().physical_cols; let old_y = self.cursor.y; - let new_y = y.min(rows as i64 - 1); self.cursor.x = x.min(cols as i64 - 1) as usize; - self.cursor.y = new_y; + + if self.dec_origin_mode { + self.cursor.y = (self.scroll_region.start + y).min(self.scroll_region.end - 1); + } else { + self.cursor.y = y.min(rows as i64 - 1); + } self.wrap_next = false; + let new_y = self.cursor.y; let screen = self.screen_mut(); screen.dirty_line(old_y); screen.dirty_line(new_y);