summaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/app.rs b/src/app.rs
index 71e6a02..937c7d7 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,6 +1,6 @@
use std::{io, time::Duration};
-use crate::{sheet::register::Register, tui, widgets::sheetview::SheetView};
+use crate::{sheet::register::Register, tui, widgets::{logview::LogView, sheetview::SheetView}};
use ratatui::{
crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers},
@@ -11,6 +11,7 @@ use ratatui::{
pub struct App<'a> {
exit: bool,
view: SheetView<'a>,
+ logview: Option<LogView<'a>>,
}
impl App<'_> {
@@ -30,7 +31,7 @@ impl App<'_> {
let view = SheetView::new(sheet_id).block(Block::bordered().title("Sheet"));
- Self { exit: false, view }
+ Self { exit: false, view, logview: None }
}
pub fn run(&mut self, terminal: &mut tui::Tui) -> io::Result<()> {
@@ -61,6 +62,12 @@ impl App<'_> {
fn handle_key_event(&mut self, key_event: KeyEvent) {
match key_event.code {
KeyCode::Char('q') if key_event.modifiers == KeyModifiers::CONTROL => self.exit(),
+ KeyCode::Char('l') if key_event.modifiers == KeyModifiers::CONTROL => {
+ match self.logview {
+ Some(_) => self.logview = None,
+ None => self.logview = Some(LogView::new().block(Block::bordered().title(" Log "))),
+ }
+ }
_ => self.view.handle_key_event(key_event),
}
}
@@ -75,6 +82,13 @@ impl Widget for &mut App<'_> {
where
Self: Sized,
{
- self.view.render(area, buf);
+ match &mut self.logview {
+ Some(logview) => {
+ let layout = Layout::vertical([Constraint::Min(2), Constraint::Length(15)]).split(area);
+ self.view.render(layout[0], buf);
+ logview.render(layout[1], buf);
+ },
+ None => self.view.render(area, buf),
+ }
}
}