handle more date formats

This commit is contained in:
Robin Appelman 2024-09-16 11:24:06 +02:00
commit 730b7b8c7a
6 changed files with 26 additions and 16 deletions

View file

@ -32,7 +32,7 @@ pub fn raw_logs<'a>(app: &'a App<'a>, lines: &[usize]) -> ScrollbarTable<'a> {
fn log_row<'a>(line: &'a LogLine<'a>) -> Row<'a> {
Row::new([
Text::from(line.level.as_str()),
Text::from(line.app),
Text::from(line.app.as_ref()),
Text::from(line.display()),
Text::from(format_time(line.time)).alignment(Alignment::Right),
])

View file

@ -35,7 +35,7 @@ fn group_row<'a>(app: &'a App, group: &'a GroupedLines) -> Row<'a> {
Row::new([
Text::from(line.level.as_str()),
Text::from(line.app),
Text::from(line.app.as_ref()),
Text::from(line.display()),
Text::from(group.sparkline.as_str()),
Text::from(group.len().to_string()),

View file

@ -1,4 +1,3 @@
use std::iter::once;
use crate::app::{App, LogMatch};
use crate::logline::{FullLogLine, LogLine};
use crate::ui::table::ScrollbarTableState;
@ -6,6 +5,7 @@ use crate::ui::UI_HEADER_SIZE;
use crate::{copy_osc, parse_line_full};
use derive_more::From;
use ratatui::widgets::TableState;
use std::iter::once;
#[derive(Clone, From, PartialEq)]
pub enum UiState<'a> {
@ -213,7 +213,11 @@ impl<'a> UiState<'a> {
UiState::MatchList(MatchListState { app, .. }) => {
let mut total_height = 0;
let match_row_counts = app.matches.iter().map(|m| m.row_count());
for (index, row_count) in once(1).chain(match_row_counts).chain(once(1)).enumerate().skip(self.scroll_offset())
for (index, row_count) in once(1)
.chain(match_row_counts)
.chain(once(1))
.enumerate()
.skip(self.scroll_offset())
{
if total_height > row {
return index - 1;

View file

@ -102,7 +102,10 @@ impl ScrollbarTableState {
pub fn scroll(&mut self, step: isize) {
*self.table.offset_mut() = self.table.offset().saturating_add_signed(step);
let selected = self.selected().saturating_add_signed(step).min(self.count - 1);
let selected = self
.selected()
.saturating_add_signed(step)
.min(self.count - 1);
self.table.select(Some(selected));
self.scrollbar = self.scrollbar.position(selected);
}