Prefer bold over bright terminal colours

Bright colours work well on dark terminals, but not on light
terminals.
better_inline
Wilfred Hughes 2022-01-27 22:24:47 +07:00
parent fca1c6fffe
commit 98ccc6e2d9
3 changed files with 10 additions and 23 deletions

@ -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;

@ -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

@ -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,