-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 👔 added Page and Pane traits, removed Component trait
- Loading branch information
Showing
5 changed files
with
89 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,67 @@ | ||
use color_eyre::eyre::Result; | ||
use crossterm::event::{KeyEvent, MouseEvent}; | ||
use ratatui::layout::Rect; | ||
use tokio::sync::mpsc::UnboundedSender; | ||
|
||
use crate::{ | ||
action::Action, | ||
config::Config, | ||
tui::{Event, EventResponse, Frame}, | ||
}; | ||
|
||
pub mod home; | ||
|
||
pub trait Page { | ||
#[allow(unused_variables)] | ||
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn register_config_handler(&mut self, config: Config) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
fn init(&mut self) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
fn handle_events(&mut self, event: Option<Event>) -> Result<Option<EventResponse<Action>>> { | ||
let r = match event { | ||
Some(Event::Key(key_event)) => self.handle_key_events(key_event)?, | ||
Some(Event::Mouse(mouse_event)) => self.handle_mouse_events(mouse_event)?, | ||
_ => None, | ||
}; | ||
Ok(r) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn handle_key_events(&mut self, key: KeyEvent) -> Result<Option<EventResponse<Action>>> { | ||
Ok(None) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Option<EventResponse<Action>>> { | ||
Ok(None) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn update(&mut self, action: Action) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
|
||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>; | ||
} | ||
|
||
pub trait Pane { | ||
fn init(&mut self) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn update(&mut self, action: Action) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
|
||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
pub mod action; | ||
pub mod app; | ||
pub mod cli; | ||
pub mod component; | ||
pub mod components; | ||
pub mod config; | ||
pub mod tui; | ||
|