diff options
author | Thomas Otto <th1000s@posteo.net> | 2021-01-30 11:57:51 +0100 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-09-19 19:39:50 -0400 |
commit | b9952f91ccd6a016d38be0f87bdcf1bb5b06ca76 (patch) | |
tree | 9ccd69805c41b6e04bf809726721ee769badcdc5 /src/config.rs | |
parent | db04d5e4ec02ea30e208c64f6f77e1cbfccb2688 (diff) |
Option to set the background extension mode to ANSI or spaces
In side-by-side mode, if `background_color_extends_to_terminal_width`
is set, the left panel color is extended via spaces, but the right
one via an ANSI sequence which instructs the terminal emulator to
fill the background color rightwards.
The command line option --line-fill-method ansi|spaces can change
how the right panel background is filled.
Add enums `BgShouldFill` and `BgFillMethod` to better distinguish
if the background should be filled, and if so, how.
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 1b035f2b..fbd58044 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,6 +16,7 @@ use crate::env; use crate::features::navigate; use crate::features::side_by_side; use crate::git_config::{GitConfig, GitConfigEntry}; +use crate::paint::BgFillMethod; use crate::style::{self, Style}; pub struct Config { @@ -51,6 +52,7 @@ pub struct Config { pub hyperlinks_file_link_format: String, pub inspect_raw_lines: cli::InspectRawLines, pub keep_plus_minus_markers: bool, + pub line_fill_method: BgFillMethod, pub line_numbers: bool, pub line_numbers_left_format: String, pub line_numbers_left_style: Style, @@ -187,6 +189,16 @@ impl From<cli::Opt> for Config { let file_renamed_label = opt.file_renamed_label; let hunk_label = opt.hunk_label; + let line_fill_method = match opt.line_fill_method.as_deref() { + // Note that "default" is not documented + Some("ansi") | Some("default") | None => BgFillMethod::TryAnsiSequence, + Some("spaces") => BgFillMethod::Spaces, + _ => { + eprintln!("Invalid option for line-fill-method: Expected \"ansi\" or \"spaces\"."); + process::exit(1); + } + }; + let navigate_regexp = if opt.navigate || opt.show_themes { Some(navigate::make_navigate_regexp( opt.show_themes, @@ -245,6 +257,7 @@ impl From<cli::Opt> for Config { hyperlinks_file_link_format: opt.hyperlinks_file_link_format, inspect_raw_lines: opt.computed.inspect_raw_lines, keep_plus_minus_markers: opt.keep_plus_minus_markers, + line_fill_method, line_numbers: opt.line_numbers, line_numbers_left_format: opt.line_numbers_left_format, line_numbers_left_style, |