use std::borrow::Cow;
use std::collections::HashMap;
use std::io::Write;
use ansi_term::ANSIString;
use itertools::Itertools;
use syntect::easy::HighlightLines;
use syntect::highlighting::Style as SyntectStyle;
use syntect::parsing::{SyntaxReference, SyntaxSet};
use crate::config::{self, delta_unreachable, Config};
use crate::delta::{DiffType, InMergeConflict, MergeParents, State};
use crate::features::hyperlinks;
use crate::features::line_numbers::{self, LineNumbersData};
use crate::features::side_by_side::ansifill;
use crate::features::side_by_side::{self, PanelSide};
use crate::handlers::merge_conflict;
use crate::minusplus::*;
use crate::paint::superimpose_style_sections::superimpose_style_sections;
use crate::style::Style;
use crate::{ansi, style};
use crate::{edits, utils, utils::tabs};
pub type LineSections<'a, S> = Vec<(S, &'a str)>;
pub struct Painter<'p> {
pub minus_lines: Vec<(String, State)>,
pub plus_lines: Vec<(String, State)>,
pub writer: &'p mut dyn Write,
pub syntax: &'p SyntaxReference,
pub highlighter: Option<HighlightLines<'p>>,
pub config: &'p config::Config,
pub output_buffer: String,
// If config.line_numbers is true, then the following is always Some().
// In side-by-side mode it is always Some (but possibly an empty one), even
// if config.line_numbers is false. See `UseFullPanelWidth` as well.
pub line_numbers_data: Option<line_numbers::LineNumbersData<'p>>,
pub merge_conflict_lines: merge_conflict::MergeConflictLines,
pub merge_conflict_commit_names: merge_conflict::MergeConflictCommitNames,
}
// How the background of a line is filled up to the end
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BgFillMethod {
// Fill the background with ANSI spaces if possible,
// but might fallback to Spaces (e.g. in the left side-by-side panel),
// also see `UseFullPanelWidth`
TryAnsiSequence,
Spaces,
}
// If the background of a line extends to the end, and if configured to do so, how.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BgShouldFill {
With(