Compare commits
2 Commits
d872b3d786
...
0926bbee46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0926bbee46 | ||
|
|
d41182b13b |
@@ -34,7 +34,7 @@ pub trait Component {
|
||||
|
||||
fn handle_text(
|
||||
&mut self,
|
||||
focus: &Self::Focus,
|
||||
_focus: &Self::Focus,
|
||||
_ch: char,
|
||||
) -> Result<Option<Self::Event>, ComponentError> {
|
||||
Ok(None)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// path_from_the_root: src/input/action.rs
|
||||
|
||||
pub trait Action: Clone + PartialEq + Eq + core::fmt::Debug {}
|
||||
|
||||
impl Action for ComponentAction {}
|
||||
|
||||
@@ -7,7 +7,7 @@ pub mod focus;
|
||||
pub mod input;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::component::*;
|
||||
pub use crate::focus::*;
|
||||
pub use crate::input::*;
|
||||
pub use crate::component::{Component, ComponentAction, ComponentError};
|
||||
pub use crate::focus::{FocusError, FocusId, FocusManager, FocusQuery, Focusable};
|
||||
pub use crate::input::{Action, Bindings, Key, KeyCode, KeyModifiers, MatchResult};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use tui_orchestrator::input::{Bindings, Key};
|
||||
extern crate alloc;
|
||||
|
||||
use tui_orchestrator::input::{Action, Bindings, Key};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[allow(dead_code)]
|
||||
@@ -8,6 +10,8 @@ enum TestAction {
|
||||
Open,
|
||||
}
|
||||
|
||||
impl Action for TestAction {}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_new() {
|
||||
let _bindings: Bindings<TestAction> = Bindings::new();
|
||||
|
||||
@@ -51,11 +51,22 @@ impl Component for TestComponent {
|
||||
self.field_b.clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_text(
|
||||
&mut self,
|
||||
focus: &Self::Focus,
|
||||
ch: char,
|
||||
) -> Result<Option<Self::Event>, tui_orchestrator::component::error::ComponentError> {
|
||||
match focus {
|
||||
Self::Focus::FieldA | Self::Focus::FieldB => Ok(Some(Self::Event::TextTyped(ch))),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_component_targets() {
|
||||
let mut component = TestComponent {
|
||||
let component = TestComponent {
|
||||
field_a: alloc::string::String::new(),
|
||||
field_b: alloc::string::String::new(),
|
||||
};
|
||||
@@ -109,7 +120,7 @@ fn test_component_on_enter_clears() {
|
||||
|
||||
#[test]
|
||||
fn test_component_defaults() {
|
||||
let component = TestComponent {
|
||||
let mut component = TestComponent {
|
||||
field_a: alloc::string::String::new(),
|
||||
field_b: alloc::string::String::new(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user