summaryrefslogtreecommitdiffstats
path: root/src/ui/views/tui_view.rs
blob: d50c1a62eb2f8847a69416a20f906ec4c3e27e55 (plain)
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
36
37
use tui::buffer::Buffer;
use tui::layout::Rect;
use tui::widgets::Widget;

use super::TuiFolderView;
use super::TuiVSplitView;
use crate::config::option::DisplayMode;
use crate::context::AppContext;

pub struct TuiView<'a> {
    pub context: &'a AppContext,
    pub show_bottom_status: bool,
}

impl<'a> TuiView<'a> {
    pub fn new(context: &'a AppContext) -> Self {
        Self {
            context,
            show_bottom_status: true,
        }
    }
}

impl<'a> Widget for TuiView<'a> {
    fn render(self, area: Rect, buf: &mut Buffer) {
        let config = self.context.config_ref();
        let display_options = config.display_options_ref();
        match display_options.mode() {
            DisplayMode::Default => {
                TuiFolderView::new(self.context).render(area, buf);
            }
            DisplayMode::VSplit => {
                TuiVSplitView::new(self.context).render(area, buf);
            }
        }
    }
}