add select-bg-color

This commit is contained in:
Abin Simon 2019-12-11 15:40:52 +05:30 committed by Ferran Basora
parent 4643c4ca0f
commit a1792ea196
3 changed files with 22 additions and 3 deletions

View File

@ -54,10 +54,16 @@ fn app_args<'a>() -> clap::ArgMatches<'a> {
)
.arg(
Arg::with_name("select_foreground_color")
.help("Sets the foregroud color for selection")
.help("Sets the foreground color for selection")
.long("select-fg-color")
.default_value("blue"),
)
.arg(
Arg::with_name("select_background_color")
.help("Sets the background color for selection")
.long("select-bg-color")
.default_value("black"),
)
.arg(
Arg::with_name("reverse")
.help("Reverse the order for assigned hints")
@ -131,6 +137,8 @@ fn main() {
let hint_background_color = colors::get_color(args.value_of("hint_background_color").unwrap());
let select_foreground_color =
colors::get_color(args.value_of("select_foreground_color").unwrap());
let select_background_color =
colors::get_color(args.value_of("select_background_color").unwrap());
let command = args.value_of("command").unwrap();
let upcase_command = args.value_of("upcase_command").unwrap();
@ -155,6 +163,7 @@ fn main() {
contrast,
position,
select_foreground_color,
select_background_color,
foreground_color,
background_color,
hint_foreground_color,

View File

@ -12,6 +12,7 @@ pub struct View<'a> {
contrast: bool,
position: &'a str,
select_foreground_color: Color,
select_background_color: Color,
foreground_color: Color,
background_color: Color,
hint_background_color: Color,
@ -26,6 +27,7 @@ impl<'a> View<'a> {
contrast: bool,
position: &'a str,
select_foreground_color: Color,
select_background_color: Color,
foreground_color: Color,
background_color: Color,
hint_foreground_color: Color,
@ -39,6 +41,7 @@ impl<'a> View<'a> {
contrast: contrast,
position: position,
select_foreground_color: select_foreground_color,
select_background_color: select_background_color,
foreground_color: foreground_color,
background_color: background_color,
hint_foreground_color: hint_foreground_color,
@ -117,6 +120,11 @@ impl<'a> View<'a> {
} else {
self.foreground_color
};
let selected_background_color = if selected == Some(mat) {
self.select_background_color
} else {
self.background_color
};
// Find long utf sequences and extract it from mat.x
let line = &self.state.lines[mat.y as usize];
@ -130,7 +138,7 @@ impl<'a> View<'a> {
mat.y as usize,
rustbox::RB_NORMAL,
selected_color,
self.background_color,
selected_background_color,
&text,
);
@ -227,6 +235,7 @@ mod tests {
contrast: false,
position: &"",
select_foreground_color: rustbox::Color::Default,
select_background_color: rustbox::Color::Default,
foreground_color: rustbox::Color::Default,
background_color: rustbox::Color::Default,
hint_background_color: rustbox::Color::Default,

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source ~/.bash_profile
[ -f ~/.bash_profile ] && source ~/.bash_profile
PARAMS=()
@ -36,6 +36,7 @@ add-option-param "bg-color"
add-option-param "hint-bg-color"
add-option-param "hint-fg-color"
add-option-param "select-fg-color"
add-option-param "select-bg-color"
add-option-param "command"
add-option-param "upcase-command"
add-multi-param "regexp"