Feat: saving screen during perfs

This commit is contained in:
2026-02-21 15:56:52 +01:00
parent 12b90bc99b
commit 79a4c3b6e2
17 changed files with 117 additions and 223 deletions

View File

@@ -13,40 +13,18 @@ use crate::widgets::{render_search_bar, CategoryItem, CategoryList, Selection};
use CatEntry::{Category, Section};
pub fn layout(area: Rect) -> (Rect, [Rect; 2]) {
let [header_area, body_area] =
Layout::vertical([Constraint::Length(5), Constraint::Fill(1)]).areas(area);
let body = Layout::horizontal([Constraint::Length(16), Constraint::Fill(1)]).areas(body_area);
(header_area, body)
pub fn layout(area: Rect) -> [Rect; 2] {
Layout::horizontal([Constraint::Length(16), Constraint::Fill(1)]).areas(area)
}
pub fn render(frame: &mut Frame, app: &App, area: Rect) {
let (header_area, [cat_area, words_area]) = layout(area);
render_header(frame, header_area);
let [cat_area, words_area] = layout(area);
let is_searching = !app.ui.dict_search_query.is_empty();
render_categories(frame, app, cat_area, is_searching);
render_words(frame, app, words_area, is_searching);
}
fn render_header(frame: &mut Frame, area: Rect) {
use ratatui::widgets::Wrap;
let theme = theme::get();
let desc = "Forth uses a stack: values are pushed, functions (called words) consume and \
produce values. Read left to right: 3 4 + -> push 3, push 4, + pops both, \
pushes 7. This page lists all words with their signature ( inputs -- outputs ).";
let block = Block::default()
.borders(Borders::ALL)
.border_style(Style::new().fg(theme.dict.border_normal))
.title("Dictionary");
let para = Paragraph::new(desc)
.style(Style::new().fg(theme.dict.header_desc))
.wrap(Wrap { trim: false })
.block(block);
frame.render_widget(para, area);
}
fn render_categories(frame: &mut Frame, app: &App, area: Rect, dimmed: bool) {
let theme = theme::get();
let focused = app.ui.dict_focus == DictFocus::Categories && !dimmed;