Skip to content

Commit

Permalink
Make the events module optional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
TimonPost committed Apr 7, 2023
1 parent b354b4c commit 2b398e2
Show file tree
Hide file tree
Showing 11 changed files with 810 additions and 769 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ all-features = true
# Features
#
[features]
default = ["bracketed-paste", "windows"]
default = ["bracketed-paste", "windows", "events"]
windows = ["winapi", "crossterm_winapi"]
bracketed-paste = []
event-stream = ["futures-core"]
use-dev-tty = ["filedescriptor"]

events = ["mio", "signal-hook", "signal-hook-mio"]
#
# Shared dependencies
#
Expand Down Expand Up @@ -59,10 +59,10 @@ crossterm_winapi = { version = "0.9", optional = true }
#
[target.'cfg(unix)'.dependencies]
libc = "0.2"
signal-hook = { version = "0.3.13" }
signal-hook = { version = "0.3.13", optional = true }
filedescriptor = { version = "0.8", optional = true }
mio = { version = "0.8", features = ["os-poll"] }
signal-hook-mio = { version = "0.2.3", features = ["support-v0_8"] }
mio = { version = "0.8", features = ["os-poll"], optional = true }
signal-hook-mio = { version = "0.2.3", features = ["support-v0_8"], optional = true }

#
# Dev dependencies (examples, ...)
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,22 @@ features = ["event-stream"]
|:---------------|:---------------------------------------------|
| `event-stream` | `futures::Stream` producing `Result<Event>`. |
| `serde` | (De)serializing of events. |
| `events` | Reading input/system events (enabled by default) |
| `filedescriptor` | Use raw filedescriptor for all events rather then mio dependency |


To use crossterm as a very tin layer you can disable the `events` feature or use `filedescriptor` feature.
This can disable `mio` / `signal-hook` / `signal-hook-mio` dependencies.

### Dependency Justification

| Dependency | Used for | Included |
|:---------------|:---------------------------------------------------------------------------------|:--------------------------------------|
| `bitflags` | `KeyModifiers`, those are differ based on input. | always |
| `parking_lot` | locking `RwLock`s with a timeout, const mutexes. | always |
| `libc` | UNIX terminal_size/raw modes/set_title and several other low level functionality. | UNIX only |
| `Mio` | event readiness polling, waking up poller | UNIX only |
| `signal-hook` | signal-hook is used to handle terminal resize SIGNAL with Mio. | UNIX only |
| `libc` | UNIX terminal_size/raw modes/set_title and several other low level functionality. | optional (`events` feature), UNIX only |
| `Mio` | event readiness polling, waking up poller | optional (`events` feature), UNIX only |
| `signal-hook` | signal-hook is used to handle terminal resize SIGNAL with Mio. | optional (`events` feature),UNIX only |
| `winapi` | Used for low-level windows system calls which ANSI codes can't replace | windows only |
| `futures-core` | For async stream of events | only with `event-stream` feature flag |
| `serde` | ***ser***ializing and ***de***serializing of events | only with `serde` feature flag |
Expand Down
4 changes: 1 addition & 3 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ use std::fmt;
use crate::Result;
use crate::{csi, impl_display, Command};

pub use sys::position;

pub(crate) mod sys;

/// A command that moves the terminal cursor to the given position (column, row).
Expand Down Expand Up @@ -432,7 +430,7 @@ mod tests {
use crate::execute;

use super::{
position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, SavePosition,
sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, SavePosition,
};

// Test is disabled, because it's failing on Travis
Expand Down
2 changes: 2 additions & 0 deletions src/cursor/sys.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This module provides platform related functions.

#[cfg(unix)]
#[cfg(feature = "events")]
pub use self::unix::position;
#[cfg(windows)]
pub use self::windows::position;
Expand All @@ -14,4 +15,5 @@ pub(crate) use self::windows::{
pub(crate) mod windows;

#[cfg(unix)]
#[cfg(feature = "events")]
pub(crate) mod unix;
Loading

0 comments on commit 2b398e2

Please sign in to comment.