Skip to content

Commit a0bc683

Browse files
choice horizontal scrolling
1 parent 43a64e3 commit a0bc683

21 files changed

+2395
-2037
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ license = "MIT"
9292
name = "boxmux"
9393
readme = "README.md"
9494
repository = "https://github.com/jowharshamshiri/boxmux"
95-
version = "0.226.272308"
95+
version = "0.227.273087"
9696

9797
[package.metadata.deb]
9898
assets = [["target/release/boxmux", "usr/bin/", "755"], ["README.md", "usr/share/doc/boxmux/README", "644"], ["examples/*", "usr/share/doc/boxmux/examples/", "644"]]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19050
1+
14801

src/color_utils.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
use crossterm::style::{Color, SetBackgroundColor, SetForegroundColor};
2+
3+
/// Get foreground color code, returning empty string for transparent (None) colors
4+
pub fn get_fg_color_transparent(color: &Option<String>) -> String {
5+
match color {
6+
Some(color_str) => get_fg_color(color_str),
7+
None => String::new(), // Transparent - no color change
8+
}
9+
}
10+
11+
/// Get background color code, returning empty string for transparent (None) colors
12+
pub fn get_bg_color_transparent(color: &Option<String>) -> String {
13+
match color {
14+
Some(color_str) => get_bg_color(color_str),
15+
None => String::new(), // Transparent - no color change
16+
}
17+
}
18+
19+
/// Check if color should be drawn (not transparent)
20+
pub fn should_draw_color(color: &Option<String>) -> bool {
21+
color.is_some()
22+
}
23+
24+
pub fn get_fg_color(color: &str) -> String {
25+
match color {
26+
"red" => format!("{}", SetForegroundColor(Color::Red)),
27+
"green" => format!("{}", SetForegroundColor(Color::Green)),
28+
"yellow" => format!("{}", SetForegroundColor(Color::Yellow)),
29+
"blue" => format!("{}", SetForegroundColor(Color::Blue)),
30+
"magenta" => format!("{}", SetForegroundColor(Color::Magenta)),
31+
"cyan" => format!("{}", SetForegroundColor(Color::Cyan)),
32+
"white" => format!("{}", SetForegroundColor(Color::White)),
33+
"black" => format!("{}", SetForegroundColor(Color::Black)),
34+
"reset" => format!("{}", SetForegroundColor(Color::Reset)),
35+
"bright_black" => format!("{}", SetForegroundColor(Color::AnsiValue(8))),
36+
"bright_red" => format!("{}", SetForegroundColor(Color::AnsiValue(9))),
37+
"bright_green" => format!("{}", SetForegroundColor(Color::AnsiValue(10))),
38+
"bright_yellow" => format!("{}", SetForegroundColor(Color::AnsiValue(11))),
39+
"bright_blue" => format!("{}", SetForegroundColor(Color::AnsiValue(12))),
40+
"bright_magenta" => format!("{}", SetForegroundColor(Color::AnsiValue(13))),
41+
"bright_cyan" => format!("{}", SetForegroundColor(Color::AnsiValue(14))),
42+
"bright_white" => format!("{}", SetForegroundColor(Color::AnsiValue(15))),
43+
_ => format!("{}", SetForegroundColor(Color::Reset)),
44+
}
45+
}
46+
47+
pub fn get_bg_color(color: &str) -> String {
48+
match color {
49+
"red" => format!("{}", SetBackgroundColor(Color::Red)),
50+
"green" => format!("{}", SetBackgroundColor(Color::Green)),
51+
"yellow" => format!("{}", SetBackgroundColor(Color::Yellow)),
52+
"blue" => format!("{}", SetBackgroundColor(Color::Blue)),
53+
"magenta" => format!("{}", SetBackgroundColor(Color::Magenta)),
54+
"cyan" => format!("{}", SetBackgroundColor(Color::Cyan)),
55+
"white" => format!("{}", SetBackgroundColor(Color::White)),
56+
"black" => format!("{}", SetBackgroundColor(Color::Black)),
57+
"reset" => format!("{}", SetBackgroundColor(Color::Reset)),
58+
"bright_black" => format!("{}", SetBackgroundColor(Color::AnsiValue(8))),
59+
"bright_red" => format!("{}", SetBackgroundColor(Color::AnsiValue(9))),
60+
"bright_green" => format!("{}", SetBackgroundColor(Color::AnsiValue(10))),
61+
"bright_yellow" => format!("{}", SetBackgroundColor(Color::AnsiValue(11))),
62+
"bright_blue" => format!("{}", SetBackgroundColor(Color::AnsiValue(12))),
63+
"bright_magenta" => format!("{}", SetBackgroundColor(Color::AnsiValue(13))),
64+
"bright_cyan" => format!("{}", SetBackgroundColor(Color::AnsiValue(14))),
65+
"bright_white" => format!("{}", SetBackgroundColor(Color::AnsiValue(15))),
66+
_ => format!("{}", SetBackgroundColor(Color::Reset)),
67+
}
68+
}

0 commit comments

Comments
 (0)