Commit Graph

43 Commits

Author SHA1 Message Date
rhysd 4cc2a489d0 Remove unnecessary heap allocations in `PrettyPrinter::print` for style components 2023-01-15 21:16:36 +09:00
rhysd 3d7817d662 Clear `highlighted_lines` when calling `PrettyPrinter::print` 2022-09-05 21:17:08 +09:00
rhysd abd69f2deb Add `bat::PrettyPrinter::clear_highlights` (fixes #1919) 2022-09-05 17:35:32 +09:00
Martin Nordholts 49875d6ce7
Make `bat::PrettyPrinter::syntaxes()` iterate over new `bat::Syntax` struct (#2222)
We can't keep `syntect::parsing::SyntaxReference` as part of the public
API, because that might prevent us from bumping to syntect 6.0.0 without
also bumping bat to v2.0.0, once we reach v1.0.0.

So introduce a new stripped down struct `Syntax` and return that
instead. Let it be fully owned to make the API simple. It is not going
to be in a hot code path anyway.

I have looked at all code of our 27 dependents but I can't find a single
instance of this method being used, so this change should be safe for
v1.0.0.
2022-09-03 12:33:38 +02:00
acheronfail b1e67e215c Allow configuring show_nonprintable from PrettyPrinter 2022-04-02 21:05:37 +02:00
Martin Nordholts a81009607a HighlightingAssets: Make .syntaxes() and syntax_for_file_name() failable
Or rather, introduce new versions of these methods and deprecate the old ones.

This is preparation to enable robust and user-friendly support for lazy-loading.
With lazy-loading, we don't know if the SyntaxSet is valid until after we try to
use it, so wherever we try to use it, we need to return a Result. See discussion
about panics in #1747.
2021-07-29 08:26:18 +02:00
Martin Nordholts 073b9968c0 pretty_printer.rs: Don't use a URL as an example Input title
Otherwise Rust 1.53.0 gets confused during `cargo doc` because it thinks
we want an actual URL:

    warning: this URL is not a hyperlink
    --> src/pretty_printer.rs:331:40
        |
    331 |     /// The title for the input (e.g. "http://example.com/example.txt")
        |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com/example.txt>`
        |
        = note: `#[warn(rustdoc::bare_urls)]` on by default
        = note: bare URLs are not automatically turned into clickable links

It was perhaps also a bit confusing to give an URL as an example in the
first place, because according to our own API example
`examples/inputs.rs` it is meant to be more a free-text thing.
2021-06-28 07:10:30 +02:00
Mohamed Abdelnour a27814db8e Implement `From<..>` instead of `Into<..>` 2021-05-27 12:05:07 +02:00
Mohamed Abdelnour 9702f5256c Use the functional update syntax 2021-05-27 12:05:07 +02:00
Aleksey Kladov 35347c2310 Improve readability
Using `Path`s for paths expresses intent more clearly.
2021-03-07 14:59:10 +01:00
sharkdp 060b9981b5 Remove deprecated PrettyPrinter methods 2021-01-11 21:36:08 +01:00
sharkdp 09fbabb0b8 Add a Default implementation for PrettyPrinter 2021-01-09 19:43:39 +01:00
MarcoIeni 43b2ee5e71 fix some clippy warnings 2020-11-23 14:25:01 +01:00
Tom Milligan aa4000cb0d
style: add component 'rule' for horizontal file delimiter 2020-10-12 09:04:27 +01:00
Ethan P 342cae2dc6 Change use of 'BatInput' to 'input::Input' 2020-05-29 22:13:10 +02:00
Ethan P a8d7141c4c Improve documentation for Input API 2020-05-29 22:13:10 +02:00
Ethan P 798b742617 Refactor InputDescription API into Input API 2020-05-29 22:13:10 +02:00
Ethan P 2f823d59b0 Add PrettyPrinter::input function 2020-05-29 22:13:10 +02:00
sharkdp 8f1babf346 Mark 'vcs_modification_markers' as deprecated 2020-05-25 11:51:10 +02:00
sharkdp fa25695b74 Make 'vcs_modification_markers' change non-breaking 2020-05-25 11:51:10 +02:00
Ethan P 887e61a99d
Allow application to be built without git support
Caveats:
The help descriptions aren't changed with you remove the "git" feature.
2020-05-15 13:58:48 -07:00
Ethan P 0aca8cab0b
Remove vcs_modification_markers from PrettyPrinter 'git' feature disabled 2020-05-15 13:58:48 -07:00
sharkdp 82e7786e74 Implementation of 'bat --diff'
This adds a new `--diff` option that can be used to only show lines
close to Git changes (added/removed/modified lines). The amount of
additional context can be controlled with `--diff-context=N`.

closes #23
2020-04-24 09:57:57 +02:00
sharkdp 8961f7aef8 Move PagingMode to separate module 2020-04-22 23:55:28 +02:00
sharkdp 17f3a3b95d Simpler highlight method 2020-04-22 23:55:28 +02:00
sharkdp 261a7ea154 Add *_with_name methods 2020-04-22 23:55:28 +02:00
sharkdp 53a973e9dd Add syntaxes and themes method 2020-04-22 23:55:28 +02:00
sharkdp 702cb198da Rename error module 2020-04-22 23:55:28 +02:00
sharkdp 13f671b499 Update examples 2020-04-22 23:55:28 +02:00
sharkdp 6a124591df Easier configuration of style components 2020-04-22 23:55:28 +02:00
sharkdp 36dde9275a Simplify style_components 2020-04-22 23:55:28 +02:00
sharkdp f034be71e7 rename run => print 2020-04-22 23:55:28 +02:00
sharkdp ec0ce05455 Better API for highlighting lines 2020-04-22 23:55:28 +02:00
sharkdp 26c951fec4 Fix warnings, sort imports, input from string 2020-04-22 23:55:28 +02:00
sharkdp 590960f7f5 Completely refactor 'input' module 2020-04-22 23:55:28 +02:00
sharkdp b4d54106fe Fix comment 2020-04-22 23:55:28 +02:00
sharkdp f3b90ddb38 Add InputDescription 2020-04-22 23:55:28 +02:00
sharkdp 3bacfc5184 Allow fluent style 2020-04-22 23:55:28 +02:00
sharkdp f8d0956893 Rename InputFile => Input 2020-04-22 23:55:28 +02:00
sharkdp 1dc328ad49 Separate inputs from config 2020-04-22 23:55:28 +02:00
sharkdp 5e5cb89da6 Add all builder options 2020-04-22 23:55:28 +02:00
sharkdp 057e4eced1 Large refactoring towards a better builder structure 2020-04-22 23:55:28 +02:00
sharkdp 27974616bf Initial verison of PrettyPrinter builder 2020-04-22 23:55:28 +02:00