diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event.rs | 10 | ||||
-rw-r--r-- | src/grid/mod.rs | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs index f69136df..c9043a06 100644 --- a/src/event.rs +++ b/src/event.rs @@ -336,6 +336,7 @@ impl<N: Notify> Processor<N> { if ref_test { // dump grid state let mut grid = processor.ctx.terminal.grid().clone(); + grid.initialize_all(&::term::cell::Cell::default()); grid.truncate(); let serialized_grid = json::to_string(&grid) @@ -344,6 +345,11 @@ impl<N: Notify> Processor<N> { let serialized_size = json::to_string(processor.ctx.terminal.size_info()) .expect("serialize size"); + let serialized_config = format!( + "{{\"history_size\":{}}}", + grid.history_size() + ); + File::create("./grid.json") .and_then(|mut f| f.write_all(serialized_grid.as_bytes())) .expect("write grid.json"); @@ -351,6 +357,10 @@ impl<N: Notify> Processor<N> { File::create("./size.json") .and_then(|mut f| f.write_all(serialized_size.as_bytes())) .expect("write size.json"); + + File::create("./config.json") + .and_then(|mut f| f.write_all(serialized_config.as_bytes())) + .expect("write config.json"); } // FIXME should do a more graceful shutdown diff --git a/src/grid/mod.rs b/src/grid/mod.rs index b6313751..113445af 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -435,6 +435,20 @@ impl<T> Grid<T> { self.raw.len() } + #[inline] + pub fn history_size(&self) -> usize { + self.raw.len().saturating_sub(*self.lines) + } + + /// This is used only for initializing after loading ref-tests + pub fn initialize_all(&mut self, template: &T) + where + T: Copy + { + let history_size = self.raw.len().saturating_sub(*self.lines); + self.raw.initialize(self.max_scroll_limit - history_size, Row::new(self.cols, template)); + } + /// This is used only for truncating before saving ref-tests pub fn truncate(&mut self) { self.raw.truncate(); |