diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index e4b3b9f..71f30c6 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -13,15 +13,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup rust toolchain
- uses: actions-rs/toolchain@v1
+ uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
- name: Run tests
- uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --lib --no-default-features --features derive,serialize,with-crossterm
+ run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
diff --git a/.github/workflows/crossterm-windows.yml b/.github/workflows/crossterm-windows.yml
index 188bd2c..c72804f 100644
--- a/.github/workflows/crossterm-windows.yml
+++ b/.github/workflows/crossterm-windows.yml
@@ -11,24 +11,16 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
+ - uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: rustfmt, clippy
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --no-default-features --features derive,serialize,tui,crossterm
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --no-default-features --features derive,serialize,ratatui,crossterm
+ - name: Test
+ run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize,crossterm
- name: Examples
run: cargo build --all-targets --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
- run: cargo clippy --lib --no-default-features --features derive,serialize,tui,crossterm -- -Dwarnings
- - name: Clippy
- run: cargo clippy --lib --no-default-features --features derive,serialize,ratatui,crossterm -- -Dwarnings
+ run: cargo clippy --lib --no-default-features --features derive,serialize,crossterm -- -Dwarnings
diff --git a/.github/workflows/ratatui_crossterm.yml b/.github/workflows/ratatui_crossterm.yml
index beaccca..cadd4f5 100644
--- a/.github/workflows/ratatui_crossterm.yml
+++ b/.github/workflows/ratatui_crossterm.yml
@@ -3,26 +3,24 @@ name: Ratatui-Crossterm
on: [push, pull_request]
env:
- CARGO_TERM_COLOR: always
+ CARGO_TERM_COLOR: always
jobs:
- build:
- runs-on: ubuntu-latest
+ build:
+ runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- components: rustfmt, clippy
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --features derive,serialize,ratatui,crossterm --no-default-features
- - name: Examples
- run: cargo build --all-targets --examples
- - name: Format
- run: cargo fmt --all -- --check
- - name: Clippy
- run: cargo clippy --lib --features derive,serialize,ratatui,crossterm --no-default-features -- -Dwarnings
+ steps:
+ - uses: actions/checkout@v2
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ toolchain: stable
+ override: true
+ components: rustfmt, clippy
+ - name: Test
+ run: cargo test --no-fail-fast --lib --features derive,serialize,crossterm --no-default-features
+ - name: Examples
+ run: cargo build --all-targets --examples
+ - name: Format
+ run: cargo fmt --all -- --check
+ - name: Clippy
+ run: cargo clippy --lib --features derive,serialize,crossterm --no-default-features -- -Dwarnings
diff --git a/.github/workflows/ratatui_termion.yml b/.github/workflows/ratatui_termion.yml
index 429a2e4..b5591c1 100644
--- a/.github/workflows/ratatui_termion.yml
+++ b/.github/workflows/ratatui_termion.yml
@@ -11,18 +11,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
+ - uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- override: true
components: rustfmt, clippy
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --no-default-features --features derive,serialize,ratatui,termion
+ - name: Test
+ run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize,termion
- name: Examples
- run: cargo build --all-targets --no-default-features --features derive,serialize,ratatui,termion --examples
+ run: cargo build --all-targets --no-default-features --features derive,serialize,termion --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
- run: cargo clippy --lib --no-default-features --features derive,serialize,ratatui,termion -- -Dwarnings
+ run: cargo clippy --lib --no-default-features --features derive,serialize,termion -- -Dwarnings
diff --git a/.github/workflows/tui_crossterm.yml b/.github/workflows/tui_crossterm.yml
deleted file mode 100644
index e24c55d..0000000
--- a/.github/workflows/tui_crossterm.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Tui-Crossterm
-
-on: [push, pull_request]
-
-env:
- CARGO_TERM_COLOR: always
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- components: rustfmt, clippy
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --features derive,serialize,tui,crossterm --no-default-features
- - name: Examples
- run: cargo build --all-targets --examples
- - name: Format
- run: cargo fmt --all -- --check
- - name: Clippy
- run: cargo clippy --lib --features derive,serialize,tui,crossterm --no-default-features -- -Dwarnings
diff --git a/.github/workflows/tui_termion.yml b/.github/workflows/tui_termion.yml
deleted file mode 100644
index 6a45f68..0000000
--- a/.github/workflows/tui_termion.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Tui-Termion
-
-on: [push, pull_request]
-
-env:
- CARGO_TERM_COLOR: always
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- components: rustfmt, clippy
- - uses: actions-rs/cargo@v1
- with:
- command: test
- args: --no-fail-fast --no-default-features --features derive,serialize,tui,termion
- - name: Examples
- run: cargo build --all-targets --no-default-features --features derive,serialize,tui,termion --examples
- - name: Format
- run: cargo fmt --all -- --check
- - name: Clippy
- run: cargo clippy --lib --no-default-features --features derive,serialize,tui,termion -- -Dwarnings
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c21c61e..48abcf0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
- [Changelog](#changelog)
+ - [2.0.0](#200)
- [1.9.2](#192)
- [1.9.1](#191)
- [1.9.0](#190)
@@ -35,6 +36,34 @@
---
+## 2.0.0
+
+Released on 13/10/2024
+
+- Dropped support for `tui-rs`. Tui-rs was deprecated a long time ago, so it doesn't really makes sense to keep supporting it.
+- Added new methods for `TerminalBridge`
+ - `init`: Initialize a terminal with reasonable defaults for most applications.
+ - Raw mode is enabled
+ - Alternate screen buffer enabled
+ - A panic hook is installed that restores the terminal before panicking. Ensure that this method is called after any other panic hooks that may be installed to ensure that the terminal is.
+ - `restore`: Restore the terminal to its original state
+ - `set_panic_hook`: Sets a panic hook that restores the terminal before panicking.
+ - Added `draw` to `TerminalBridge`
+- `CmdResult::Custom(&'static str)` changed to `CmdResult::Custom(&'static str, State)`
+- Added new `subclause_and!(Id::Foo, Id::Bar, Id::Baz)` and `subclause_or!(Id::Foo, Id::Bar, Id::Baz)` macros.
+- Removed `InputListener`. Now use `CrosstermInputListener` or `TermionInputListener`.
+- Added Event handling for Mouse Events
+ - Added `Mouse` in `SubEventClause`.
+- Bump `ratatui` version to `0.28`
+- Dont enable `MouseCapture` by default
+- Add function `enable_mouse_capture` and `disable_mouse_capture` to `TerminalBridge`
+- **Max poll for ports**:
+ - Add `Port::set_max_poll` to set the amount a `Port` is polled in a single `Port::should_poll`.
+ - Add `EventListenerCfg::port` to add a manually constructed `Port`
+ - Previous `EventListenerCfg::port` has been renamed to `EventListenerCfg::add_port`
+
+Huge thanks to [hasezoey](https://github.com/hasezoey) for the contributions.
+
## 1.9.2
Released on 04/03/2023
diff --git a/Cargo.toml b/Cargo.toml
index 17cd154..3b19e85 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tuirealm"
-version = "1.9.2"
+version = "2.0.0"
authors = ["Christian Visintin"]
edition = "2021"
categories = ["command-line-utilities"]
@@ -14,15 +14,14 @@ readme = "README.md"
repository = "https://github.com/veeso/tui-realm"
[dependencies]
-bitflags = "2.4"
-crossterm = { version = "0.27", optional = true }
+bitflags = "2"
+crossterm = { version = "0.28", optional = true }
lazy-regex = "3"
-ratatui = { version = "0.26", default-features = false, optional = true }
+ratatui = { version = "0.28", default-features = false }
serde = { version = "^1", features = ["derive"], optional = true }
-termion = { version = "^2", optional = true }
-thiserror = "^1.0.0"
-tui = { version = "0.19", default-features = false, optional = true }
-tuirealm_derive = { version = "^1.0.0", optional = true }
+termion = { version = "^4", optional = true }
+thiserror = "1"
+tuirealm_derive = { version = "2", optional = true }
[dev-dependencies]
pretty_assertions = "^1"
@@ -30,21 +29,22 @@ toml = "^0.8"
tempfile = "^3"
[features]
-default = ["derive", "ratatui", "crossterm"]
-derive = ["tuirealm_derive"]
-serialize = ["serde", "bitflags/serde"]
-tui = ["dep:tui"]
-crossterm = ["dep:crossterm", "tui?/crossterm", "ratatui?/crossterm"]
-termion = ["dep:termion", "tui?/termion", "ratatui?/termion"]
-ratatui = ["dep:ratatui"]
-# deprecated aliases for broken out backend and UI library features
-with-crossterm = ["tui", "crossterm"]
-with-termion = ["tui", "termion"]
+default = ["derive", "crossterm"]
+derive = ["dep:tuirealm_derive"]
+serialize = ["dep:serde", "bitflags/serde"]
+crossterm = ["dep:crossterm", "ratatui/crossterm"]
+termion = ["dep:termion", "ratatui/termion"]
[[example]]
name = "demo"
path = "examples/demo/demo.rs"
+required-features = ["crossterm"]
[[example]]
name = "user-events"
path = "examples/user_events/user_events.rs"
+required-features = ["crossterm"]
+
+[package.metadata.docs.rs]
+all-features = true
+rustdoc-args = ["--cfg", "docsrs"]
diff --git a/README.md b/README.md
index a7d559a..cacd669 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
Developed by @veeso
-Current version: 1.9.2 (04/03/2024)
+Current version: 2.0.0 (13/10/2024)
-
-
⚠️ You can enable only one backend at the time and at least one must be enabled in order to build.
-> ❗ You don't need tui as a dependency, since you can access to tui types via `use tuirealm::tui::`
-
#### Enabling other backends ⚠️
This library supports two backends: `crossterm` and `termion`, and two high
@@ -169,18 +149,18 @@ level terminal TUI libraries: `tui` and `ratatui`. Whenever you explicitly
declare any of the TUI library or backend feature sets you should disable the
crate's default features.
-> ❗ You can never have more than one backend and one UI library enabled at the same time
+> ❗ The two features can co-exist, even if it doesn't make too much sense.
-Example using the termion backend:
+Example using crossterm:
```toml
-tuirealm = { version = "^1.9.0", default-features = false, features = [ "termion", "derive", "tui" ] }
+tuirealm = { version = "2", default-features = false, features = [ "derive", "crossterm" ]}
```
-Example using the ratatui UI library:
+Example using the termion backend:
```toml
-tuirealm = { version = "^1.9.0", default-features = false, features = [ "ratatui", "derive", "crossterm" ]}
+tuirealm = { version = "2", default-features = false, features = [ "derive", "termion" ] }
```
### Create a tui-realm application 🪂
@@ -191,7 +171,7 @@ View how to implement a tui-realm application in the [related guide](/docs/en/ge
Still confused about how tui-realm works? Don't worry, try with the examples:
-- [demo](/examples/demo.rs): a simple application which shows how tui-realm works
+- [demo](/examples/demo/demo.rs): a simple application which shows how tui-realm works
```sh
cargo run --example demo
diff --git a/examples/demo/app/model.rs b/examples/demo/app/model.rs
index 26b7905..aa9e317 100644
--- a/examples/demo/app/model.rs
+++ b/examples/demo/app/model.rs
@@ -6,8 +6,8 @@ use std::time::{Duration, SystemTime};
use tuirealm::event::NoUserEvent;
use tuirealm::props::{Alignment, Color, TextModifiers};
-use tuirealm::terminal::TerminalBridge;
-use tuirealm::tui::layout::{Constraint, Direction, Layout};
+use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
+use tuirealm::terminal::{CrosstermTerminalAdapter, TerminalAdapter, TerminalBridge};
use tuirealm::{
Application, AttrValue, Attribute, EventListenerCfg, Sub, SubClause, SubEventClause, Update,
};
@@ -15,7 +15,10 @@ use tuirealm::{
use super::components::{Clock, DigitCounter, Label, LetterCounter};
use super::{Id, Msg};
-pub struct Model {
+pub struct Model
+where
+ T: TerminalAdapter,
+{
/// Application
pub app: Application,
/// Indicates that the application must quit
@@ -23,25 +26,27 @@ pub struct Model {
/// Tells whether to redraw interface
pub redraw: bool,
/// Used to draw to terminal
- pub terminal: TerminalBridge,
+ pub terminal: TerminalBridge,
}
-impl Default for Model {
+impl Default for Model {
fn default() -> Self {
Self {
app: Self::init_app(),
quit: false,
redraw: true,
- terminal: TerminalBridge::new().expect("Cannot initialize terminal"),
+ terminal: TerminalBridge::init_crossterm().expect("Cannot initialize terminal"),
}
}
}
-impl Model {
+impl Model
+where
+ T: TerminalAdapter,
+{
pub fn view(&mut self) {
assert!(self
.terminal
- .raw_mut()
.draw(|f| {
let chunks = Layout::default()
.direction(Direction::Vertical)
@@ -55,7 +60,7 @@ impl Model {
]
.as_ref(),
)
- .split(f.size());
+ .split(f.area());
self.app.view(&Id::Clock, f, chunks[0]);
self.app.view(&Id::LetterCounter, f, chunks[1]);
self.app.view(&Id::DigitCounter, f, chunks[2]);
@@ -72,7 +77,7 @@ impl Model {
let mut app: Application = Application::init(
EventListenerCfg::default()
- .default_input_listener(Duration::from_millis(20))
+ .crossterm_input_listener(Duration::from_millis(20), 3)
.poll_timeout(Duration::from_millis(10))
.tick_interval(Duration::from_secs(1)),
);
@@ -128,7 +133,10 @@ impl Model {
// Let's implement Update for model
-impl Update for Model {
+impl Update for Model
+where
+ T: TerminalAdapter,
+{
fn update(&mut self, msg: Option) -> Option {
if let Some(msg) = msg {
// Set redraw
diff --git a/examples/demo/components/clock.rs b/examples/demo/components/clock.rs
index 6d14e3d..86d6a8f 100644
--- a/examples/demo/components/clock.rs
+++ b/examples/demo/components/clock.rs
@@ -7,7 +7,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tuirealm::command::{Cmd, CmdResult};
use tuirealm::props::{Alignment, Color, TextModifiers};
-use tuirealm::tui::layout::Rect;
+use tuirealm::ratatui::layout::Rect;
use tuirealm::{
AttrValue, Attribute, Component, Event, Frame, MockComponent, NoUserEvent, State, StateValue,
};
diff --git a/examples/demo/components/counter.rs b/examples/demo/components/counter.rs
index f5a5eda..e9a218d 100644
--- a/examples/demo/components/counter.rs
+++ b/examples/demo/components/counter.rs
@@ -5,8 +5,8 @@
use tuirealm::command::{Cmd, CmdResult};
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, Borders, Color, Style, TextModifiers};
-use tuirealm::tui::layout::Rect;
-use tuirealm::tui::widgets::{BorderType, Paragraph};
+use tuirealm::ratatui::layout::Rect;
+use tuirealm::ratatui::widgets::{BorderType, Paragraph};
use tuirealm::{
AttrValue, Attribute, Component, Event, Frame, MockComponent, NoUserEvent, Props, State,
StateValue,
diff --git a/examples/demo/components/label.rs b/examples/demo/components/label.rs
index c21ad7e..8bab2cd 100644
--- a/examples/demo/components/label.rs
+++ b/examples/demo/components/label.rs
@@ -4,8 +4,8 @@
use tuirealm::command::{Cmd, CmdResult};
use tuirealm::props::{Alignment, Color, Style, TextModifiers};
-use tuirealm::tui::layout::Rect;
-use tuirealm::tui::widgets::Paragraph;
+use tuirealm::ratatui::layout::Rect;
+use tuirealm::ratatui::widgets::Paragraph;
use tuirealm::{
AttrValue, Attribute, Component, Event, Frame, MockComponent, NoUserEvent, Props, State,
};
diff --git a/examples/demo/components/mod.rs b/examples/demo/components/mod.rs
index a45c807..794c432 100644
--- a/examples/demo/components/mod.rs
+++ b/examples/demo/components/mod.rs
@@ -3,7 +3,7 @@
//! demo example components
use tuirealm::props::{Alignment, Borders, Color, Style};
-use tuirealm::tui::widgets::Block;
+use tuirealm::ratatui::widgets::Block;
use super::Msg;
diff --git a/examples/user_events/components/label.rs b/examples/user_events/components/label.rs
index b0a7d07..25fb8f4 100644
--- a/examples/user_events/components/label.rs
+++ b/examples/user_events/components/label.rs
@@ -7,8 +7,8 @@ use std::time::UNIX_EPOCH;
use tuirealm::command::{Cmd, CmdResult};
use tuirealm::event::{Key, KeyEvent};
use tuirealm::props::{Alignment, Color, Style, TextModifiers};
-use tuirealm::tui::layout::Rect;
-use tuirealm::tui::widgets::Paragraph;
+use tuirealm::ratatui::layout::Rect;
+use tuirealm::ratatui::widgets::Paragraph;
use tuirealm::{AttrValue, Attribute, Component, Event, Frame, MockComponent, Props, State};
use super::{Msg, UserEvent};
diff --git a/examples/user_events/model.rs b/examples/user_events/model.rs
index afcfba6..fd90f84 100644
--- a/examples/user_events/model.rs
+++ b/examples/user_events/model.rs
@@ -2,13 +2,16 @@
//!
//! app model
-use tuirealm::terminal::TerminalBridge;
-use tuirealm::tui::layout::{Constraint, Direction, Layout};
+use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
+use tuirealm::terminal::{TerminalAdapter, TerminalBridge};
use tuirealm::{Application, Update};
use super::{Id, Msg, UserEvent};
-pub struct Model {
+pub struct Model
+where
+ T: TerminalAdapter,
+{
/// Application
pub app: Application,
/// Indicates that the application must quit
@@ -16,23 +19,25 @@ pub struct Model {
/// Tells whether to redraw interface
pub redraw: bool,
/// Used to draw to terminal
- pub terminal: TerminalBridge,
+ pub terminal: TerminalBridge,
}
-impl Model {
- pub fn new(app: Application) -> Self {
+impl Model
+where
+ T: TerminalAdapter,
+{
+ pub fn new(app: Application, adapter: T) -> Self {
Self {
app,
quit: false,
redraw: true,
- terminal: TerminalBridge::new().expect("Cannot initialize terminal"),
+ terminal: TerminalBridge::init(adapter).expect("Cannot initialize terminal"),
}
}
pub fn view(&mut self) {
assert!(self
.terminal
- .raw_mut()
.draw(|f| {
let chunks = Layout::default()
.direction(Direction::Vertical)
@@ -44,7 +49,7 @@ impl Model {
]
.as_ref(),
)
- .split(f.size());
+ .split(f.area());
self.app.view(&Id::Label, f, chunks[0]);
self.app.view(&Id::Other, f, chunks[1]);
})
@@ -54,7 +59,10 @@ impl Model {
// Let's implement Update for model
-impl Update for Model {
+impl Update for Model
+where
+ T: TerminalAdapter,
+{
fn update(&mut self, msg: Option) -> Option {
if let Some(msg) = msg {
// Set redraw
diff --git a/examples/user_events/user_events.rs b/examples/user_events/user_events.rs
index 6a4ed21..8b5aa20 100644
--- a/examples/user_events/user_events.rs
+++ b/examples/user_events/user_events.rs
@@ -5,6 +5,7 @@ use std::time::{Duration, SystemTime};
use components::Label;
use tuirealm::listener::{ListenerResult, Poll};
+use tuirealm::terminal::CrosstermTerminalAdapter;
use tuirealm::{
Application, Event, EventListenerCfg, PollStrategy, Sub, SubClause, SubEventClause, Update,
};
@@ -49,14 +50,15 @@ impl Poll for UserDataPort {
}
fn main() {
- let mut app: Application = Application::init(
- EventListenerCfg::default()
- .default_input_listener(Duration::from_millis(10))
- .port(
- Box::new(UserDataPort::default()),
- Duration::from_millis(1000),
- ),
- );
+ let event_listener = EventListenerCfg::default()
+ .crossterm_input_listener(Duration::from_millis(10), 3)
+ .add_port(
+ Box::new(UserDataPort::default()),
+ Duration::from_millis(1000),
+ 1,
+ );
+
+ let mut app: Application = Application::init(event_listener);
// subscribe component to clause
app.mount(
@@ -80,9 +82,10 @@ fn main() {
app.active(&Id::Label).expect("failed to active");
- let mut model = Model::new(app);
- let _ = model.terminal.enter_alternate_screen();
- let _ = model.terminal.enable_raw_mode();
+ let mut model = Model::new(
+ app,
+ CrosstermTerminalAdapter::new().expect("failed to create terminal"),
+ );
// Main loop
// NOTE: loop until quit; quit is set in update if AppClose is received from counter
while !model.quit {
@@ -109,8 +112,9 @@ fn main() {
model.redraw = false;
}
}
- // Terminate terminal
- let _ = model.terminal.leave_alternate_screen();
- let _ = model.terminal.disable_raw_mode();
- let _ = model.terminal.clear_screen();
+
+ model
+ .terminal
+ .restore()
+ .expect("failed to restore terminal");
}
diff --git a/src/adapter/crossterm/listener.rs b/src/adapter/crossterm/listener.rs
deleted file mode 100644
index f3f7068..0000000
--- a/src/adapter/crossterm/listener.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-//! ## Listener
-//!
-//! input listener adapter for crossterm
-
-use std::marker::PhantomData;
-use std::time::Duration;
-
-use crossterm::event as xterm;
-
-use super::Event;
-use crate::listener::{ListenerError, ListenerResult, Poll};
-
-/// The input listener for crossterm.
-/// If crossterm is enabled, this will already be exported as `InputEventListener` in the `adapter` module
-/// or you can use it directly in the event listener, calling `default_input_listener()` in the `EventListenerCfg`
-pub struct CrosstermInputListener
-where
- U: Eq + PartialEq + Clone + PartialOrd + Send,
-{
- ghost: PhantomData,
- interval: Duration,
-}
-
-impl CrosstermInputListener
-where
- U: Eq + PartialEq + Clone + PartialOrd + Send,
-{
- pub fn new(interval: Duration) -> Self {
- Self {
- ghost: PhantomData,
- interval: interval / 2,
- }
- }
-}
-
-impl Poll for CrosstermInputListener
-where
- U: Eq + PartialEq + Clone + PartialOrd + Send + 'static,
-{
- fn poll(&mut self) -> ListenerResult