Skip to main content

clankerdiff_ratatui/
options.rs

1#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
2pub enum NavigationPane {
3    #[default]
4    Auto,
5    Hidden,
6    Width(u16),
7}
8
9impl NavigationPane {
10    pub(crate) fn width(self, available: u16, breakpoint: u16, automatic: u16) -> u16 {
11        let width = match self {
12            Self::Auto if available >= breakpoint => automatic,
13            Self::Width(width) => width,
14            Self::Auto | Self::Hidden => 0,
15        };
16        width.min(available.saturating_sub(2))
17    }
18}
19
20#[derive(Debug, Clone, PartialEq, Eq)]
21pub struct ReviewOptions {
22    pub footer: bool,
23    pub navigation: NavigationPane,
24    pub tab_width: u16,
25}
26
27impl Default for ReviewOptions {
28    fn default() -> Self {
29        Self {
30            footer: true,
31            navigation: NavigationPane::Auto,
32            tab_width: 2,
33        }
34    }
35}