@@ -10,12 +10,22 @@ use crate::{
1010 errors::Result,
1111 input::Input,
1212 line_range::{HighlightedLineRanges, LineRanges},
13− LineRange, StyleComponent, StyleComponents, SyntaxMapping, WrappingMode,
13+ style::{StyleComponent, StyleComponents},
14+ LineRange, SyntaxMapping, WrappingMode,
1415};
1516
1617#[cfg(feature = "paging")]
1718use crate::config::PagingMode;
1819
20+#[derive(Default)]
21+struct ActiveStyleComponents {
22+ header: bool,
23+ vcs_modification_markers: bool,
24+ grid: bool,
25+ line_numbers: bool,
26+ snip: bool,
27+}
28+
1929pub struct PrettyPrinter<'a> {
2030 inputs: Vec<Input<'a>>,
2131 config: Config<'a>,
@@ -23,6 +33,7 @@ pub struct PrettyPrinter<'a> {
2333
2434 highlighted_lines: Vec<LineRange>,
2535 term_width: Option<usize>,
36+ active_style_components: ActiveStyleComponents,
2637}
2738
2839impl<'a> PrettyPrinter<'a> {
@@ -39,6 +50,7 @@ impl<'a> PrettyPrinter<'a> {
3950
4051 highlighted_lines: vec![],
4152 term_width: None,
53+ active_style_components: ActiveStyleComponents::default(),
4254 }
4355 }
4456
@@ -107,9 +119,33 @@ impl<'a> PrettyPrinter<'a> {
107119 self
108120 }
109121
110− /// Configure style elements like grid or line numbers (default: "full" style)
111− pub fn style_components(&mut self, components: &[StyleComponent]) -> &mut Self {
112− self.config.style_components = StyleComponents::new(components);
122+ /// Whether to show a header with the file name
123+ pub fn header(&mut self, yes: bool) -> &mut Self {
124+ self.active_style_components.header = yes;
125+ self
126+ }
127+
128+ /// Whether to show line numbers
129+ pub fn line_numbers(&mut self, yes: bool) -> &mut Self {
130+ self.active_style_components.line_numbers = yes;
131+ self
132+ }
133+
134+ /// Whether to paint a grid, separating line numbers, git changes and the code
135+ pub fn grid(&mut self, yes: bool) -> &mut Self {
136+ self.active_style_components.grid = yes;
137+ self
138+ }
139+
140+ /// Whether to show modification markers for VCS changes
141+ pub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self {
142+ self.active_style_components.vcs_modification_markers = yes;
143+ self
144+ }
145+
146+ /// Whether to show "snip" markers between visible line ranges (default: no)
147+ pub fn snip(&mut self, yes: bool) -> &mut Self {
148+ self.active_style_components.snip = yes;
113149 self
114150 }
115151
@@ -175,6 +211,24 @@ impl<'a> PrettyPrinter<'a> {
175211 .term_width
176212 .unwrap_or_else(|| Term::stdout().size().1 as usize);
177213
214+ let mut style_components = vec![];
215+ if self.active_style_components.grid {
216+ style_components.push(StyleComponent::Grid);
217+ }
218+ if self.active_style_components.header {
219+ style_components.push(StyleComponent::Header);
220+ }
221+ if self.active_style_components.line_numbers {
222+ style_components.push(StyleComponent::LineNumbers);
223+ }
224+ if self.active_style_components.snip {
225+ style_components.push(StyleComponent::Snip);
226+ }
227+ if self.active_style_components.vcs_modification_markers {
228+ style_components.push(StyleComponent::Changes);
229+ }
230+ self.config.style_components = StyleComponents::new(&style_components);
231+
178232 let mut inputs: Vec<Input> = vec![];
179233 std::mem::swap(&mut inputs, &mut self.inputs);
180234