tui framework, based on tui-rs (not ready for production)
View
and Controller
traits.Components in ashiba shall not implement View
and Controller
traits.
They merely provide a model to cover basic functionality.
Components can then be used in widgets through composition to fulfil the usecase.
It's as easy as this:
rust
fn main() {
ashiba::app::run(AshibaApp::default()).unwrap();
}
where AshibaApp
implements View
and Controller
.
The AshibaApp
struct acts as a model and could look something like this:
```rust
pub struct AshibaApp {
button: BasicButton,
counter: u32,
shouldquit: bool,
}
A `Controller` makes it possible to define actions for your App or Widget:
rust
impl Controller for AshibaApp {
fn handlemouse(&mut self, ev: MouseEvent) {
self.button.on_click(ev, || {
self.counter += 1;
})
}
fn handle_key(&mut self, ev: KeyEvent) {
if let KeyCode::Char('q') = ev.code {
self.should_quit = true;
}
}
fn should_quit(&self) -> bool {
self.should_quit
}
}
A `View` gives freedom to style your App or Widget:
rust
impl View for AshibaApp {
fn ui(&mut self, f: &mut Frame
Feel free to open an issue/PR explaining possible improvements or changes.
Also, please do not hesitate and open an issue when needed. I am happy to help!