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}
25
26impl Default for ReviewOptions {
27    fn default() -> Self {
28        Self {
29            footer: true,
30            navigation: NavigationPane::Auto,
31        }
32    }
33}