summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracheronfail <acheronfail@gmail.com>2022-04-01 20:24:33 +1030
committerDavid Peter <sharkdp@users.noreply.github.com>2022-04-02 21:05:37 +0200
commitb1e67e215c385f926b997e7ef03a674195a52fd0 (patch)
tree9c2ba1c6d122a1ec03a454bce07ccf9f4b283eca
parent49317adcd36d68bfb66b0605d06f31e0742dd77c (diff)
Allow configuring show_nonprintable from PrettyPrinter
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/pretty_printer.rs6
2 files changed, 7 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34d6c377..c60ea4f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@
## `bat` as a library
+- Allow crates using `bat` as a library to configure `show_nonprintable` with `PrettyPrinter`, see #2142
# v0.20.0
diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs
index d537b890..57097a6f 100644
--- a/src/pretty_printer.rs
+++ b/src/pretty_printer.rs
@@ -164,6 +164,12 @@ impl<'a> PrettyPrinter<'a> {
self
}
+ /// Whether to print binary content or nonprintable characters (default: no)
+ pub fn show_nonprintable(&mut self, yes: bool) -> &mut Self {
+ self.config.show_nonprintable = yes;
+ self
+ }
+
/// Whether to show "snip" markers between visible line ranges (default: no)
pub fn snip(&mut self, yes: bool) -> &mut Self {
self.active_style_components.snip = yes;