summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-07-29 23:00:49 -0400
committerDan Davison <dandavison7@gmail.com>2020-08-01 11:38:19 -0400
commitd9a07679dfaf2b9c9b84187f3691aa93d8beca31 (patch)
tree05370847279730c98a9b40961780433dd1104aa0 /src/config.rs
parentcd7953c176c2bc71b34cc2aaa1618f6ab208538f (diff)
Emit raw lines instead of explicitly handling --color-moved
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs70
1 files changed, 15 insertions, 55 deletions
diff --git a/src/config.rs b/src/config.rs
index 4703e38e..9b39c350 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -15,7 +15,7 @@ use crate::delta::State;
use crate::env;
use crate::features::side_by_side;
use crate::git_config_entry::GitConfigEntry;
-use crate::style::Style;
+use crate::style::{self, Style};
pub struct Config {
pub available_terminal_width: usize,
@@ -46,7 +46,6 @@ pub struct Config {
pub minus_emph_style: Style,
pub minus_empty_line_marker_style: Style,
pub minus_file: Option<PathBuf>,
- pub minus_moved_style: Style,
pub minus_non_emph_style: Style,
pub minus_style: Style,
pub navigate: bool,
@@ -56,11 +55,10 @@ pub struct Config {
pub plus_emph_style: Style,
pub plus_empty_line_marker_style: Style,
pub plus_file: Option<PathBuf>,
- pub plus_moved_style: Style,
pub plus_non_emph_style: Style,
pub plus_style: Style,
- pub raw_expected_minus_style: Style,
- pub raw_expected_plus_style: Style,
+ pub git_minus_style: Style,
+ pub git_plus_style: Style,
pub side_by_side: bool,
pub side_by_side_data: side_by_side::SideBySideData,
pub syntax_dummy_theme: SyntaxTheme,
@@ -77,10 +75,8 @@ pub struct Config {
impl Config {
pub fn get_style(&self, state: &State) -> &Style {
match state {
- State::HunkMinus(false) => &self.minus_style,
- State::HunkMinus(true) => &self.minus_moved_style,
- State::HunkPlus(false) => &self.plus_style,
- State::HunkPlus(true) => &self.plus_moved_style,
+ State::HunkMinus(_) => &self.minus_style,
+ State::HunkPlus(_) => &self.plus_style,
State::CommitMeta => &self.commit_style,
State::FileMeta => &self.file_style,
State::HunkHeader => &self.hunk_header_style,
@@ -95,13 +91,11 @@ impl From<cli::Opt> for Config {
minus_style,
minus_emph_style,
minus_non_emph_style,
- minus_moved_style,
minus_empty_line_marker_style,
zero_style,
plus_style,
plus_emph_style,
plus_non_emph_style,
- plus_moved_style,
plus_empty_line_marker_style,
whitespace_error_style,
) = make_hunk_styles(&opt);
@@ -137,26 +131,14 @@ impl From<cli::Opt> for Config {
&opt.computed.available_terminal_width,
);
- let raw_expected_minus_style = Style::from_str(
- match opt.git_config_entries.get("color.diff.old") {
- Some(GitConfigEntry::Style(s)) => s,
- _ => "red",
- },
- None,
- None,
- opt.computed.true_color,
- false,
- );
- let raw_expected_plus_style = Style::from_str(
- match opt.git_config_entries.get("color.diff.new") {
- Some(GitConfigEntry::Style(s)) => s,
- _ => "green",
- },
- None,
- None,
- opt.computed.true_color,
- false,
- );
+ let git_minus_style = match opt.git_config_entries.get("color.diff.old") {
+ Some(GitConfigEntry::Style(s)) => Style::from_git_str(s),
+ _ => *style::GIT_DEFAULT_MINUS_STYLE,
+ };
+ let git_plus_style = match opt.git_config_entries.get("color.diff.new") {
+ Some(GitConfigEntry::Style(s)) => Style::from_git_str(s),
+ _ => *style::GIT_DEFAULT_PLUS_STYLE,
+ };
Self {
available_terminal_width: opt.computed.available_terminal_width,
@@ -189,7 +171,6 @@ impl From<cli::Opt> for Config {
minus_emph_style,
minus_empty_line_marker_style,
minus_file: opt.minus_file.map(|s| s.clone()),
- minus_moved_style,
minus_non_emph_style,
minus_style,
navigate: opt.navigate,
@@ -199,11 +180,10 @@ impl From<cli::Opt> for Config {
plus_emph_style,
plus_empty_line_marker_style,
plus_file: opt.plus_file.map(|s| s.clone()),
- plus_moved_style,
plus_non_emph_style,
plus_style,
- raw_expected_minus_style,
- raw_expected_plus_style,
+ git_minus_style,
+ git_plus_style,
side_by_side: opt.side_by_side,
side_by_side_data,
syntax_dummy_theme: SyntaxTheme::default(),
@@ -232,8 +212,6 @@ fn make_hunk_styles<'a>(
Style,
Style,
Style,
- Style,
- Style,
) {
let is_light_mode = opt.computed.is_light_mode;
let true_color = opt.computed.true_color;
@@ -273,14 +251,6 @@ fn make_hunk_styles<'a>(
false,
);
- let minus_moved_style = Style::from_str(
- &opt.color_moved_minus_style,
- Some(minus_style),
- None,
- true_color,
- false,
- );
-
// The style used to highlight a removed empty line when otherwise it would be invisible due to
// lack of background color in minus-style.
let minus_empty_line_marker_style = Style::from_str(
@@ -335,14 +305,6 @@ fn make_hunk_styles<'a>(
false,
);
- let plus_moved_style = Style::from_str(
- &opt.color_moved_plus_style,
- Some(plus_style),
- None,
- true_color,
- false,
- );
-
// The style used to highlight an added empty line when otherwise it would be invisible due to
// lack of background color in plus-style.
let plus_empty_line_marker_style = Style::from_str(
@@ -366,13 +328,11 @@ fn make_hunk_styles<'a>(
minus_style,
minus_emph_style,
minus_non_emph_style,
- minus_moved_style,
minus_empty_line_marker_style,
zero_style,
plus_style,
plus_emph_style,
plus_non_emph_style,
- plus_moved_style,
plus_empty_line_marker_style,
whitespace_error_style,
)