From 98ccc6e2d9e0ac53c1b2c18932a975ada844e166 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Thu, 27 Jan 2022 22:24:47 -0800 Subject: [PATCH] Prefer bold over bright terminal colours Bright colours work well on dark terminals, but not on light terminals. --- src/inline.rs | 4 ++-- src/side_by_side.rs | 17 ++++++----------- src/style.rs | 12 ++---------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/inline.rs b/src/inline.rs index 05217cfed..b00a39caf 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -59,7 +59,7 @@ pub fn display( for (lhs_line, _) in &hunk_lines { if let Some(lhs_line) = lhs_line { - res.push_str(&format_line_num(*lhs_line).bright_red().to_string()); + res.push_str(&format_line_num(*lhs_line).red().bold().to_string()); res.push_str(" "); res.push_str(lhs_lines[lhs_line.0]); } else { @@ -70,7 +70,7 @@ pub fn display( for (_, rhs_line) in &hunk_lines { if let Some(rhs_line) = rhs_line { res.push_str(" "); - res.push_str(&format_line_num(*rhs_line).bright_green().to_string()); + res.push_str(&format_line_num(*rhs_line).green().bold().to_string()); res.push_str(rhs_lines[rhs_line.0]); } else { continue; diff --git a/src/side_by_side.rs b/src/side_by_side.rs index 5ffaf3656..cbea8436d 100644 --- a/src/side_by_side.rs +++ b/src/side_by_side.rs @@ -90,7 +90,7 @@ fn display_line_nums( Some(line_num) => { let s = format_line_num_padded(line_num, widths.lhs_line_nums); if lhs_has_novel { - s.bright_red().to_string() + s.red().bold().to_string() } else { s } @@ -104,7 +104,7 @@ fn display_line_nums( Some(line_num) => { let s = format_line_num_padded(line_num, widths.rhs_line_nums); if rhs_has_novel { - s.bright_green().to_string() + s.green().bold().to_string() } else { s } @@ -250,15 +250,10 @@ pub fn display_hunks( let rhs_colored_src = apply_colors(rhs_src, false, rhs_mps); if lhs_src.is_empty() { - return display_single_column( - display_path, - lang_name, - &rhs_colored_src, - Color::BrightGreen, - ); + return display_single_column(display_path, lang_name, &rhs_colored_src, Color::Green); } if rhs_src.is_empty() { - return display_single_column(display_path, lang_name, &lhs_colored_src, Color::BrightRed); + return display_single_column(display_path, lang_name, &lhs_colored_src, Color::Red); } // TODO: this is largely duplicating the `apply_colors` logic. @@ -381,7 +376,7 @@ pub fn display_hunks( ); if let Some(line_num) = lhs_line_num { if lhs_lines_with_novel.contains(&line_num) { - s = s.bright_red().to_string() + s = s.red().bold().to_string() } } s @@ -396,7 +391,7 @@ pub fn display_hunks( ); if let Some(line_num) = rhs_line_num { if rhs_lines_with_novel.contains(&line_num) { - s = s.bright_green().to_string(); + s = s.green().bold().to_string(); } } s diff --git a/src/style.rs b/src/style.rs index 9d367c0ec..aa2968930 100644 --- a/src/style.rs +++ b/src/style.rs @@ -212,11 +212,7 @@ pub fn color_positions(is_lhs: bool, positions: &[MatchedPos]) -> Vec<(SingleLin dimmed: false, }, MatchKind::Novel { highlight, .. } => Style { - foreground: Some(if is_lhs { - Color::BrightRed - } else { - Color::BrightGreen - }), + foreground: Some(if is_lhs { Color::Red } else { Color::Green }), background: None, bold: match highlight { TokenKind::Delimiter => true, @@ -227,11 +223,7 @@ pub fn color_positions(is_lhs: bool, positions: &[MatchedPos]) -> Vec<(SingleLin dimmed: false, }, MatchKind::ChangedCommentPart { .. } => Style { - foreground: Some(if is_lhs { - Color::BrightRed - } else { - Color::BrightGreen - }), + foreground: Some(if is_lhs { Color::Red } else { Color::Green }), background: None, bold: true, dimmed: false,