Struct bat::PrettyPrinter

source ·
pub struct PrettyPrinter<'a> { /* private fields */ }

Implementations§

source§

impl<'a> PrettyPrinter<'a>

source

pub fn new() -> Self

source

pub fn input(&mut self, input: Input<'a>) -> &mut Self

Add an input which should be pretty-printed

source

pub fn inputs( &mut self, inputs: impl IntoIterator<Item = Input<'a>> ) -> &mut Self

Adds multiple inputs which should be pretty-printed

source

pub fn input_file(&mut self, path: impl AsRef<Path>) -> &mut Self

Add a file which should be pretty-printed

source

pub fn input_files<I, P>(&mut self, paths: I) -> &mut Self
where I: IntoIterator<Item = P>, P: AsRef<Path>,

Add multiple files which should be pretty-printed

source

pub fn input_stdin(&mut self) -> &mut Self

Add STDIN as an input

source

pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self

Add a byte string as an input

source

pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self

Add a custom reader as an input

source

pub fn language(&mut self, language: &'a str) -> &mut Self

Specify the syntax file which should be used (default: auto-detect)

source

pub fn term_width(&mut self, width: usize) -> &mut Self

The character width of the terminal (default: autodetect)

source

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)

source

pub fn colored_output(&mut self, yes: bool) -> &mut Self

Whether or not the output should be colorized (default: true)

source

pub fn true_color(&mut self, yes: bool) -> &mut Self

Whether or not to output 24bit colors (default: true)

source

pub fn header(&mut self, yes: bool) -> &mut Self

Whether to show a header with the file name

source

pub fn line_numbers(&mut self, yes: bool) -> &mut Self

Whether to show line numbers

source

pub fn grid(&mut self, yes: bool) -> &mut Self

Whether to paint a grid, separating line numbers, git changes and the code

source

pub fn rule(&mut self, yes: bool) -> &mut Self

Whether to paint a horizontal rule to delimit files

source

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.

source

pub fn show_nonprintable(&mut self, yes: bool) -> &mut Self

Whether to print binary content or nonprintable characters (default: no)

source

pub fn snip(&mut self, yes: bool) -> &mut Self

Whether to show “snip” markers between visible line ranges (default: no)

source

pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self

Text wrapping mode (default: do not wrap)

source

pub fn use_italics(&mut self, yes: bool) -> &mut Self

Whether or not to use ANSI italics (default: off)

source

pub fn paging_mode(&mut self, mode: PagingMode) -> &mut Self

If and how to use a pager (default: no paging)

source

pub fn pager(&mut self, cmd: &'a str) -> &mut Self

Specify the command to start the pager (default: use “less”)

source

pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self

Specify the lines that should be printed (default: all)

source

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.

source

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.

source

pub fn theme(&mut self, theme: impl AsRef<str>) -> &mut Self

Specify the highlighting theme

source

pub fn syntax_mapping(&mut self, mapping: SyntaxMapping<'a>) -> &mut Self

Specify custom file extension / file name to syntax mappings

source

pub fn themes(&self) -> impl Iterator<Item = &str>

source

pub fn syntaxes(&self) -> impl Iterator<Item = Syntax> + '_

source

pub fn print(&mut self) -> Result<bool>

Pretty-print all specified inputs. This method will “use” all stored inputs. If you want to call ‘print’ multiple times, you have to call the appropriate input_* methods again.

Trait Implementations§

source§

impl Default for PrettyPrinter<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PrettyPrinter<'a>

§

impl<'a> !Send for PrettyPrinter<'a>

§

impl<'a> !Sync for PrettyPrinter<'a>

§

impl<'a> Unpin for PrettyPrinter<'a>

§

impl<'a> !UnwindSafe for PrettyPrinter<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.