This commit is contained in:
Jana Dönszelmann 2026-02-25 13:06:25 +01:00
parent d8e445b5f7
commit 4a7817a239
No known key found for this signature in database
4 changed files with 82 additions and 8 deletions

View file

@ -1,20 +1,20 @@
use ratatui_themes::{Theme, ThemeName};
use regex::bytes::Regex;
use std::{
cell::RefCell,
fs::{self, DirEntry},
io,
ops::ControlFlow,
path::{Path, PathBuf},
process::exit,
rc::Rc,
time::Instant,
};
use tui_widget_list::{ListBuilder, ListView};
use crate::tui::{
filter::FilterKind,
log_viewer::{InputState, InputTarget, LogViewer},
model::pretty_print_value,
widgets::{hyperlink::Hyperlink, items::Items, line_text::Highlighted},
widgets::{hyperlink::Hyperlink, items::Items, last_error::LastError},
};
use crate::tui::{
filter::{Filter, Matcher},
@ -27,7 +27,7 @@ use ratatui::{
buffer::Buffer,
crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers},
layout::{Constraint, HorizontalAlignment, Layout, Rect},
style::Style,
style::{self, Style},
text::Line,
widgets::{
Block, Clear, List, ListItem, ListState, Padding, Paragraph, StatefulWidget, Widget, Wrap,
@ -116,6 +116,8 @@ struct App {
compiler_root: Option<PathBuf>,
current_file: Option<LogfileReader>,
theme: Theme,
last_error: LastError,
}
impl App {
@ -126,6 +128,7 @@ impl App {
logs_dir,
compiler_root,
theme,
last_error: LastError::new(),
};
res.replace_tab(res.choose_file());
res
@ -356,6 +359,8 @@ impl App {
fn run(mut self, mut terminal: DefaultTerminal) -> io::Result<()> {
loop {
self.last_error.check_expired();
terminal.draw(|frame| frame.render_widget(&mut self, frame.area()))?;
if let Event::Key(key) = event::read()? {
@ -376,12 +381,14 @@ impl App {
let highlighted = Style::new().fg(palette.accent).bg(palette.selection);
let border = Style::new().fg(palette.fg).bg(palette.bg);
let border_highlighted = Style::new().fg(palette.secondary).bg(palette.bg);
let error = Style::new().fg(palette.error).bg(palette.bg);
Styles {
default,
highlighted,
border,
border_highlighted,
error,
}
}
@ -400,11 +407,12 @@ impl App {
}
}
struct Styles {
pub struct Styles {
default: Style,
highlighted: Style,
border: Style,
border_highlighted: Style,
error: Style,
}
impl Widget for &mut App {
@ -471,6 +479,8 @@ impl Widget for &mut App {
.style(styles.default)
.render(middle, buf);
let [right, error] =
Layout::vertical([Constraint::Length(1), Constraint::Length(1)]).areas(right);
Paragraph::new("").style(styles.default).render(right, buf);
for tab in &mut self.tabs {
@ -533,6 +543,7 @@ impl Widget for &mut App {
.get(idx)
.map(|(a, b)| (a.clone(), b.clone()))
}),
self.last_error.clone(),
)
.styled_ref(&styles)
.render(main_area, buf);
@ -575,6 +586,8 @@ impl Widget for &mut App {
Paragraph::new(HELP_TEXT).render(popup_area, buf);
}
}
self.last_error.clone().styled(&styles).render(error, buf);
}
}
}