use std::collections::HashMap; use std::path::PathBuf; use regex::Regex; 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::handlers; use crate::handlers::blame::parse_blame_line_numbers; use crate::handlers::blame::BlameLineNumbers; use crate::minusplus::MinusPlus; use crate::paint::BgFillMethod; use crate::parse_styles; use crate::style; use crate::style::Style; use crate::tests::TESTING; use crate::utils; use crate::utils::bat::output::PagingMode; use crate::utils::regex_replacement::RegexReplacement; 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 } } #[cfg_attr(test, derive(Clone))] pub struct Config { pub available_terminal_width: usize, pub background_color_extends_to_terminal_width: bool, pub blame_code_style: Option