1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::options::common::constants::*;
use crate::Error;
use std::fmt;
use std::str::FromStr;

//status-position [top | bottom]
#[derive(PartialEq, Clone, Debug)]
#[cfg(feature = "tmux_1_7")]
pub enum StatusPosition {
    Top,
    Bottom,
}

#[cfg(feature = "tmux_1_7")]
impl FromStr for StatusPosition {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Error> {
        match s {
            TOP => Ok(Self::Top),
            BOTTOM => Ok(Self::Bottom),
            _ => Err(Error::ParseStatusPosition),
        }
    }
}

#[cfg(feature = "tmux_1_7")]
impl fmt::Display for StatusPosition {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::Top => write!(f, "{}", TOP),
            Self::Bottom => write!(f, "{}", BOTTOM),
        }
    }
}