From 1478ce4d160711d416ddcd0cbb5b5de43e5254a2 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 25 Jun 2020 10:43:00 -0400 Subject: Implement numbers as a feature --- src/cli.rs | 8 +++----- src/config.rs | 49 ++++++++++--------------------------------------- src/features/mod.rs | 4 ++++ src/features/numbers.rs | 30 ++++++++++++++++++++++++++++++ src/set_options.rs | 3 +++ 5 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 079a03c8..5136f6cb 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -323,18 +323,16 @@ pub struct Opt { /// line number in the new version of the file. A blank cell in the first or /// second column indicates that the line does not exist in that file (it was /// added or removed, respectively). - #[structopt(short = "n", long = "number")] + #[structopt(short = "n", long = "numbers")] pub show_line_numbers: bool, /// Style (foreground, background, attributes) for the minus file line numbers (line numbers in - /// the old version) See STYLES and LINE NUMBERS sections. Defaults to - /// --hunk-header-decoration-style. + /// the old version) See STYLES and LINE NUMBERS sections. #[structopt(long = "number-minus-style", default_value = "auto")] pub number_minus_style: String, /// Style (foreground, background, attributes) for the plus file line numbers (line numbers in - /// the old version) See STYLES and LINE NUMBERS sections. Defaults to - /// --hunk-header-decoration-style. + /// the old version) See STYLES and LINE NUMBERS sections. #[structopt(long = "number-plus-style", default_value = "auto")] pub number_plus_style: String, diff --git a/src/config.rs b/src/config.rs index 28020202..e7b6b868 100644 --- a/src/config.rs +++ b/src/config.rs @@ -162,11 +162,7 @@ impl From for Config { number_right_format_style, number_plus_style, number_zero_style, - ) = make_line_number_styles( - &opt, - hunk_header_style.decoration_ansi_term_style(), - true_color, - ); + ) = make_line_number_styles(&opt, true_color); let syntax_theme = if syntax_theme::is_no_syntax_highlighting_theme_name(&syntax_theme_name) { @@ -381,59 +377,34 @@ fn make_hunk_styles<'a>( fn make_line_number_styles<'a>( opt: &'a cli::Opt, - default_style: Option, true_color: bool, ) -> (Style, Style, Style, Style, Option