Skip to content

Commit fce58c8

Browse files
joshkagwenn
andauthored
fix: broken build issues (#888)
Co-authored-by: gwenn <[email protected]>
1 parent 6d20946 commit fce58c8

File tree

8 files changed

+49
-35
lines changed

8 files changed

+49
-35
lines changed

Diff for: .github/workflows/crossterm_test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
if: matrix.os != 'windows-2019'
6767
run: cargo test --no-default-features -- --nocapture --test-threads 1
6868
continue-on-error: ${{ matrix.can-fail }}
69+
- name: Test no default features with use-dev-tty feature enabled
70+
if: matrix.os != 'windows-2019'
71+
run: cargo test --no-default-features --features "use-dev-tty events" -- --nocapture --test-threads 1
72+
continue-on-error: ${{ matrix.can-fail }}
6973
- name: Test no default features with windows feature enabled
7074
if: matrix.os == 'windows-2019'
7175
run: cargo test --no-default-features --features "windows" -- --nocapture --test-threads 1

Diff for: Cargo.toml

+22-6
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,28 @@ all-features = true
2828
#
2929
[features]
3030
default = ["bracketed-paste", "windows", "events"]
31-
windows = ["dep:winapi", "dep:crossterm_winapi"] # Disables winapi dependencies from being included into the binary (SHOULD NOT be disabled on windows).
32-
bracketed-paste = [] # Enables triggering a `Event::Paste` when pasting text into the terminal.
31+
windows = [
32+
"dep:winapi",
33+
"dep:crossterm_winapi",
34+
] # Disables winapi dependencies from being included into the binary (SHOULD NOT be disabled on windows).
35+
bracketed-paste = [
36+
] # Enables triggering a `Event::Paste` when pasting text into the terminal.
3337
event-stream = ["dep:futures-core", "events"] # Enables async events
34-
use-dev-tty = ["filedescriptor"] # Enables raw file descriptor polling / selecting instead of mio.
35-
events = ["dep:mio", "dep:signal-hook", "dep:signal-hook-mio"] # Enables reading input/events from the system.
38+
use-dev-tty = [
39+
"filedescriptor",
40+
] # Enables raw file descriptor polling / selecting instead of mio.
41+
events = [
42+
"dep:mio",
43+
"dep:signal-hook",
44+
"dep:signal-hook-mio",
45+
] # Enables reading input/events from the system.
3646
serde = ["dep:serde", "bitflags/serde"] # Enables 'serde' for various types.
3747

3848
#
3949
# Shared dependencies
4050
#
4151
[dependencies]
42-
bitflags = {version = "2.3" }
52+
bitflags = { version = "2.3" }
4353
parking_lot = "0.12"
4454

4555
# optional deps only added when requested
@@ -65,7 +75,9 @@ libc = "0.2"
6575
signal-hook = { version = "0.3.17", optional = true }
6676
filedescriptor = { version = "0.8", optional = true }
6777
mio = { version = "0.8", features = ["os-poll"], optional = true }
68-
signal-hook-mio = { version = "0.2.3", features = ["support-v0_8"], optional = true }
78+
signal-hook-mio = { version = "0.2.3", features = [
79+
"support-v0_8",
80+
], optional = true }
6981

7082
#
7183
# Dev dependencies (examples, ...)
@@ -108,3 +120,7 @@ required-features = ["events"]
108120
[[example]]
109121
name = "stderr"
110122
required-features = ["events"]
123+
124+
[[example]]
125+
name = "key-display"
126+
required-features = ["events"]

Diff for: src/cursor/sys.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#[cfg(feature = "events")]
55
pub use self::unix::position;
66
#[cfg(windows)]
7+
#[cfg(feature = "events")]
78
pub use self::windows::position;
89
#[cfg(windows)]
910
pub(crate) use self::windows::{

Diff for: src/event.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ impl Display for ModifierKeyCode {
910910
///
911911
/// # Platform-specific Notes
912912
///
913-
/// On macOS, the control, alt, and super keys is displayed as "Control", "Option", and
913+
/// On macOS, the control, alt, and super keys are displayed as "Control", "Option", and
914914
/// "Command" respectively. See
915915
/// <https://support.apple.com/guide/applestyleguide/welcome/1.0/web>.
916916
///
@@ -920,7 +920,6 @@ impl Display for ModifierKeyCode {
920920
///
921921
/// On other platforms, the super key is referred to as "Super".
922922
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
923-
#[cfg(target_os = "macos")]
924923
match self {
925924
ModifierKeyCode::LeftShift => write!(f, "Left Shift"),
926925
ModifierKeyCode::LeftHyper => write!(f, "Left Hyper"),

Diff for: src/event/source/unix/mio.rs

+12-17
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,18 @@ impl EventSource for UnixInternalEventSource {
120120
}
121121
}
122122
SIGNAL_TOKEN => {
123-
for signal in self.signals.pending() {
124-
match signal {
125-
signal_hook::consts::SIGWINCH => {
126-
// TODO Should we remove tput?
127-
//
128-
// This can take a really long time, because terminal::size can
129-
// launch new process (tput) and then it parses its output. It's
130-
// not a really long time from the absolute time point of view, but
131-
// it's a really long time from the mio, async-std/tokio executor, ...
132-
// point of view.
133-
let new_size = crate::terminal::size()?;
134-
return Ok(Some(InternalEvent::Event(Event::Resize(
135-
new_size.0, new_size.1,
136-
))));
137-
}
138-
_ => unreachable!("Synchronize signal registration & handling"),
139-
};
123+
if self.signals.pending().next() == Some(signal_hook::consts::SIGWINCH) {
124+
// TODO Should we remove tput?
125+
//
126+
// This can take a really long time, because terminal::size can
127+
// launch new process (tput) and then it parses its output. It's
128+
// not a really long time from the absolute time point of view, but
129+
// it's a really long time from the mio, async-std/tokio executor, ...
130+
// point of view.
131+
let new_size = crate::terminal::size()?;
132+
return Ok(Some(InternalEvent::Event(Event::Resize(
133+
new_size.0, new_size.1,
134+
))));
140135
}
141136
}
142137
#[cfg(feature = "event-stream")]

Diff for: src/event/source/unix/tty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl UnixInternalEventSource {
8080
/// only fills the given buffer and does not read beyond that.
8181
fn read_complete(fd: &FileDesc, buf: &mut [u8]) -> io::Result<usize> {
8282
loop {
83-
match fd.read(buf, buf.len()) {
83+
match fd.read(buf) {
8484
Ok(x) => return Ok(x),
8585
Err(e) => match e.kind() {
8686
io::ErrorKind::WouldBlock => return Ok(0),

Diff for: src/style/attributes.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ mod tests {
140140

141141
#[test]
142142
fn test_attributes_const() {
143-
const ATTRIBUTES: Attributes = Attributes::none().with(Attribute::Bold).with(Attribute::Italic).without(Attribute::Bold);
144-
assert!(!ATTRIBUTES.has(Attribute::Bold));
145-
assert!(ATTRIBUTES.has(Attribute::Italic));
143+
const ATTRIBUTES: Attributes = Attributes::none()
144+
.with(Attribute::Bold)
145+
.with(Attribute::Italic)
146+
.without(Attribute::Bold);
147+
assert!(!ATTRIBUTES.has(Attribute::Bold));
148+
assert!(ATTRIBUTES.has(Attribute::Italic));
146149
}
147150
}

Diff for: src/style/types/color.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,11 @@ impl serde::ser::Serialize for Color {
246246

247247
if str.is_empty() {
248248
match *self {
249-
Color::AnsiValue(value) => {
250-
serializer.serialize_str(&format!("ansi_({})", value))
251-
}
249+
Color::AnsiValue(value) => serializer.serialize_str(&format!("ansi_({})", value)),
252250
Color::Rgb { r, g, b } => {
253251
serializer.serialize_str(&format!("rgb_({},{},{})", r, g, b))
254252
}
255-
_ => {
256-
Err(serde::ser::Error::custom("Could not serialize enum type"))
257-
}
253+
_ => Err(serde::ser::Error::custom("Could not serialize enum type")),
258254
}
259255
} else {
260256
serializer.serialize_str(str)

0 commit comments

Comments
 (0)