mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
uistate cmp
This commit is contained in:
parent
7bda24c6ba
commit
fa539dfeae
1 changed files with 34 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ use crate::{copy_osc, parse_line_full};
|
|||
use derive_more::From;
|
||||
use ratatui::widgets::TableState;
|
||||
|
||||
#[derive(Clone, From)]
|
||||
#[derive(Clone, From, PartialEq)]
|
||||
pub enum UiState<'a> {
|
||||
MatchList(MatchListState),
|
||||
Match(MatchState<'a>),
|
||||
|
|
@ -26,6 +26,12 @@ impl MatchListState {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for MatchListState {
|
||||
fn eq(&self, _other: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MatchState<'a> {
|
||||
pub result: &'a LogMatch,
|
||||
|
|
@ -39,6 +45,12 @@ impl<'a> MatchState<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for MatchState<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.result.result == other.result.result
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LogsState<'a> {
|
||||
pub lines: &'a [usize],
|
||||
|
|
@ -46,15 +58,21 @@ pub struct LogsState<'a> {
|
|||
pub previous: Box<UiState<'a>>,
|
||||
}
|
||||
|
||||
impl PartialEq for LogsState<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.lines == other.lines
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ErrorState<'a> {
|
||||
pub table_state: ScrollbarTableState,
|
||||
pub previous: Box<UiState<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> LogsState<'a> {
|
||||
fn selected(&self) -> usize {
|
||||
self.table_state.selected()
|
||||
impl PartialEq for ErrorState<'_> {
|
||||
fn eq(&self, _other: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +85,18 @@ pub struct LogState<'a> {
|
|||
pub previous: Box<UiState<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> LogsState<'a> {
|
||||
fn selected(&self) -> usize {
|
||||
self.table_state.selected()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for LogState<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.log.index == other.log.index
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> UiState<'a> {
|
||||
pub fn new(app: &App) -> Self {
|
||||
let mut table_state = TableState::default();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue