From b19b92e4482b080d23d867a9750ec21492848b43 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 6 Jun 2016 03:05:51 -0400 Subject: bump libvt100 this requires some workarounds since we might have extra scrollback length even if we didn't ask for it (because of the optimization to move scrollback around in chunks). not sure if i'm happy about the workarounds here - we should maybe disable that optimization if no scrollback at all was requested, but this at least gets tests passing for now --- libvt100 | 2 +- src/screen.rs | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libvt100 b/libvt100 index bd9fc2b..32f97d8 160000 --- a/libvt100 +++ b/libvt100 @@ -1 +1 @@ -Subproject commit bd9fc2ba0396f04df399c1f685aacced84128518 +Subproject commit 32f97d8385d591ec4026f3fb5a1ab8e34e12a06d diff --git a/src/screen.rs b/src/screen.rs index fd143d7..1073a6b 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -12,6 +12,12 @@ pub struct Screen(*mut types::ScreenImpl); struct ScreenGridPrefix { cur: types::Loc, max: types::Loc, + saved: types::Loc, + scroll_top: libc::c_int, + scroll_bottom: libc::c_int, + row_count: libc::c_int, + row_capacity: libc::c_int, + row_top: libc::c_int, } #[repr(C)] @@ -79,10 +85,19 @@ impl Screen { col_end: i32 ) -> String { let Screen(screen_impl) = *self; + let prefix: *mut ScreenPrefix = unsafe { + std::mem::transmute(screen_impl) + }; + + // XXX not super happy about this - can we maybe disable the + // optimization in libvt100 if no scrollback at all was requested? + let grid_max_row = unsafe { (*(*prefix).grid).max.row }; + let row_count = unsafe { (*(*prefix).grid).row_count }; + let row_start = std::cmp::min( std::cmp::max(row_start, 0), self.rows() - 1 - ); + ) + row_count - grid_max_row; let col_start = std::cmp::min( std::cmp::max(col_start, 0), self.cols() - 1 @@ -90,7 +105,7 @@ impl Screen { let row_end = std::cmp::min( std::cmp::max(row_end, 0), self.rows() - 1 - ); + ) + row_count - grid_max_row; let col_end = std::cmp::min( std::cmp::max(col_end, 0), self.cols() - 1 @@ -126,10 +141,17 @@ impl Screen { col_end: i32 ) -> String { let Screen(screen_impl) = *self; + let prefix: *mut ScreenPrefix = unsafe { + std::mem::transmute(screen_impl) + }; + + let grid_max_row = unsafe { (*(*prefix).grid).max.row }; + let row_count = unsafe { (*(*prefix).grid).row_count }; + let row_start = std::cmp::min( std::cmp::max(row_start, 0), self.rows() - 1 - ); + ) + row_count - grid_max_row; let col_start = std::cmp::min( std::cmp::max(col_start, 0), self.cols() - 1 @@ -137,7 +159,7 @@ impl Screen { let row_end = std::cmp::min( std::cmp::max(row_end, 0), self.rows() - 1 - ); + ) + row_count - grid_max_row; let col_end = std::cmp::min( std::cmp::max(col_end, 0), self.cols() - 1 -- cgit v1.2.3-54-g00ecf