Skip to content

Commit

Permalink
updated event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Jan 10, 2024
1 parent dfafdf0 commit 788c79b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode},
};

use models::event_handling::Event;
use models::states::InputMode;
use ratatui::{
backend::CrosstermBackend,
Expand All @@ -28,8 +29,6 @@ mod routes;
mod util;
mod widgets;

use crate::util::event::Event;

use crate::widgets::{
chart::{render_chart, TokenChart},
table::{render_table, StatefulTable},
Expand Down Expand Up @@ -117,6 +116,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
f.render_stateful_widget(render_table(&mut table), chunks[2], &mut table.state);
})?;

// #TODO: Move this to event handling

match rx.recv()? {
Event::Input(event) => match event.code {
KeyCode::Char('q') => {
Expand Down
5 changes: 2 additions & 3 deletions src/util/event.rs → src/models/event_handling.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pub enum Event<I> {
Input(I),
Tick,
Input(I),
Tick,
}


pub struct SinSignal {
x: f64,
interval: f64,
Expand Down
1 change: 1 addition & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod event_handling;
pub mod position;
pub mod states;
1 change: 0 additions & 1 deletion src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod constants;
pub mod event;
pub mod list;
4 changes: 2 additions & 2 deletions src/widgets/chart.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::util::event::SinSignal;

use ratatui::{
style::{Color, Modifier, Style},
symbols,
text::Span,
widgets::{Axis, Block, Borders, Chart, Dataset},
};

use crate::models::event_handling::SinSignal;

pub struct TokenChart {
pub signal: SinSignal,
pub data: Vec<(f64, f64)>,
Expand Down

0 comments on commit 788c79b

Please sign in to comment.