aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2025-01-27 14:55:59 +0000
committerGitHub <noreply@github.com>2025-01-27 14:55:59 +0000
commit35dd9e27a1a32553dc196840122d1beb3ce8c7ff (patch)
treee475d8561ec8feddea8ec90e351524c3d14e9e3b
parent9c45ce63039f0d4a9fb077a546cdd1e969a49df3 (diff)
downloadr-alacritty-vte-35dd9e27a1a32553dc196840122d1beb3ce8c7ff.tar.gz
r-alacritty-vte-35dd9e27a1a32553dc196840122d1beb3ce8c7ff.tar.bz2
r-alacritty-vte-35dd9e27a1a32553dc196840122d1beb3ce8c7ff.zip
Replace `no_std` with `std` feature
The `no_std` feature has been broken since version `0.14`, since it did not disable the `std` feature of `memchr`. To fall more in line with the general ecosystem standards, this crate changes the `no_std` feature into an `std` feature. Since `vte` should be significantly faster with this feature, it has also been enabled by default (previously `no_std` was default). This is a breaking change, even if we ignore `no_std` consumers which aren't able to compile 0.14, since intermediate dependencies relying on the `no_std` feature will have to remove it from the manifest.
-rw-r--r--CHANGELOG.md2
-rw-r--r--Cargo.toml6
-rw-r--r--src/ansi.rs22
-rw-r--r--src/lib.rs28
4 files changed, 30 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53b2046..64a701a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ CHANGELOG
## Unreleased
- Support `CSI ? 5 W` to reset tabs stops to every 8th column
+- Replaced `no_std` with a new `std` feature
+- Changed default features to include `std`
## 0.14.1
diff --git a/Cargo.toml b/Cargo.toml
index e6868bd..d5611cc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,12 +15,12 @@ rust-version = "1.62.1"
[features]
ansi = ["log", "cursor-icon", "bitflags"]
-default = ["no_std"]
-no_std = ["arrayvec"]
+default = ["std"]
+std = ["memchr/std"]
serde = ["dep:serde"]
[dependencies]
-arrayvec = { version = "0.7.2", default-features = false, optional = true }
+arrayvec = { version = "0.7.2", default-features = false }
bitflags = { version = "2.3.3", default-features = false, optional = true }
cursor-icon = { version = "1.0.0", default-features = false, optional = true }
log = { version = "0.4.17", optional = true }
diff --git a/src/ansi.rs b/src/ansi.rs
index a0d5e51..592266e 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -13,13 +13,13 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::fmt::{self, Display, Formatter, Write};
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
use core::ops::Mul;
use core::ops::{Add, Sub};
use core::str::FromStr;
use core::time::Duration;
use core::{iter, mem, str};
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
use std::time::Instant;
use bitflags::bitflags;
@@ -67,7 +67,7 @@ impl Rgb {
/// Implementation of [W3C's luminance algorithm].
///
/// [W3C's luminance algorithm]: https://www.w3.org/TR/WCAG20/#relativeluminancedef
- #[cfg(not(feature = "no_std"))]
+ #[cfg(feature = "std")]
pub fn luminance(self) -> f64 {
let channel_luminance = |channel| {
let channel = channel as f64 / 255.;
@@ -88,7 +88,7 @@ impl Rgb {
/// Implementation of [W3C's contrast algorithm].
///
/// [W3C's contrast algorithm]: https://www.w3.org/TR/WCAG20/#contrast-ratiodef
- #[cfg(not(feature = "no_std"))]
+ #[cfg(feature = "std")]
pub fn contrast(self, other: Rgb) -> f64 {
let self_luminance = self.luminance();
let other_luminance = other.luminance();
@@ -104,7 +104,7 @@ impl Rgb {
}
// A multiply function for Rgb, as the default dim is just *2/3.
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
impl Mul<f32> for Rgb {
type Output = Rgb;
@@ -266,7 +266,7 @@ impl<T: Timeout> Default for SyncState<T> {
/// The processor wraps a `crate::Parser` to ultimately call methods on a
/// Handler.
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
#[derive(Default)]
pub struct Processor<T: Timeout = StdSyncHandler> {
state: ProcessorState<T>,
@@ -275,7 +275,7 @@ pub struct Processor<T: Timeout = StdSyncHandler> {
/// The processor wraps a `crate::Parser` to ultimately call methods on a
/// Handler.
-#[cfg(feature = "no_std")]
+#[cfg(not(feature = "std"))]
#[derive(Default)]
pub struct Processor<T: Timeout> {
state: ProcessorState<T>,
@@ -438,13 +438,13 @@ impl<'a, H: Handler + 'a, T: Timeout> Performer<'a, H, T> {
}
}
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
#[derive(Default)]
pub struct StdSyncHandler {
timeout: Option<Instant>,
}
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
impl StdSyncHandler {
/// Synchronized update expiration time.
#[inline]
@@ -453,7 +453,7 @@ impl StdSyncHandler {
}
}
-#[cfg(not(feature = "no_std"))]
+#[cfg(feature = "std")]
impl Timeout for StdSyncHandler {
#[inline]
fn set_timeout(&mut self, duration: Duration) {
@@ -2438,7 +2438,7 @@ mod tests {
}
#[test]
- #[cfg(not(feature = "no_std"))]
+ #[cfg(feature = "std")]
fn contrast() {
let rgb1 = Rgb { r: 0xFF, g: 0xFF, b: 0xFF };
let rgb2 = Rgb { r: 0x00, g: 0x00, b: 0x00 };
diff --git a/src/lib.rs b/src/lib.rs
index 55fa676..1c69123 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -27,12 +27,12 @@
//! [`Perform`]: trait.Perform.html
//! [Paul Williams' ANSI parser state machine]: https://vt100.net/emu/dec_ansi_parser
#![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use)]
-#![cfg_attr(feature = "no_std", no_std)]
+#![cfg_attr(not(feature = "std"), no_std)]
use core::mem::MaybeUninit;
use core::str;
-#[cfg(feature = "no_std")]
+#[cfg(not(feature = "std"))]
use arrayvec::ArrayVec;
mod params;
@@ -50,7 +50,7 @@ const MAX_OSC_RAW: usize = 1024;
/// [`Perform`]: trait.Perform.html
///
/// Generic over the value for the size of the raw Operating System Command
-/// buffer. Only used when the `no_std` feature is enabled.
+/// buffer. Only used when the `std` feature is not enabled.
#[derive(Default)]
pub struct Parser<const OSC_RAW_BUF_SIZE: usize = MAX_OSC_RAW> {
state: State,
@@ -58,9 +58,9 @@ pub struct Parser<const OSC_RAW_BUF_SIZE: usize = MAX_OSC_RAW> {
intermediate_idx: usize,
params: Params,
param: u16,
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
osc_raw: ArrayVec<u8, OSC_RAW_BUF_SIZE>,
- #[cfg(not(feature = "no_std"))]
+ #[cfg(feature = "std")]
osc_raw: Vec<u8>,
osc_params: [(usize, usize); MAX_OSC_PARAMS],
osc_num_params: usize,
@@ -85,7 +85,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
/// ```rust
/// let mut p = vte::Parser::<64>::new_with_size();
/// ```
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
pub fn new_with_size() -> Parser<OSC_RAW_BUF_SIZE> {
Default::default()
}
@@ -422,7 +422,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
self.state = State::Escape
},
0x3B => {
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
{
if self.osc_raw.is_full() {
return;
@@ -542,7 +542,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
#[inline(always)]
fn action_osc_put(&mut self, byte: u8) {
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
{
if self.osc_raw.is_full() {
return;
@@ -825,7 +825,7 @@ pub trait Perform {
}
}
-#[cfg(all(test, feature = "no_std"))]
+#[cfg(all(test, not(feature = "std")))]
#[macro_use]
extern crate std;
@@ -1039,10 +1039,10 @@ mod tests {
assert_eq!(params.len(), 2);
assert_eq!(params[0], b"52");
- #[cfg(not(feature = "no_std"))]
+ #[cfg(feature = "std")]
assert_eq!(params[1].len(), NUM_BYTES + INPUT_END.len());
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
assert_eq!(params[1].len(), MAX_OSC_RAW - params[0].len());
},
_ => panic!("expected osc sequence"),
@@ -1308,7 +1308,7 @@ mod tests {
}
}
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
#[test]
fn build_with_fixed_size() {
const INPUT: &[u8] = b"\x1b[3;1\x1b[?1049h";
@@ -1328,7 +1328,7 @@ mod tests {
}
}
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
#[test]
fn exceed_fixed_osc_buffer_size() {
const OSC_BUFFER_SIZE: usize = 32;
@@ -1362,7 +1362,7 @@ mod tests {
}
}
- #[cfg(feature = "no_std")]
+ #[cfg(not(feature = "std"))]
#[test]
fn fixed_size_osc_containing_string_terminator() {
const INPUT_START: &[u8] = b"\x1b]2;";