This adds a feature flag to allow opting out of the `derive_more`
dependency and derivations added in e063091. `derive_more` brings in
heavy proc macro dependencies and isn't crucial for the core functioning
of crossterm, so it should be possible for a crossterm dependent to opt
out of bringing in the transitive dependency.
* Add is_ and as_ methods to the event enums
Often application code only cares about a small subset of possible
events. These methods make it simpler to write code which checks whether
an event is a particular event type or converts events into the specific
type (returning an Option).
This can help simplify some nested match blocks. E.g.:
```rust
match event {
Event::Key(key) if key.kind == KeyEventKind::Press => { ... }
}
```
becomes:
```rust
if let Some(key) = event.as_key_press() { ... }
```
Similar flexible methods are aded across all the event enums:
- `Event::is_focus_gained()`
- `Event::is_focus_lost()`
- `Event::is_key()`
- `Event::is_mouse()`
- `Event::is_paste()`
- `Event::is_resize()`
- `Event::is_key_press()`
- `Event::as_key_press() -> Option<&KeyEvent>`
- `MouseEventKind::is_*()`
- `MouseButton::is_*()`
- `KeyEventKind::is_*()`
- `KeyEvent::is_press()`
- `KeyEvent::is_release()`
- `KeyEvent::is_repeat()`
- `KeyCode::is_*()`
- `KeyCode::is_function_key(n)`
- `KeyCode::is_char(c)`
- `KeyCode::as_char() -> Option<char>`
- `KeyCode::is_media_key(media)`
- `KeyCode::is_modifier(modifier)`
- add is_key_release() and is_key_repeat() checks
- add as_key_event()
- rename as_key_press() to as_key_press_event()
- add as_key_repeat_event()
- add as_key_release_event()
- add as_mouse_event()
- add as_paste_event()
- more tests
- update event-match and key-display examples
* 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.
Fixes#882 by improving `style::available_color_count()`:
- Checks ANSI support on Windows.
- Uses the COLORTERM environment variable and falls back to the TERM environment variable.
- Supports "xterm-24bit" and "truecolor" values which return `u16::MAX`.
* use rustix instead of libc
* make rustix the default feature
* bump msrv to 1.63.0
* fix remaining libc issues
- use rustix version of sigwinch signal
- add a lifetime to FileDesc and replace FileDesc::Static to
FileDesc::Borrowed. This made it necessary to either add a lifetime to
the libc version of FileDesc or replace all the callers with multiple
paths (libc, rustix). Changing FileDesc was more straightforward.
There are no usages of FileDesc found in any repo on github, so this
change should be reasonably safe.
* add changelog entry for rustix / filedesc change
This change does two things:
- add the serial_test crate to run selected tests serial rather
than in parallel. This is done because they use global state
so running them in parallel leads to race conditions and flaky
results (sometimes they pass, sometimes they fail). Running
them serialy avoids this flakiness.
- create a screen buffer within the test. This avoids changing
the terminal (screen buffer) which is running the test. for
example, a test that changes the terminal size to 20 x 20 can
leave the developer running the test with a resized terminal.
Creating a separate screen buffer for the test avoids this.
As of 318f810a39a7d45af2068eb97a255cdfa18282e8, crossterm uses RFC
2795 implicit named arguments, which shipped in Rust 1.58.
Co-authored-by: Timon <timonpost@hotmail.nl>
# Version 0.22.1
- Update yanked version crossterm-winapi and move to crossterm-winapi 0.9.0.
- Changed panic to error when calling disable-mouse capture without setting it first.
- Update bitflags dependency.
# Version 0.22
- Fix serde Color serialisation/deserialization inconsistency.
- Update crossterm-winapi 0.8.1 to fix panic for certain mouse events