Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/anstyle-parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pre-release-replacements = [

[dependencies]
arrayvec = { version = "0.7.2", default-features = false, optional = true }
utf8parse = { version = "0.2.0", optional = true }
utf8parse = { version = "0.2.1", optional = true }

[features]
default = ["utf8"]
Expand Down
6 changes: 3 additions & 3 deletions crates/anstyle-parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const MAX_OSC_PARAMS: usize = 16;
const MAX_OSC_RAW: usize = 1024;

/// Parser for raw _VTE_ protocol which delegates actions to a [`Perform`]
#[derive(Default)]
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct Parser<C = DefaultCharAccumulator> {
state: State,
intermediates: [u8; MAX_INTERMEDIATES],
Expand Down Expand Up @@ -328,7 +328,7 @@ pub type DefaultCharAccumulator = Utf8Parser;
pub type DefaultCharAccumulator = AsciiParser;

/// Only allow parsing 7-bit ASCII
#[derive(Default)]
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct AsciiParser;

impl CharAccumulator for AsciiParser {
Expand All @@ -338,8 +338,8 @@ impl CharAccumulator for AsciiParser {
}

/// Allow parsing UTF-8
#[derive(Default)]
#[cfg(feature = "utf8")]
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct Utf8Parser {
utf8_parser: utf8::Parser,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anstyle-parse/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::fmt::{self, Debug, Formatter};

pub(crate) const MAX_PARAMS: usize = 32;

#[derive(Default)]
#[derive(Default, Clone, PartialEq, Eq)]
pub struct Params {
/// Number of subparameters for each parameter.
///
Expand Down
8 changes: 7 additions & 1 deletion crates/anstyle-stream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ pre-release-replacements = [
]

[features]
default = ["auto"]
default = ["auto", "wincon"]
auto = ["dep:concolor-query", "dep:is-terminal"]
wincon = ["dep:anstyle-wincon"]

[dependencies]
anstyle = { version = "0.2.5", path = "../anstyle" }
anstyle-parse = { version = "0.0.1", path = "../anstyle-parse" }
anstyle-wincon = { version = "0.0.1", path = "../anstyle-wincon", optional = true }
concolor-query = { version = "0.2.0", optional = true }
is-terminal = { version = "0.4.4", optional = true }
utf8parse = "0.2.1"
Expand All @@ -44,3 +46,7 @@ strip-ansi-escapes = "0.1.1"
[[bench]]
name = "strip"
harness = false

[[bench]]
name = "wincon"
harness = false
26 changes: 26 additions & 0 deletions crates/anstyle-stream/benches/wincon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use criterion::{black_box, Criterion};

fn wincon(c: &mut Criterion) {
for (name, content) in [
("demo.vte", &include_bytes!("../tests/demo.vte")[..]),
("rg_help.vte", &include_bytes!("../tests/rg_help.vte")[..]),
("rg_linus.vte", &include_bytes!("../tests/rg_linus.vte")[..]),
(
"state_changes",
&b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\"[..],
),
] {
let mut group = c.benchmark_group(name);
group.bench_function("wincon_bytes", |b| {
b.iter(|| {
let mut state = anstyle_stream::adapter::WinconBytes::new();
let stripped = state.extract_next(content).collect::<Vec<_>>();

black_box(stripped)
})
});
}
}

criterion::criterion_group!(benches, wincon);
criterion::criterion_main!(benches);
3 changes: 3 additions & 0 deletions crates/anstyle-stream/src/adapter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Gracefully degrade styled output

mod strip;
mod wincon;

pub use strip::strip_bytes;
pub use strip::strip_str;
Expand All @@ -10,3 +11,5 @@ pub use strip::StripStr;
pub use strip::StripStrIter;
pub use strip::StrippedBytes;
pub use strip::StrippedStr;
pub use wincon::WinconBytes;
pub use wincon::WinconBytesIter;
2 changes: 1 addition & 1 deletion crates/anstyle-stream/src/adapter/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl StripBytes {
}
}

/// See [`StripStr`]
/// See [`StripBytes`]
#[derive(Debug, PartialEq, Eq)]
pub struct StripBytesIter<'s> {
bytes: &'s [u8],
Expand Down
Loading