From a1792ea196f33b3249b988c250b9d2a86baf20b7 Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Wed, 11 Dec 2019 15:40:52 +0530 Subject: [PATCH] add select-bg-color --- src/main.rs | 11 ++++++++++- src/view.rs | 11 ++++++++++- tmux-thumbs.sh | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1e55510..7bf1ce1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, diff --git a/src/view.rs b/src/view.rs index 9836f75..1d6225e 100644 --- a/src/view.rs +++ b/src/view.rs @@ -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, diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index cb0cde6..00ae8ca 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -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"