mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-20 04:40:00 +02:00
Add ANSI stripping to bat-as-a-library
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
input,
|
input,
|
||||||
line_range::{HighlightedLineRanges, LineRange, LineRanges},
|
line_range::{HighlightedLineRanges, LineRange, LineRanges},
|
||||||
style::StyleComponent,
|
style::StyleComponent,
|
||||||
SyntaxMapping, WrappingMode,
|
StripAnsiMode, SyntaxMapping, WrappingMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "paging")]
|
#[cfg(feature = "paging")]
|
||||||
@@ -182,6 +182,15 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
self
|
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.
|
||||||
|
pub fn strip_ansi(&mut self, mode: StripAnsiMode) -> &mut Self {
|
||||||
|
self.config.strip_ansi = mode;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Text wrapping mode (default: do not wrap)
|
/// Text wrapping mode (default: do not wrap)
|
||||||
pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self {
|
pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self {
|
||||||
self.config.wrapping_mode = mode;
|
self.config.wrapping_mode = mode;
|
||||||
|
Reference in New Issue
Block a user