diff --git a/Cargo.toml b/Cargo.toml index ce8f9af..7623539 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "vt100" version = "0.15.2" -authors = ["Jesse Luehrs "] +authors = ["Chris Titus ", "Jesse Luehrs "] edition = "2021" -description = "Library for parsing terminal data" -homepage = "https://github.com/doy/vt100-rust" -repository = "https://github.com/doy/vt100-rust" +description = "Library for parsing terminal data - up-to-date version" +homepage = "https://github.com/ChrisTitusTech/vt100-rust" +repository = "https://github.com/ChrisTitusTech/vt100-rust" readme = "README.md" keywords = ["terminal", "vt100"] categories = ["command-line-interface", "encoding"] diff --git a/LICENSE b/LICENSE index a1dd5b0..7c4e759 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ -The MIT License (MIT) +MIT License +Copyright (c) 2024 Chris Titus Copyright (c) 2016 Jesse Luehrs Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/src/grid.rs b/src/grid.rs index fc236bc..20041d2 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -122,7 +122,18 @@ impl Grid { self.scrollback .iter() .skip(scrollback_len - self.scrollback_offset) - .chain(self.rows.iter().take(rows_len - self.scrollback_offset)) + // when scrollback_offset > rows_len (e.g. rows = 3, + // scrollback_len = 10, offset = 9) the skip(10 - 9) + // will take 9 rows instead of 3. we need to set + // the upper bound to rows_len (e.g. 3) + .take(rows_len) + // same for rows_len - scrollback_offset (e.g. 3 - 9). + // it'll panic with overflow. we have to saturate the subtraction. + .chain( + self.rows + .iter() + .take(rows_len.saturating_sub(self.scrollback_offset)), + ) } pub fn drawing_rows(&self) -> impl Iterator { diff --git a/src/lib.rs b/src/lib.rs index 0c7e7da..922adaf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,9 +33,7 @@ //! ); //! ``` -#![warn(clippy::cargo)] #![warn(clippy::pedantic)] -#![warn(clippy::nursery)] #![warn(clippy::as_conversions)] #![warn(clippy::get_unwrap)] #![allow(clippy::cognitive_complexity)] diff --git a/src/perform.rs b/src/perform.rs index d528cb4..ecf0aa4 100644 --- a/src/perform.rs +++ b/src/perform.rs @@ -119,7 +119,7 @@ impl vte::Perform for WrappedScreen { } fn osc_dispatch(&mut self, params: &[&[u8]], _bel_terminated: bool) { - match (params.get(0), params.get(1)) { + match (params.first(), params.get(1)) { (Some(&b"0"), Some(s)) => self.0.osc0(s), (Some(&b"1"), Some(s)) => self.0.osc1(s), (Some(&b"2"), Some(s)) => self.0.osc2(s), diff --git a/src/screen.rs b/src/screen.rs index 73b904e..0d32051 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -1502,7 +1502,7 @@ impl Screen { } fn u16_to_u8(i: u16) -> Option { - if i > u16::from(u8::max_value()) { + if i > u16::from(u8::MAX) { None } else { // safe because we just ensured that the value fits in a u8