ssh/model/
terminal.rs

1pub enum TerminalSizeType {
2    Character,
3    Pixel,
4}
5
6pub struct TerminalSize {
7    width: u32,
8    height: u32,
9    type_: TerminalSizeType,
10}
11
12impl TerminalSize {
13    pub fn from(width: u32, height: u32) -> Self {
14        TerminalSize {
15            width,
16            height,
17            type_: TerminalSizeType::Character,
18        }
19    }
20
21    pub fn from_type(width: u32, height: u32, type_: TerminalSizeType) -> Self {
22        TerminalSize {
23            width,
24            height,
25            type_,
26        }
27    }
28
29    pub(crate) fn fetch(&self) -> (u32, u32, u32, u32) {
30        match self.type_ {
31            TerminalSizeType::Character => (self.width, self.height, 0, 0),
32            TerminalSizeType::Pixel => (0, 0, self.width, self.height),
33        }
34    }
35}