mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Make number of scrollback lines configurable
This commit is contained in:
parent
001b780dda
commit
5c648a34aa
5 changed files with 33 additions and 18 deletions
|
@ -33,6 +33,9 @@ window:
|
||||||
# Setting this to false will result in window without borders and title bar.
|
# Setting this to false will result in window without borders and title bar.
|
||||||
decorations: true
|
decorations: true
|
||||||
|
|
||||||
|
# How many lines of scrollback to keep
|
||||||
|
scroll_history: 10000
|
||||||
|
|
||||||
# Display tabs using this many cells (changes require restart)
|
# Display tabs using this many cells (changes require restart)
|
||||||
tabspaces: 8
|
tabspaces: 8
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ window:
|
||||||
# Setting this to false will result in window without borders and title bar.
|
# Setting this to false will result in window without borders and title bar.
|
||||||
decorations: true
|
decorations: true
|
||||||
|
|
||||||
|
# How many lines of scrollback to keep
|
||||||
|
scroll_history: 10000
|
||||||
|
|
||||||
# Display tabs using this many cells (changes require restart)
|
# Display tabs using this many cells (changes require restart)
|
||||||
tabspaces: 8
|
tabspaces: 8
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,14 @@ pub struct Config {
|
||||||
/// Number of spaces in one tab
|
/// Number of spaces in one tab
|
||||||
#[serde(default="default_tabspaces", deserialize_with = "deserialize_tabspaces")]
|
#[serde(default="default_tabspaces", deserialize_with = "deserialize_tabspaces")]
|
||||||
tabspaces: usize,
|
tabspaces: usize,
|
||||||
|
|
||||||
|
/// How much scrolling history to keep
|
||||||
|
#[serde(default="default_scroll_history")]
|
||||||
|
scroll_history: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_scroll_history() -> u32 {
|
||||||
|
10_000
|
||||||
}
|
}
|
||||||
|
|
||||||
fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T>, D::Error>
|
fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T>, D::Error>
|
||||||
|
@ -1244,6 +1252,10 @@ impl Config {
|
||||||
.map(|path| path.into())
|
.map(|path| path.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn scroll_history(&self) -> usize {
|
||||||
|
self.scroll_history as _
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
|
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
|
||||||
let path = ::xdg::BaseDirectories::with_prefix("alacritty")
|
let path = ::xdg::BaseDirectories::with_prefix("alacritty")
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::NotFound, ::std::error::Error::description(&err)))
|
.map_err(|err| io::Error::new(io::ErrorKind::NotFound, ::std::error::Error::description(&err)))
|
||||||
|
|
|
@ -28,9 +28,6 @@ mod tests;
|
||||||
mod storage;
|
mod storage;
|
||||||
use self::storage::Storage;
|
use self::storage::Storage;
|
||||||
|
|
||||||
/// Lines to keep in scrollback buffer
|
|
||||||
const SCROLLBACK_LINES: usize = 10_000;
|
|
||||||
|
|
||||||
/// Convert a type to a linear index range.
|
/// Convert a type to a linear index range.
|
||||||
pub trait ToRange {
|
pub trait ToRange {
|
||||||
fn to_range(&self) -> RangeInclusive<index::Linear>;
|
fn to_range(&self) -> RangeInclusive<index::Linear>;
|
||||||
|
@ -101,19 +98,8 @@ pub struct GridIterator<'a, T: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Copy + Clone> Grid<T> {
|
impl<T: Copy + Clone> Grid<T> {
|
||||||
pub fn scroll_display(&mut self, count: isize) {
|
pub fn new(lines: index::Line, cols: index::Column, scrollback: usize, template: T) -> Grid<T> {
|
||||||
self.display_offset = min(
|
let mut raw = Storage::with_capacity(*lines + scrollback, lines);
|
||||||
max((self.display_offset as isize) + count, 0isize) as usize,
|
|
||||||
self.scroll_limit
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reset_scroll(&mut self) {
|
|
||||||
self.display_offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(lines: index::Line, cols: index::Column, template: T) -> Grid<T> {
|
|
||||||
let mut raw = Storage::with_capacity(*lines + SCROLLBACK_LINES, lines);
|
|
||||||
let template_row = Row::new(cols, &template);
|
let template_row = Row::new(cols, &template);
|
||||||
|
|
||||||
// Allocate all lines in the buffer, including scrollback history
|
// Allocate all lines in the buffer, including scrollback history
|
||||||
|
@ -137,6 +123,17 @@ impl<T: Copy + Clone> Grid<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn scroll_display(&mut self, count: isize) {
|
||||||
|
self.display_offset = min(
|
||||||
|
max((self.display_offset as isize) + count, 0isize) as usize,
|
||||||
|
self.scroll_limit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_scroll_display(&mut self) {
|
||||||
|
self.display_offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, lines: index::Line, cols: index::Column) {
|
pub fn resize(&mut self, lines: index::Line, cols: index::Column) {
|
||||||
// Check that there's actually work to do and return early if not
|
// Check that there's actually work to do and return early if not
|
||||||
if lines == self.lines && cols == self.cols {
|
if lines == self.lines && cols == self.cols {
|
||||||
|
|
|
@ -808,7 +808,7 @@ impl Term {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_scroll(&mut self) {
|
pub fn reset_scroll(&mut self) {
|
||||||
self.grid.reset_scroll();
|
self.grid.reset_scroll_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -822,7 +822,7 @@ impl Term {
|
||||||
let num_cols = size.cols();
|
let num_cols = size.cols();
|
||||||
let num_lines = size.lines();
|
let num_lines = size.lines();
|
||||||
|
|
||||||
let grid = Grid::new(num_lines, num_cols, template);
|
let grid = Grid::new(num_lines, num_cols, config.scroll_history(), template);
|
||||||
|
|
||||||
let tabspaces = config.tabspaces();
|
let tabspaces = config.tabspaces();
|
||||||
let tabs = IndexRange::from(Column(0)..grid.num_cols())
|
let tabs = IndexRange::from(Column(0)..grid.num_cols())
|
||||||
|
|
Loading…
Reference in a new issue