-
Notifications
You must be signed in to change notification settings - Fork 29
/
icons.rs
98 lines (95 loc) · 4.57 KB
/
icons.rs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use crate::{config::IconSet, CONFIG};
pub fn get(id: &str) -> String {
CONFIG
.icons
.get(id)
.unwrap_or(
&match CONFIG.icon_set {
IconSet::Nerd => {
match id {
"apple" => "\u{f179}", // Font Awesome; apple
"arch" => "\u{f303}", // Font Linux
"centOS" => "\u{f304}", // Font Linux
"debian" => "\u{f306}", // Font Linux
"fedora" => "\u{f30a}", // Font Linux
"mint" => "\u{f30e}", // Font Linux
"SUSE" => "\u{f314}", // Font Linux
"ubuntu" => "\u{f31b}", // Font Linux
"elementary" => "\u{f309}", // Font Linux
"linux" => "\u{f31a}", // Font Linux
"windows" => "\u{f17a}", // Font Awesome; windows
"bsd" => "\u{f30c}", // Font Linux
"root" => "\u{e00a}", // Pomicons; lightning
"readonly" => "\u{f023}", // Font Awesome; lock
"failed" => "\u{e009}", // Pomicons; exclamation
"job" => "\u{e615}", // Seti UI
"package" => "\u{f187}", // Font Awesome; archive
"rss" => "\u{f09e}", // Font Awesome; rss
"home" => "\u{f015}", // Font Awesome; home
"github" => "\u{f09b}", // Font Awesome; github
"gitlab" => "\u{f296}", // Font Awesome; gitlab
"bitbucket" => "\u{f171}", // Font Awesome; bitbucket
"azure" => "\u{fd03}", // Font Awesome; azure
"git" => "\u{f418}", // Octicons; branch
"stash" => "\u{f01c}", // Font Awesome; inbox
"ahead" => "\u{f148}", // Font Awesome; level-up
"behind" => "\u{f149}", // Font Awesome; level-down
"modified" => "\u{f111}", // Unicode
"staged" => "\u{f067}", // Unicode
"toolbox" => "\u{f0ad}", // Font Awesome; wrench
_ => "",
}
}
IconSet::Unicode => {
match id {
// TODO: test if it's possible to use \uf8ff on an Apple machine
"apple" => "\u{1f34e}", // Emoji; red apple
"linux" => "\u{1f427}", // Emoji; penguin
"bsd" => "\u{1f608}", // Emoji; smiling face with horns
"windows" => "\u{1f5a5}", // Emoji; desktop computer
"root" => "\u{26a1}", // Emoji; high voltage
"readonly" => "\u{1f512}", // Emoji; locked
"failed" => "\u{2757}", // Emoji; exclamation mark
"job" => "\u{2699}", // Emoji; gear
"package" => "\u{1f4e6}", // Emoji; package
"rss" => "*",
"home" => "\u{1f3e0}", // Emoji; house
"stash" => "\u{1f4e5}", // Emoji; inbox tray
"ahead" => "\u{2191}", // Unicode
"behind" => "\u{2193}", // Unicode
"modified" => "\u{25cf}", // Unicode
"staged" => "\u{271a}", // Unicode
"toolbox" => "\u{1f527}", // Unicode
_ => "",
}
}
IconSet::ASCII => {
match id {
"root" => "#",
"readonly" => "@",
"failed" => "!",
"job" => "&",
"rss" => "*",
"home" => "~",
"stash" => "#",
"ahead" => ">",
"behind" => "<",
"modified" => "*",
"staged" => "+",
"toolbox" => "*",
_ => "",
}
}
}
.into(),
)
.to_owned()
}
pub fn repeat(icon: &str, n: usize) -> String {
let icon = get(icon);
if n > 5 {
format!("{}{}", icon, n)
} else {
icon.repeat(n)
}
}