1use std::cell::RefCell;
2
3use ratatui::widgets::TableState;
4
5#[derive(Debug)]
6pub struct DiffState {
7 old_diff: RefCell<TableState>,
8 current_diff: RefCell<TableState>,
9}
10
11#[derive(Debug, Default, PartialEq, Eq)]
12pub enum RunningState {
13 #[default]
14 Running,
15 Done,
16}
17
18impl Default for DiffState {
19 fn default() -> Self {
20 Self {
21 old_diff: RefCell::from(TableState::default().with_selected(0)),
22 current_diff: RefCell::from(TableState::default().with_selected(0)),
23 }
24 }
25}
26
27impl DiffState {
28 pub fn old_diff(&self) -> &RefCell<TableState> {
29 &self.old_diff
30 }
31
32 pub fn current_diff(&self) -> &RefCell<TableState> {
33 &self.current_diff
34 }
35
36 pub fn reset_row_state(&self) {
37 self.old_diff.borrow_mut().select(Some(0));
38 self.current_diff.borrow_mut().select(Some(0));
39 }
40}