From c2acb446e7868b67e5743d54cee5c64c469e5a18 Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Wed, 6 Mar 2024 14:14:07 -0500 Subject: Add keyboard commands --- src/components/hello_world.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/components/hello_world.rs') diff --git a/src/components/hello_world.rs b/src/components/hello_world.rs index afb9d47..2e3a2ee 100644 --- a/src/components/hello_world.rs +++ b/src/components/hello_world.rs @@ -1,7 +1,9 @@ use ratatui::prelude::*; use ratatui::widgets::Paragraph; +use crate::app_action::AppAction; use crate::component::Component; +use crate::keys::key_commands::*; #[derive(Default, Clone)] pub struct HelloWorld { @@ -14,7 +16,16 @@ impl Component for HelloWorld { Ok(()) } + fn handle_key_event( + &mut self, + key: crossterm::event::KeyEvent, + ) -> eyre::Result> { + self.text = serialize_key_event(key); + Ok(None) + } + fn render(&mut self, frame: &mut Frame, rect: Rect) -> eyre::Result<()> { + frame.render_widget(Paragraph::new(self.text.clone()), rect); Ok(()) -- cgit v1.2.3