My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: init zk component

+71 -8
+1
Cargo.lock
··· 2240 2240 version = "0.1.0" 2241 2241 dependencies = [ 2242 2242 "anyhow", 2243 + "async-trait", 2243 2244 "better-panic", 2244 2245 "clap", 2245 2246 "color-eyre",
+1
Cargo.toml
··· 74 74 kdl = "6.5.0" 75 75 dto = {path="./crates/dto"} 76 76 eframe = "0.34.1" 77 + async-trait = "0.1.89" 77 78 78 79 [build-dependencies] 79 80 anyhow = "1.0.102"
+1 -1
src/cli/mod.rs
··· 65 65 }, 66 66 /// List groups. 67 67 List { 68 - /// The file-path for data to pe put into. 68 + /// Filter by tag 69 69 #[arg(short = 't', long)] 70 70 by_tag: String, 71 71 },
+6 -5
src/tui/app.rs
··· 10 10 11 11 use crate::{ 12 12 config::Config, 13 - tui::{Event, Tui}, 13 + tui::{Event, Tui, components::Zk}, 14 14 }; 15 15 16 16 use super::{components::Component, signal::Signal}; ··· 38 38 pub enum Region { 39 39 #[default] 40 40 Home, 41 + Zk, 41 42 } 42 43 43 44 impl App { ··· 48 49 Ok(Self { 49 50 tick_rate, 50 51 frame_rate, 51 - components: vec![], 52 + components: vec![Box::new(Zk::new())], 52 53 should_quit: false, 53 54 should_suspend: false, 54 55 config: Config::parse()?, ··· 80 81 81 82 loop { 82 83 self.handle_events(&mut tui).await?; 83 - self.handle_signals(&mut tui)?; 84 + self.handle_signals(&mut tui).await?; 84 85 if self.should_suspend { 85 86 tui.suspend()?; 86 87 ··· 150 151 Ok(()) 151 152 } 152 153 153 - fn handle_signals(&mut self, tui: &mut Tui) -> Result<()> { 154 + async fn handle_signals(&mut self, tui: &mut Tui) -> Result<()> { 154 155 while let Ok(signal) = self.signal_rx.try_recv() { 155 156 if signal != Signal::Tick && signal != Signal::Render { 156 157 debug!("handling signal: {signal:?}"); ··· 193 194 } 194 195 195 196 for component in &mut self.components { 196 - if let Some(signal) = component.update(signal.clone())? { 197 + if let Some(signal) = component.update(signal.clone()).await? { 197 198 self.signal_tx.send(signal)?; 198 199 } 199 200 }
+10 -2
src/tui/components/mod.rs
··· 1 + use async_trait::async_trait; 1 2 use crossterm::event::{KeyEvent, MouseEvent}; 2 3 use ratatui::{ 3 4 Frame, ··· 10 11 tui::{Event, Signal}, 11 12 }; 12 13 14 + /// The zk component 15 + mod zk; 16 + 17 + pub use zk::*; 18 + 13 19 /// `Component` is a trait that represents a visual and interactive element of the user interface. 14 20 /// 15 21 /// Implementers of this trait can be registered with the main application loop and will be able to 16 22 /// receive events, update state, and be rendered on the screen. 17 - pub trait Component: Send { 23 + /// 24 + #[async_trait] 25 + pub trait Component: Send + Sync { 18 26 /// Register a signal handler that can send signals for processing if necessary. 19 27 /// 20 28 /// # Arguments ··· 106 114 /// # Returns 107 115 /// 108 116 /// * [`color_eyre::Result<Option<signal>>`] - A signal to be processed or none. 109 - fn update(&mut self, signal: Signal) -> color_eyre::Result<Option<Signal>>; 117 + async fn update(&mut self, signal: Signal) -> color_eyre::Result<Option<Signal>>; 110 118 111 119 /// Render the component on the screen. (REQUIRED) 112 120 ///
+52
src/tui/components/zk/mod.rs
··· 1 + use async_trait::async_trait; 2 + use color_eyre::eyre::Result; 3 + use ratatui::widgets::Paragraph; 4 + use tokio::sync::mpsc::UnboundedSender; 5 + 6 + use crate::tui::{Signal, components::Component}; 7 + 8 + mod zettel; 9 + 10 + pub struct Zk { 11 + signal_tx: Option<UnboundedSender<Signal>>, 12 + } 13 + 14 + impl Zk { 15 + pub const fn new() -> Self { 16 + Self { signal_tx: None } 17 + } 18 + } 19 + 20 + #[async_trait] 21 + impl Component for Zk { 22 + fn register_signal_handler(&mut self, tx: UnboundedSender<Signal>) -> Result<()> { 23 + self.signal_tx = Some(tx); 24 + Ok(()) 25 + } 26 + 27 + async fn update(&mut self, _signal: Signal) -> Result<Option<crate::tui::Signal>> { 28 + // match signal { 29 + // Signal::Tick => todo!(), 30 + // Signal::Render => todo!(), 31 + // Signal::Resize(_, _) => todo!(), 32 + // Signal::Suspend => todo!(), 33 + // Signal::Resume => todo!(), 34 + // Signal::Quit => todo!(), 35 + // Signal::ClearScreen => todo!(), 36 + // Signal::Error(_) => todo!(), 37 + // Signal::Help => todo!(), 38 + // Signal::Helix => todo!(), 39 + // } 40 + Ok(None) 41 + } 42 + 43 + fn draw( 44 + &mut self, 45 + frame: &mut ratatui::Frame, 46 + area: ratatui::prelude::Rect, 47 + ) -> color_eyre::Result<()> { 48 + let hello = Paragraph::new("Hello Surendra"); 49 + frame.render_widget(hello, area); 50 + Ok(()) 51 + } 52 + }
src/tui/components/zk/zettel.rs

This is a binary file and will not be displayed.