Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken build issues #888

Merged
merged 7 commits into from
May 5, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/crossterm_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
if: matrix.os != 'windows-2019'
run: cargo test --no-default-features -- --nocapture --test-threads 1
continue-on-error: ${{ matrix.can-fail }}
- name: Test no default features with use-dev-tty feature enabled
if: matrix.os != 'windows-2019'
run: cargo test --no-default-features --features "use-dev-tty events" -- --nocapture --test-threads 1
continue-on-error: ${{ matrix.can-fail }}
- name: Test no default features with windows feature enabled
if: matrix.os == 'windows-2019'
run: cargo test --no-default-features --features "windows" -- --nocapture --test-threads 1
Expand Down
28 changes: 22 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@ all-features = true
#
[features]
default = ["bracketed-paste", "windows", "events"]
windows = ["dep:winapi", "dep:crossterm_winapi"] # Disables winapi dependencies from being included into the binary (SHOULD NOT be disabled on windows).
bracketed-paste = [] # Enables triggering a `Event::Paste` when pasting text into the terminal.
windows = [
"dep:winapi",
"dep:crossterm_winapi",
] # Disables winapi dependencies from being included into the binary (SHOULD NOT be disabled on windows).
bracketed-paste = [
] # Enables triggering a `Event::Paste` when pasting text into the terminal.
event-stream = ["dep:futures-core", "events"] # Enables async events
use-dev-tty = ["filedescriptor"] # Enables raw file descriptor polling / selecting instead of mio.
events = ["dep:mio", "dep:signal-hook", "dep:signal-hook-mio"] # Enables reading input/events from the system.
use-dev-tty = [
"filedescriptor",
] # Enables raw file descriptor polling / selecting instead of mio.
events = [
"dep:mio",
"dep:signal-hook",
"dep:signal-hook-mio",
] # Enables reading input/events from the system.
serde = ["dep:serde", "bitflags/serde"] # Enables 'serde' for various types.

#
# Shared dependencies
#
[dependencies]
bitflags = {version = "2.3" }
bitflags = { version = "2.3" }
parking_lot = "0.12"

# optional deps only added when requested
Expand All @@ -65,7 +75,9 @@ libc = "0.2"
signal-hook = { version = "0.3.17", optional = true }
filedescriptor = { version = "0.8", optional = true }
mio = { version = "0.8", features = ["os-poll"], optional = true }
signal-hook-mio = { version = "0.2.3", features = ["support-v0_8"], optional = true }
signal-hook-mio = { version = "0.2.3", features = [
"support-v0_8",
], optional = true }

#
# Dev dependencies (examples, ...)
Expand Down Expand Up @@ -108,3 +120,7 @@ required-features = ["events"]
[[example]]
name = "stderr"
required-features = ["events"]

[[example]]
name = "key-display"
required-features = ["events"]
1 change: 1 addition & 0 deletions src/cursor/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#[cfg(feature = "events")]
pub use self::unix::position;
#[cfg(windows)]
#[cfg(feature = "events")]
pub use self::windows::position;
#[cfg(windows)]
pub(crate) use self::windows::{
Expand Down
3 changes: 1 addition & 2 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ impl Display for ModifierKeyCode {
///
/// # Platform-specific Notes
///
/// On macOS, the control, alt, and super keys is displayed as "Control", "Option", and
/// On macOS, the control, alt, and super keys are displayed as "Control", "Option", and
/// "Command" respectively. See
/// <https://support.apple.com/guide/applestyleguide/welcome/1.0/web>.
///
Expand All @@ -920,7 +920,6 @@ impl Display for ModifierKeyCode {
///
/// On other platforms, the super key is referred to as "Super".
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(target_os = "macos")]
match self {
ModifierKeyCode::LeftShift => write!(f, "Left Shift"),
ModifierKeyCode::LeftHyper => write!(f, "Left Hyper"),
Expand Down
29 changes: 12 additions & 17 deletions src/event/source/unix/mio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,18 @@ impl EventSource for UnixInternalEventSource {
}
}
SIGNAL_TOKEN => {
for signal in self.signals.pending() {
match signal {
signal_hook::consts::SIGWINCH => {
// TODO Should we remove tput?
//
// This can take a really long time, because terminal::size can
// launch new process (tput) and then it parses its output. It's
// not a really long time from the absolute time point of view, but
// it's a really long time from the mio, async-std/tokio executor, ...
// point of view.
let new_size = crate::terminal::size()?;
return Ok(Some(InternalEvent::Event(Event::Resize(
new_size.0, new_size.1,
))));
}
_ => unreachable!("Synchronize signal registration & handling"),
};
if self.signals.pending().next() == Some(signal_hook::consts::SIGWINCH) {
// TODO Should we remove tput?
//
// This can take a really long time, because terminal::size can
// launch new process (tput) and then it parses its output. It's
// not a really long time from the absolute time point of view, but
// it's a really long time from the mio, async-std/tokio executor, ...
// point of view.
let new_size = crate::terminal::size()?;
return Ok(Some(InternalEvent::Event(Event::Resize(
new_size.0, new_size.1,
))));
}
}
#[cfg(feature = "event-stream")]
Expand Down
2 changes: 1 addition & 1 deletion src/event/source/unix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl UnixInternalEventSource {
/// only fills the given buffer and does not read beyond that.
fn read_complete(fd: &FileDesc, buf: &mut [u8]) -> io::Result<usize> {
loop {
match fd.read(buf, buf.len()) {
match fd.read(buf) {
Ok(x) => return Ok(x),
Err(e) => match e.kind() {
io::ErrorKind::WouldBlock => return Ok(0),
Expand Down
9 changes: 6 additions & 3 deletions src/style/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ mod tests {

#[test]
fn test_attributes_const() {
const ATTRIBUTES: Attributes = Attributes::none().with(Attribute::Bold).with(Attribute::Italic).without(Attribute::Bold);
assert!(!ATTRIBUTES.has(Attribute::Bold));
assert!(ATTRIBUTES.has(Attribute::Italic));
const ATTRIBUTES: Attributes = Attributes::none()
.with(Attribute::Bold)
.with(Attribute::Italic)
.without(Attribute::Bold);
assert!(!ATTRIBUTES.has(Attribute::Bold));
assert!(ATTRIBUTES.has(Attribute::Italic));
}
}
8 changes: 2 additions & 6 deletions src/style/types/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,11 @@ impl serde::ser::Serialize for Color {

if str.is_empty() {
match *self {
Color::AnsiValue(value) => {
serializer.serialize_str(&format!("ansi_({})", value))
}
Color::AnsiValue(value) => serializer.serialize_str(&format!("ansi_({})", value)),
Color::Rgb { r, g, b } => {
serializer.serialize_str(&format!("rgb_({},{},{})", r, g, b))
}
_ => {
Err(serde::ser::Error::custom("Could not serialize enum type"))
}
_ => Err(serde::ser::Error::custom("Could not serialize enum type")),
}
} else {
serializer.serialize_str(str)
Expand Down
Loading