From 7f5a18fa3478596c3c1dbdc7eb92da99b0945886 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 7 Apr 2024 04:19:50 +0200 Subject: [PATCH] Show help message --- src/list.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/list.rs b/src/list.rs index b8ea27bb..7329d2b8 100644 --- a/src/list.rs +++ b/src/list.rs @@ -6,10 +6,10 @@ use crossterm::{ }; use ratatui::{ backend::CrosstermBackend, - layout::Constraint, + layout::{Constraint, Rect}, style::{Style, Stylize}, - text::Span, - widgets::{HighlightSpacing, Row, Table, TableState}, + text::{Line, Span}, + widgets::{Block, Borders, HighlightSpacing, Row, Table, TableState}, Terminal, }; use std::io; @@ -54,6 +54,7 @@ fn table<'a>(state: &State, exercises: &'a [Exercise]) -> Table<'a> { .highlight_spacing(HighlightSpacing::Always) .highlight_style(Style::new().bg(ratatui::style::Color::Rgb(50, 50, 50))) .highlight_symbol("🦀") + .block(Block::default().borders(Borders::BOTTOM)) } pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> { @@ -75,7 +76,25 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> { terminal.draw(|frame| { let area = frame.size(); - frame.render_stateful_widget(&table, area, &mut table_state); + frame.render_stateful_widget( + &table, + Rect { + x: 0, + y: 0, + width: area.width, + height: area.height - 1, + }, + &mut table_state, + ); + frame.render_widget( + Span::raw("Navi: ↓/j ↑/k home/g end/G │ Filter done/pending: d/p │ Reset: r │ Continue at: c │ Quit: q"), + Rect { + x: 0, + y: area.height - 1, + width: area.width, + height: 1, + }, + ); })?; let key = loop {