summaryrefslogtreecommitdiffstats
path: root/src/display/mod.rs
blob: 01b47ebf3a69783fd033097ec4250c8c4a200335 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! This module is where is defined whether broot
//! writes on stdout, on stderr or elsewhere. It also provides helper
//! structs for io.

/// declare a style named `$dst` which is usually a reference to the `$src`
/// skin but, in case `selected` is true, is a clone with background changed
/// to the one of selected lines.
macro_rules! cond_bg {
    ($dst:ident, $self:ident, $selected:expr, $src:expr) => {
        let mut cloned_style;
        let $dst = if $selected {
            cloned_style = $src.clone();
            if let Some(c) = $self.skin.selected_line.get_bg() {
                cloned_style.set_bg(c);
            }
            &cloned_style
        } else {
            &$src
        };
    };
}

mod areas;
mod col;
mod crop_writer;
mod displayable_tree;
pub mod flags_display;
mod git_status_display;
pub mod status_line;
mod matched_string;
mod screen;

use std::io::BufWriter;

pub use {
    areas::Areas,
    col::{Col, Cols, DEFAULT_COLS},
    crop_writer::CropWriter,
    displayable_tree::DisplayableTree,
    git_status_display::GitStatusDisplay,
    matched_string::MatchedString,
    screen::Screen,
};

/// if true then the status of a panel covers the whole width
/// of the terminal (over the other panels)
pub const WIDE_STATUS: bool = true;

/// the type used by all GUI writing functions
pub type W = BufWriter<std::io::Stderr>;

/// return the writer used by the application
pub fn writer() -> W {
    BufWriter::new(std::io::stderr())
}