pub struct PrettyPrinter<'a> { /* private fields */ }
Implementations§
Source§impl<'a> PrettyPrinter<'a>
impl<'a> PrettyPrinter<'a>
pub fn new() -> Self
Sourcepub fn input(&mut self, input: Input<'a>) -> &mut Self
pub fn input(&mut self, input: Input<'a>) -> &mut Self
Add an input which should be pretty-printed
Sourcepub fn inputs(
&mut self,
inputs: impl IntoIterator<Item = Input<'a>>,
) -> &mut Self
pub fn inputs( &mut self, inputs: impl IntoIterator<Item = Input<'a>>, ) -> &mut Self
Adds multiple inputs which should be pretty-printed
Sourcepub fn input_file(&mut self, path: impl AsRef<Path>) -> &mut Self
pub fn input_file(&mut self, path: impl AsRef<Path>) -> &mut Self
Add a file which should be pretty-printed
Sourcepub fn input_files<I, P>(&mut self, paths: I) -> &mut Self
pub fn input_files<I, P>(&mut self, paths: I) -> &mut Self
Add multiple files which should be pretty-printed
Sourcepub fn input_stdin(&mut self) -> &mut Self
pub fn input_stdin(&mut self) -> &mut Self
Add STDIN as an input
Sourcepub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self
pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self
Add a byte string as an input
Sourcepub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self
pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self
Add a custom reader as an input
Sourcepub fn language(&mut self, language: &'a str) -> &mut Self
pub fn language(&mut self, language: &'a str) -> &mut Self
Specify the syntax file which should be used (default: auto-detect)
Sourcepub fn term_width(&mut self, width: usize) -> &mut Self
pub fn term_width(&mut self, width: usize) -> &mut Self
The character width of the terminal (default: autodetect)
Sourcepub fn tab_width(&mut self, tab_width: Option<usize>) -> &mut Self
pub fn tab_width(&mut self, tab_width: Option<usize>) -> &mut Self
The width of tab characters (default: None - do not turn tabs to spaces)
Sourcepub fn colored_output(&mut self, yes: bool) -> &mut Self
pub fn colored_output(&mut self, yes: bool) -> &mut Self
Whether or not the output should be colorized (default: true)
Sourcepub fn true_color(&mut self, yes: bool) -> &mut Self
pub fn true_color(&mut self, yes: bool) -> &mut Self
Whether or not to output 24bit colors (default: true)
Sourcepub fn line_numbers(&mut self, yes: bool) -> &mut Self
pub fn line_numbers(&mut self, yes: bool) -> &mut Self
Whether to show line numbers
Sourcepub fn grid(&mut self, yes: bool) -> &mut Self
pub fn grid(&mut self, yes: bool) -> &mut Self
Whether to paint a grid, separating line numbers, git changes and the code
Sourcepub fn rule(&mut self, yes: bool) -> &mut Self
pub fn rule(&mut self, yes: bool) -> &mut Self
Whether to paint a horizontal rule to delimit files
Sourcepub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self
pub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self
Whether to show modification markers for VCS changes. This has no effect if
the git
feature is not activated.
Sourcepub fn show_nonprintable(&mut self, yes: bool) -> &mut Self
pub fn show_nonprintable(&mut self, yes: bool) -> &mut Self
Whether to print binary content or nonprintable characters (default: no)
Sourcepub fn snip(&mut self, yes: bool) -> &mut Self
pub fn snip(&mut self, yes: bool) -> &mut Self
Whether to show “snip” markers between visible line ranges (default: no)
Sourcepub fn strip_ansi(&mut self, mode: StripAnsiMode) -> &mut Self
pub fn strip_ansi(&mut self, mode: StripAnsiMode) -> &mut Self
Whether to remove ANSI escape sequences from the input (default: never)
If Auto
is used, escape sequences will only be removed when the input
is not plain text.
Sourcepub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self
pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self
Text wrapping mode (default: do not wrap)
Sourcepub fn use_italics(&mut self, yes: bool) -> &mut Self
pub fn use_italics(&mut self, yes: bool) -> &mut Self
Whether or not to use ANSI italics (default: off)
Sourcepub fn paging_mode(&mut self, mode: PagingMode) -> &mut Self
pub fn paging_mode(&mut self, mode: PagingMode) -> &mut Self
If and how to use a pager (default: no paging)
Sourcepub fn pager(&mut self, cmd: &'a str) -> &mut Self
pub fn pager(&mut self, cmd: &'a str) -> &mut Self
Specify the command to start the pager (default: use “less”)
Sourcepub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self
pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self
Specify the lines that should be printed (default: all)
Sourcepub fn highlight(&mut self, line: usize) -> &mut Self
pub fn highlight(&mut self, line: usize) -> &mut Self
Specify a line that should be highlighted (default: none). This can be called multiple times to highlight more than one line. See also: highlight_range.
Sourcepub fn highlight_range(&mut self, from: usize, to: usize) -> &mut Self
pub fn highlight_range(&mut self, from: usize, to: usize) -> &mut Self
Specify a range of lines that should be highlighted (default: none). This can be called multiple times to highlight more than one range of lines.
Sourcepub fn squeeze_empty_lines(&mut self, maximum: Option<usize>) -> &mut Self
pub fn squeeze_empty_lines(&mut self, maximum: Option<usize>) -> &mut Self
Specify the maximum number of consecutive empty lines to print.
Sourcepub fn theme(&mut self, theme: impl AsRef<str>) -> &mut Self
pub fn theme(&mut self, theme: impl AsRef<str>) -> &mut Self
Specify the highlighting theme.
You can use crate::theme::theme
to pick a theme based on user preferences
and the terminal’s background color.
Sourcepub fn syntax_mapping(&mut self, mapping: SyntaxMapping<'a>) -> &mut Self
pub fn syntax_mapping(&mut self, mapping: SyntaxMapping<'a>) -> &mut Self
Specify custom file extension / file name to syntax mappings