aboutsummaryrefslogtreecommitdiff
path: root/src/grid/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-05-30 10:20:47 +0200
committerJoe Wilm <joe@jwilm.com>2018-06-02 10:03:42 -0700
commit4631ca4db5faf10eb0276e3968814a68c86c81ee (patch)
treefed10fa657047e769a07bd1c7c40a0f19683f669 /src/grid/mod.rs
parent24c50fa0a793cd8c6127b5cf8ba3ea59f47cc1ca (diff)
downloadr-alacritty-4631ca4db5faf10eb0276e3968814a68c86c81ee.tar.gz
r-alacritty-4631ca4db5faf10eb0276e3968814a68c86c81ee.tar.bz2
r-alacritty-4631ca4db5faf10eb0276e3968814a68c86c81ee.zip
Allow changing scrollback history size at runtime
Making use of the changes that have been introduced in #1234 and #1284, this allows changing the size of the scrollback buffer at runtime. This simply changes the size of the raw inner buffer making use of the optimized mutation algorithms introduced in #1284. As a result, shrinking the scrollback history size at runtime should be basically free and growing will only introduce a performance cost when there are no more buffered lines. However, as a result there will not be any memory freed when shrinking the scrollback history size at runtime. As discussed in #1234 a potential solution for this could be to truncate the raw buffer whenever more than X lines are deleted, however this issue should not be very significant PR and if a solution is desired a separate issue/PR should be opened. This fixes #1235.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r--src/grid/mod.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index 97614d71..535f6cc6 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -155,6 +155,13 @@ impl<T: Copy + Clone> Grid<T> {
self.line_to_offset(line) + self.display_offset
}
+ /// Update the size of the scrollback history
+ pub fn update_history(&mut self, history_size: usize, template: &T)
+ {
+ self.raw.update_history(history_size, Row::new(self.cols, &template));
+ self.scroll_limit = min(self.scroll_limit, history_size);
+ }
+
pub fn scroll_display(&mut self, scroll: Scroll) {
match scroll {
Scroll::Lines(count) => {