Hook up Chat to UI

This commit is contained in:
Joscha 2022-06-13 10:17:30 +02:00
parent 4b28b0e3b2
commit 14125c1650
4 changed files with 67 additions and 17 deletions

41
cove-tui/src/chat.rs Normal file
View file

@ -0,0 +1,41 @@
use crossterm::event::KeyEvent;
use crossterm::style::ContentStyle;
use toss::frame::{Frame, Pos, Size};
use crate::traits::{Msg, MsgStore};
pub enum Mode {
Tree,
// Thread,
// Flat,
}
pub struct Chat<M: Msg, S: MsgStore<M>> {
cursor: Option<M::Id>,
store: S,
mode: Mode,
// tree: TreeView,
// thread: ThreadView,
// flat: FlatView,
}
impl<M: Msg, S: MsgStore<M>> Chat<M, S> {
pub fn new(store: S) -> Self {
Self {
cursor: None,
store,
mode: Mode::Tree,
}
}
}
impl<M: Msg, S: MsgStore<M>> Chat<M, S> {
pub fn handle_key_event(&mut self, key: KeyEvent, size: Size) {
// TODO
}
pub fn render(&mut self, frame: &mut Frame, pos: Pos, size: Size) {
// TODO
frame.write(Pos::new(0, 0), "Hello world!", ContentStyle::default());
}
}