rendering
This commit is contained in:
parent
36d698a3e1
commit
49cd6d6ab6
8 changed files with 178 additions and 157 deletions
|
|
@ -12,7 +12,7 @@ use ratatui::{
|
|||
crossterm::event::{KeyCode, KeyEvent},
|
||||
};
|
||||
|
||||
use super::{App, ScreenAction, ScreenView, screen_legend};
|
||||
use super::{App, ScreenView, screen_legend};
|
||||
use crate::agent::context::ContextSection;
|
||||
|
||||
pub(crate) struct ConsciousScreen {
|
||||
|
|
@ -117,13 +117,14 @@ impl ScreenView for ConsciousScreen {
|
|||
fn label(&self) -> &'static str { "conscious" }
|
||||
|
||||
fn tick(&mut self, frame: &mut Frame, area: Rect,
|
||||
key: Option<KeyEvent>, app: &mut App) -> Option<ScreenAction> {
|
||||
// Handle keys
|
||||
if let Some(key) = key {
|
||||
let context_state = self.read_context_state(app);
|
||||
let item_count = self.item_count(&context_state);
|
||||
events: &[ratatui::crossterm::event::Event], app: &mut App) {
|
||||
for event in events {
|
||||
if let ratatui::crossterm::event::Event::Key(key) = event {
|
||||
if key.kind != ratatui::crossterm::event::KeyEventKind::Press { continue; }
|
||||
let context_state = self.read_context_state(app);
|
||||
let item_count = self.item_count(&context_state);
|
||||
|
||||
match key.code {
|
||||
match key.code {
|
||||
KeyCode::Up => {
|
||||
self.selected = Some(self.selected.unwrap_or(0).saturating_sub(1));
|
||||
self.scroll_to_selected(item_count);
|
||||
|
|
@ -145,9 +146,9 @@ impl ScreenView for ConsciousScreen {
|
|||
}
|
||||
KeyCode::PageUp => { self.scroll = self.scroll.saturating_sub(20); }
|
||||
KeyCode::PageDown => { self.scroll += 20; }
|
||||
KeyCode::Esc => return Some(ScreenAction::Switch(0)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
|
|
@ -214,6 +215,5 @@ impl ScreenView for ConsciousScreen {
|
|||
.scroll((self.scroll, 0));
|
||||
|
||||
frame.render_widget(para, area);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue