summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2024-03-02 05:35:55 -0800
committerGitHub <noreply@github.com>2024-03-02 08:35:55 -0500
commit037665ba37593665e5566fee8ac580ef6bbb170a (patch)
tree85de8cf68370b6f741d551a84d9ea2585318e38b
parent084a6d19b2054f8778c375862f8e4ed3d9145120 (diff)
Switch from vte to anstyle-parse (already used in dependencies) (#1638)
delta already depends indirectly on anstyle-parse through clap. Switch from vte to anstyle-parse to eliminate a few dependencies.
-rw-r--r--Cargo.lock33
-rw-r--r--Cargo.toml2
-rw-r--r--src/ansi/iterator.rs14
3 files changed, 11 insertions, 38 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6b47c5d1..799e362e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -73,9 +73,9 @@ checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
[[package]]
name = "anstyle-parse"
-version = "0.2.1"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
+checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
@@ -115,12 +115,6 @@ dependencies = [
]
[[package]]
-name = "arrayvec"
-version = "0.7.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
-
-[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -560,6 +554,7 @@ version = "0.16.5"
dependencies = [
"ansi_colours",
"ansi_term",
+ "anstyle-parse",
"anyhow",
"bat",
"bitflags 2.3.3",
@@ -587,7 +582,6 @@ dependencies = [
"sysinfo",
"unicode-segmentation",
"unicode-width",
- "vte",
"xdg",
]
@@ -1475,27 +1469,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
-name = "vte"
-version = "0.11.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197"
-dependencies = [
- "arrayvec",
- "utf8parse",
- "vte_generate_state_changes",
-]
-
-[[package]]
-name = "vte_generate_state_changes"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
-dependencies = [
- "proc-macro2",
- "quote",
-]
-
-[[package]]
name = "walkdir"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 5aa04339..5b80a058 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,6 +20,7 @@ chrono = "0.4.26"
chrono-humanize = "0.2.2"
ansi_colours = "1.2.1"
ansi_term = "0.12.1"
+anstyle-parse = "0.2.3"
anyhow = "1.0.70"
bitflags = "2.2.1"
box_drawing = "0.1.2"
@@ -41,7 +42,6 @@ smol_str = "0.1.24"
syntect = "5.0.0"
unicode-segmentation = "1.10.1"
unicode-width = "0.1.10"
-vte = "0.11.0"
xdg = "2.4.1"
clap_complete = "4.4.4"
diff --git a/src/ansi/iterator.rs b/src/ansi/iterator.rs
index 6318fd51..e380fbad 100644
--- a/src/ansi/iterator.rs
+++ b/src/ansi/iterator.rs
@@ -1,14 +1,14 @@
+use anstyle_parse::{Params, ParamsIter};
use core::str::Bytes;
use std::convert::TryFrom;
use std::iter;
-use vte::{Params, ParamsIter};
pub struct AnsiElementIterator<'a> {
// The input bytes
bytes: Bytes<'a>,
// The state machine
- machine: vte::Parser,
+ machine: anstyle_parse::Parser,
// Becomes non-None when the parser finishes parsing an ANSI sequence.
// This is never Element::Text.
@@ -61,7 +61,7 @@ impl Element {
impl<'a> AnsiElementIterator<'a> {
pub fn new(s: &'a str) -> Self {
Self {
- machine: vte::Parser::new(),
+ machine: anstyle_parse::Parser::<anstyle_parse::DefaultCharAccumulator>::new(),
bytes: s.bytes(),
element: None,
text_length: 0,
@@ -120,13 +120,13 @@ impl<'a> Iterator for AnsiElementIterator<'a> {
}
// Based on https://github.com/alacritty/vte/blob/v0.9.0/examples/parselog.rs
-impl vte::Perform for Performer {
- fn csi_dispatch(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: char) {
+impl anstyle_parse::Perform for Performer {
+ fn csi_dispatch(&mut self, params: &Params, intermediates: &[u8], ignore: bool, byte: u8) {
if ignore || intermediates.len() > 1 {
return;
}
- let is_sgr = c == 'm' && intermediates.first().is_none();
+ let is_sgr = byte == b'm' && intermediates.first().is_none();
let element = if is_sgr {
if params.is_empty() {
// Attr::Reset
@@ -154,7 +154,7 @@ impl vte::Perform for Performer {
}
}
- fn hook(&mut self, _params: &Params, _intermediates: &[u8], _ignore: bool, _c: char) {}
+ fn hook(&mut self, _params: &Params, _intermediates: &[u8], _ignore: bool, _byte: u8) {}
fn put(&mut self, _byte: u8) {}