use std::collections::HashMap; use std::path::PathBuf; use regex::Regex; use structopt::clap; use syntect::highlighting::Style as SyntectStyle; use syntect::highlighting::Theme as SyntaxTheme; use syntect::parsing::SyntaxSet; use unicode_segmentation::UnicodeSegmentation; use crate::ansi; use crate::cli; use crate::color; use crate::delta::State; use crate::env; use crate::fatal; use crate::features::navigate; use crate::features::side_by_side::{self, ansifill, LeftRight}; use crate::git_config::{GitConfig, GitConfigEntry}; use crate::minusplus::MinusPlus; use crate::paint::BgFillMethod; use crate::style::{self, Style}; use crate::tests::TESTING; use crate::utils::bat::output::PagingMode; use crate::utils::syntect::FromDeltaStyle; use crate::wrapping::WrapConfig; pub const INLINE_SYMBOL_WIDTH_1: usize = 1; fn remove_percent_suffix(arg: &str) -> &str { match &arg.strip_suffix('%') { Some(s) => s, None => arg, } } fn ensure_display_width_1(what: &str, arg: String) -> String { match arg.grapheme_indices(true).count() { INLINE_SYMBOL_WIDTH_1 => arg, width => fatal(format!( "Invalid value for {}, display width of \"{}\" must be {} but is {}", what, arg, INLINE_SYMBOL_WIDTH_1, width )), } } fn adapt_wrap_max_lines_argument(arg: String) -> usize { if arg == "∞" || arg == "unlimited" || arg.starts_with("inf") { 0 } else { arg.parse::() .unwrap_or_else(|err| fatal(format!("Invalid wrap-max-lines argument: {}", err))) + 1 } } pub struct Config { pub available_terminal_width: usize, pub background_color_extends_to_terminal_width: bool, pub blame_format: String, pub blame_palette: Vec, pub blame_timestamp_format: String, pub color_only: bool, pub commit_regex: Regex, pub commit_style: Style, pub cwd_relative_to_repo_root: Option, pub decorations_width: cli::Width, pub default_language: Option, pub diff_stat_align_width: usize, pub error_exit_code: i32, pub file_added_label: String, pub file_copied_label: String, pub file_modified_label: String, pub file_removed_label: String, pub file_renamed_label: String, pub right_arrow: String, pub file_style: Style, pub git_config_entries: HashMap, pub git_config: Option, pub git_minus_style: Style, pub git_plus_style: Style, pub hunk_header_file_style: Style, pub hunk_header_line_number_style: Style, pub hunk_header_style_include_file_path: bool, pub hunk_header_style_include_line_number: bool, pub hunk_header_style: Style, pub hunk_label: String, pub hyperlinks_commit_link_format: Option, pub hyperlinks_file_link_format: String, pub hyperlinks: bool, pub inline_hint_style: Style, pub inspect_raw_lines: cli::InspectRawLines, pub keep_plus_minus_markers: bool, pub line_buffer_size: usize, pub line_fill_method: BgFillMethod, pub line_numbers_format: LeftRight, pub line_numbers_style_leftright: LeftRight