From 65d068b0fa4d269c8d985821ac016bb2dd911473 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Wed, 2 Oct 2024 23:10:00 +0200 Subject: [PATCH 1/4] metadata --- Cargo.toml | 10 +++++----- LICENSE | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce8f9af1..3ae91a0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "vt100" -version = "0.15.2" -authors = ["Jesse Luehrs "] +version = "0.16.0" +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 a1dd5b0e..7c4e759a 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 From ca2f740ae95e796817672bb938dce5a5e8d1948a Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Wed, 2 Oct 2024 23:14:54 +0200 Subject: [PATCH 2/4] some patches --- src/grid.rs | 9 ++++++++- src/lib.rs | 4 +--- src/perform.rs | 2 +- src/screen.rs | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/grid.rs b/src/grid.rs index fc236bc0..29d3aad5 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -122,7 +122,14 @@ 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 0c7e7dab..aee38955 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)] @@ -60,4 +58,4 @@ pub use attrs::Color; pub use callbacks::Callbacks; pub use cell::Cell; pub use parser::Parser; -pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen}; +pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen}; \ No newline at end of file diff --git a/src/perform.rs b/src/perform.rs index d528cb4e..ecf0aa43 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 73b904e9..0d320512 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 From 74b0909548c684ac0335b67dca9451d70919cd0a Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Wed, 2 Oct 2024 23:15:18 +0200 Subject: [PATCH 3/4] formatting --- src/grid.rs | 6 +++++- src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/grid.rs b/src/grid.rs index 29d3aad5..20041d2c 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -129,7 +129,11 @@ impl Grid { .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))) + .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 aee38955..922adaf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,4 +58,4 @@ pub use attrs::Color; pub use callbacks::Callbacks; pub use cell::Cell; pub use parser::Parser; -pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen}; \ No newline at end of file +pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen}; From fab0f6988146abe77302d47c0db9cf580c4c6962 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Wed, 2 Oct 2024 23:27:17 +0200 Subject: [PATCH 4/4] revert crate version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3ae91a0c..76235399 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vt100" -version = "0.16.0" +version = "0.15.2" authors = ["Chris Titus ", "Jesse Luehrs "] edition = "2021"