use syntect::highlighting::Style as SyntectStyle;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use crate::cli;
use crate::config::INLINE_SYMBOL_WIDTH_1;
use crate::fatal;
use crate::config::Config;
use crate::delta::DiffType;
use crate::delta::State;
use crate::features::line_numbers::{self, SideBySideLineWidth};
use crate::features::side_by_side::{available_line_width, line_is_too_long, Left, Right};
use crate::minusplus::*;
use crate::paint::LineSections;
use crate::style::Style;
use crate::utils::syntect::FromDeltaStyle;
/// See [`wrap_line`] for documentation.
#[derive(Clone, Debug)]
pub struct WrapConfig {
pub left_symbol: String,
pub right_symbol: String,
pub right_prefix_symbol: String,
// In fractions of 1000 so that a >100 wide panel can
// still be configured down to a single character.
pub use_wrap_right_permille: usize,
// This value is --wrap-max-lines + 1, and unlimited is 0, see
// adapt_wrap_max_lines_argument()
pub max_lines: usize,
pub inline_hint_syntect_style: SyntectStyle,
}
impl WrapConfig {
pub fn from_opt(opt: &cli::Opt, inline_hint_style: Style) -> Self {
Self {
left_symbol: ensure_display_width_1("wrap-left-symbol", opt.wrap_left_symbol.clone()),
right_symbol: ensure_display_width_1(
"wrap-right-symbol",
opt.wrap_right_symbol.clone(),
),
right_prefix_symbol: ensure_display_width_1(
"wrap-right-prefix-symbol",
opt.wrap_right_prefix_symbol.clone(),
),
use_wrap_right_permille: {
let arg = &opt.wrap_right_percent;
let percent = remove_percent_suffix(arg)
.parse::<