aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
blob: d23f70d095d92366568aa1cc91f389e42ff19c77 (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
use cursive::theme::{BaseColor, Color};
use directories::ProjectDirs;
use std::fs;
use std::path::{Path, PathBuf};

pub struct AppConfig {
    pub true_chr: char,
    pub false_chr: char,
    pub future_chr: char,

    // view dimensions
    pub view_width: usize,
    pub view_height: usize,

    // app dimensions
    pub grid_width: usize,

    pub reached_color: Color,
    pub todo_color: Color,
    pub future_color: Color,
}

pub fn load_configuration_file() -> AppConfig {
    return AppConfig {
        true_chr: '·',
        false_chr: '·',
        future_chr: '·',
        view_width: 25,
        view_height: 8,
        grid_width: 3,
        reached_color: Color::Dark(BaseColor::Cyan),
        todo_color: Color::Dark(BaseColor::Magenta),
        future_color: Color::Light(BaseColor::Black),
    };
}

pub fn data_file() -> PathBuf {
    if let Some(proj_dirs) = ProjectDirs::from("rs", "nerdypepper", "dijo") {
        let mut data_file = PathBuf::from(proj_dirs.data_dir());
        fs::create_dir_all(&data_file);
        data_file.push("habit_record.json");
        return data_file;
    } else {
        panic!("Invalid home directory!")
    };
}