Disable old chat rendering
This commit is contained in:
parent
422641ddf0
commit
82fce0430d
1 changed files with 18 additions and 33 deletions
|
|
@ -1,62 +1,56 @@
|
||||||
mod action;
|
|
||||||
mod blocks;
|
|
||||||
mod cursor;
|
|
||||||
mod layout;
|
|
||||||
mod render;
|
|
||||||
mod util;
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crossterm::event::{KeyCode, KeyEvent};
|
use crossterm::event::KeyEvent;
|
||||||
use parking_lot::FairMutex;
|
use parking_lot::FairMutex;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use toss::frame::{Frame, Size};
|
use toss::frame::{Frame, Size};
|
||||||
use toss::terminal::Terminal;
|
use toss::terminal::Terminal;
|
||||||
|
|
||||||
use crate::store::{Msg, MsgStore};
|
use crate::store::{Msg, MsgStore};
|
||||||
|
use crate::ui::widgets::editor::EditorState;
|
||||||
use crate::ui::widgets::Widget;
|
use crate::ui::widgets::Widget;
|
||||||
|
|
||||||
use self::blocks::Blocks;
|
|
||||||
use self::cursor::Cursor;
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// State //
|
// State //
|
||||||
///////////
|
///////////
|
||||||
|
|
||||||
|
pub enum Cursor<I> {
|
||||||
|
Bottom,
|
||||||
|
Msg(I),
|
||||||
|
Editor(Option<I>),
|
||||||
|
Pseudo(Option<I>),
|
||||||
|
}
|
||||||
|
|
||||||
struct InnerTreeViewState<M: Msg, S: MsgStore<M>> {
|
struct InnerTreeViewState<M: Msg, S: MsgStore<M>> {
|
||||||
store: S,
|
store: S,
|
||||||
last_blocks: Blocks<M::Id>,
|
|
||||||
last_cursor: Cursor<M::Id>,
|
last_cursor: Cursor<M::Id>,
|
||||||
|
last_cursor_line: i32,
|
||||||
|
|
||||||
cursor: Cursor<M::Id>,
|
cursor: Cursor<M::Id>,
|
||||||
/// Set to true if the chat should be scrolled such that the cursor is fully
|
/// Set to true if the chat should be scrolled such that the cursor is fully
|
||||||
/// visible (if possible). If set to false, then the cursor itself is moved
|
/// visible (if possible). If set to false, then the cursor itself is moved
|
||||||
/// to a different message such that it remains visible.
|
/// to a different message such that it remains visible.
|
||||||
make_cursor_visible: bool,
|
make_cursor_visible: bool,
|
||||||
editor: (), // TODO
|
|
||||||
|
editor: EditorState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
||||||
fn new(store: S) -> Self {
|
fn new(store: S) -> Self {
|
||||||
Self {
|
Self {
|
||||||
store,
|
store,
|
||||||
last_blocks: Blocks::new(),
|
|
||||||
last_cursor: Cursor::Bottom,
|
last_cursor: Cursor::Bottom,
|
||||||
|
last_cursor_line: 0,
|
||||||
cursor: Cursor::Bottom,
|
cursor: Cursor::Bottom,
|
||||||
make_cursor_visible: false,
|
make_cursor_visible: false,
|
||||||
editor: (),
|
editor: EditorState::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_navigation(&mut self, event: KeyEvent) -> bool {
|
async fn handle_navigation(&mut self, event: KeyEvent) -> bool {
|
||||||
match event.code {
|
false
|
||||||
KeyCode::Up | KeyCode::Char('k') => self.move_cursor_up().await,
|
|
||||||
KeyCode::Down | KeyCode::Char('j') => self.move_cursor_down().await,
|
|
||||||
KeyCode::Char('g') => self.move_cursor_to_top().await,
|
|
||||||
KeyCode::Char('G') => self.move_cursor_to_bottom().await,
|
|
||||||
_ => return false,
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_messaging(
|
async fn handle_messaging(
|
||||||
|
|
@ -65,14 +59,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
||||||
crossterm_lock: &Arc<FairMutex<()>>,
|
crossterm_lock: &Arc<FairMutex<()>>,
|
||||||
event: KeyEvent,
|
event: KeyEvent,
|
||||||
) -> Option<(Option<M::Id>, String)> {
|
) -> Option<(Option<M::Id>, String)> {
|
||||||
match event.code {
|
None
|
||||||
KeyCode::Char('r') => self.reply_normal(terminal, crossterm_lock).await,
|
|
||||||
KeyCode::Char('R') => self.reply_alternate(terminal, crossterm_lock).await,
|
|
||||||
KeyCode::Char('t') | KeyCode::Char('T') => {
|
|
||||||
Self::create_new_thread(terminal, crossterm_lock)
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,7 +111,5 @@ where
|
||||||
|
|
||||||
async fn render(self: Box<Self>, frame: &mut Frame) {
|
async fn render(self: Box<Self>, frame: &mut Frame) {
|
||||||
let mut guard = self.0.lock().await;
|
let mut guard = self.0.lock().await;
|
||||||
guard.relayout(frame).await;
|
|
||||||
guard.draw_blocks(frame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue