mirror of
https://github.com/crossterm-rs/crossterm.git
synced 2025-10-02 07:21:31 +00:00
Document feature flags in lib.rs (#947)
* Autoformat Cargo.toml Uses VSCode Even Better TOML plugin for opinionated formatting * Document feature flags Use the document-features crate to automatically add documentation about the features to the crate documentation at the crate level.
This commit is contained in:
parent
56ee252fe1
commit
fc8f977938
87
Cargo.toml
87
Cargo.toml
@ -17,91 +17,66 @@ categories = ["command-line-interface", "command-line-utilities"]
|
|||||||
name = "crossterm"
|
name = "crossterm"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
#
|
|
||||||
# Build documentation with all features -> EventStream is available
|
|
||||||
#
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
||||||
#
|
|
||||||
# Features
|
|
||||||
#
|
|
||||||
[features]
|
[features]
|
||||||
default = ["bracketed-paste", "windows", "events"]
|
default = ["bracketed-paste", "events", "windows"]
|
||||||
windows = [
|
|
||||||
"dep:winapi",
|
#! ### Default features
|
||||||
"dep:crossterm_winapi",
|
## Enables triggering [`Event::Paste`](event::Event::Paste) when pasting text into the terminal.
|
||||||
] # Disables winapi dependencies from being included into the binary (SHOULD NOT be disabled on windows).
|
bracketed-paste = []
|
||||||
bracketed-paste = [
|
|
||||||
] # Enables triggering a `Event::Paste` when pasting text into the terminal.
|
## Enables reading input/events from the system using the [`event`] module.
|
||||||
event-stream = ["dep:futures-core", "events"] # Enables async events
|
events = ["dep:mio", "dep:signal-hook", "dep:signal-hook-mio"]
|
||||||
use-dev-tty = [
|
|
||||||
"filedescriptor",
|
## Enables windows specific crates.
|
||||||
"rustix/process",
|
windows = ["dep:winapi", "dep:crossterm_winapi"]
|
||||||
] # Enables raw file descriptor polling / selecting instead of mio.
|
|
||||||
events = [
|
#! ### Optional Features
|
||||||
"dep:mio",
|
|
||||||
"dep:signal-hook",
|
## Enables the [EventStream](event::EventStream) struct for async event reading.
|
||||||
"dep:signal-hook-mio",
|
event-stream = ["dep:futures-core", "events"]
|
||||||
] # Enables reading input/events from the system.
|
|
||||||
serde = ["dep:serde", "bitflags/serde"] # Enables 'serde' for various types.
|
## Enables [`serde`] for various types.
|
||||||
|
serde = ["dep:serde", "bitflags/serde"]
|
||||||
|
|
||||||
|
## Enables raw file descriptor polling / selecting instead of mio.
|
||||||
|
use-dev-tty = ["filedescriptor", "rustix/process"]
|
||||||
|
|
||||||
#
|
|
||||||
# Shared dependencies
|
|
||||||
#
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = { version = "2.3" }
|
bitflags = { version = "2.3" }
|
||||||
parking_lot = "0.12"
|
document-features = "0.2.10"
|
||||||
|
|
||||||
# optional deps only added when requested
|
|
||||||
futures-core = { version = "0.3", optional = true, default-features = false }
|
futures-core = { version = "0.3", optional = true, default-features = false }
|
||||||
|
parking_lot = "0.12"
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
|
|
||||||
#
|
|
||||||
# Windows dependencies
|
# Windows dependencies
|
||||||
#
|
|
||||||
[target.'cfg(windows)'.dependencies.winapi]
|
|
||||||
version = "0.3.9"
|
|
||||||
features = ["winuser", "winerror"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
crossterm_winapi = { version = "0.9.1", optional = true }
|
crossterm_winapi = { version = "0.9.1", optional = true }
|
||||||
|
winapi = { version = "0.3.9", optional = true, features = ["winuser", "winerror"] }
|
||||||
|
|
||||||
#
|
|
||||||
# UNIX dependencies
|
# UNIX dependencies
|
||||||
#
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
filedescriptor = { version = "0.8", optional = true }
|
||||||
# Default to using rustix for UNIX systems, but provide an option to use libc for backwards
|
# Default to using rustix for UNIX systems, but provide an option to use libc for backwards
|
||||||
# compatibility.
|
# compatibility.
|
||||||
libc = { version = "0.2", default-features = false, optional = true }
|
libc = { version = "0.2", default-features = false, optional = true }
|
||||||
rustix = { version = "0.38.34", default-features = false, features = [
|
|
||||||
"std",
|
|
||||||
"stdio",
|
|
||||||
"termios",
|
|
||||||
] }
|
|
||||||
signal-hook = { version = "0.3.17", optional = true }
|
|
||||||
filedescriptor = { version = "0.8", optional = true }
|
|
||||||
mio = { version = "1.0", features = ["os-poll"], optional = true }
|
mio = { version = "1.0", features = ["os-poll"], optional = true }
|
||||||
signal-hook-mio = { version = "0.2.4", features = [
|
rustix = { version = "0.38.34", default-features = false, features = ["std", "stdio", "termios"] }
|
||||||
"support-v1_0",
|
signal-hook = { version = "0.3.17", optional = true }
|
||||||
], optional = true }
|
signal-hook-mio = { version = "0.2.4", features = ["support-v1_0"], optional = true }
|
||||||
|
|
||||||
#
|
|
||||||
# Dev dependencies (examples, ...)
|
|
||||||
#
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1.25", features = ["full"] }
|
async-std = "1.12"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-timer = "3.0"
|
futures-timer = "3.0"
|
||||||
async-std = "1.12"
|
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serial_test = "2.0.0"
|
serial_test = "2.0.0"
|
||||||
temp-env = "0.3.6"
|
temp-env = "0.3.6"
|
||||||
|
tokio = { version = "1.25", features = ["full"] }
|
||||||
|
|
||||||
#
|
|
||||||
# Examples
|
# Examples
|
||||||
#
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "event-read"
|
name = "event-read"
|
||||||
required-features = ["bracketed-paste", "events"]
|
required-features = ["bracketed-paste", "events"]
|
||||||
|
@ -223,6 +223,8 @@
|
|||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! }
|
//! }
|
||||||
//!```
|
//!```
|
||||||
|
//! ## Feature Flags
|
||||||
|
#![doc = document_features::document_features!()]
|
||||||
//!
|
//!
|
||||||
//! [write]: https://doc.rust-lang.org/std/io/trait.Write.html
|
//! [write]: https://doc.rust-lang.org/std/io/trait.Write.html
|
||||||
//! [stdout]: https://doc.rust-lang.org/std/io/fn.stdout.html
|
//! [stdout]: https://doc.rust-lang.org/std/io/fn.stdout.html
|
||||||
|
@ -184,7 +184,7 @@ pub fn available_color_count() -> u16 {
|
|||||||
///
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
///
|
///
|
||||||
/// crossterm supports NO_COLOR (https://no-color.org/) to disabled colored output.
|
/// crossterm supports NO_COLOR (<https://no-color.org/>) to disabled colored output.
|
||||||
///
|
///
|
||||||
/// This API allows applications to override that behavior and force colorized output
|
/// This API allows applications to override that behavior and force colorized output
|
||||||
/// even if NO_COLOR is set.
|
/// even if NO_COLOR is set.
|
||||||
|
@ -71,7 +71,7 @@ impl Colored {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether ansi color sequences are disabled by setting of NO_COLOR
|
/// Checks whether ansi color sequences are disabled by setting of NO_COLOR
|
||||||
/// in environment as per https://no-color.org/
|
/// in environment as per <https://no-color.org/>
|
||||||
pub fn ansi_color_disabled() -> bool {
|
pub fn ansi_color_disabled() -> bool {
|
||||||
!std::env::var("NO_COLOR")
|
!std::env::var("NO_COLOR")
|
||||||
.unwrap_or("".to_string())
|
.unwrap_or("".to_string())
|
||||||
|
@ -148,7 +148,7 @@ pub struct WindowSize {
|
|||||||
/// Returns the terminal size `[WindowSize]`.
|
/// Returns the terminal size `[WindowSize]`.
|
||||||
///
|
///
|
||||||
/// The width and height in pixels may not be reliably implemented or default to 0.
|
/// The width and height in pixels may not be reliably implemented or default to 0.
|
||||||
/// For unix, https://man7.org/linux/man-pages/man4/tty_ioctl.4.html documents them as "unused".
|
/// For unix, <https://man7.org/linux/man-pages/man4/tty_ioctl.4.html> documents them as "unused".
|
||||||
/// For windows it is not implemented.
|
/// For windows it is not implemented.
|
||||||
pub fn window_size() -> io::Result<WindowSize> {
|
pub fn window_size() -> io::Result<WindowSize> {
|
||||||
sys::window_size()
|
sys::window_size()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user