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 derive_more::From;
|
||||||
use ratatui::widgets::TableState;
|
use ratatui::widgets::TableState;
|
||||||
|
|
||||||
#[derive(Clone, From)]
|
#[derive(Clone, From, PartialEq)]
|
||||||
pub enum UiState<'a> {
|
pub enum UiState<'a> {
|
||||||
MatchList(MatchListState),
|
MatchList(MatchListState),
|
||||||
Match(MatchState<'a>),
|
Match(MatchState<'a>),
|
||||||
|
|
@ -26,6 +26,12 @@ impl MatchListState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for MatchListState {
|
||||||
|
fn eq(&self, _other: &Self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MatchState<'a> {
|
pub struct MatchState<'a> {
|
||||||
pub result: &'a LogMatch,
|
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)]
|
#[derive(Clone)]
|
||||||
pub struct LogsState<'a> {
|
pub struct LogsState<'a> {
|
||||||
pub lines: &'a [usize],
|
pub lines: &'a [usize],
|
||||||
|
|
@ -46,15 +58,21 @@ pub struct LogsState<'a> {
|
||||||
pub previous: Box<UiState<'a>>,
|
pub previous: Box<UiState<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for LogsState<'_> {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.lines == other.lines
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ErrorState<'a> {
|
pub struct ErrorState<'a> {
|
||||||
pub table_state: ScrollbarTableState,
|
pub table_state: ScrollbarTableState,
|
||||||
pub previous: Box<UiState<'a>>,
|
pub previous: Box<UiState<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LogsState<'a> {
|
impl PartialEq for ErrorState<'_> {
|
||||||
fn selected(&self) -> usize {
|
fn eq(&self, _other: &Self) -> bool {
|
||||||
self.table_state.selected()
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +85,18 @@ pub struct LogState<'a> {
|
||||||
pub previous: Box<UiState<'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> {
|
impl<'a> UiState<'a> {
|
||||||
pub fn new(app: &App) -> Self {
|
pub fn new(app: &App) -> Self {
|
||||||
let mut table_state = TableState::default();
|
let mut table_state = TableState::default();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue