Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
Co-authored-by: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com>
|
|
Co-authored-by: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com>
|
|
|
|
This simplifies the `print_line` function a little bit while also
providing a way for syntax highlighting to be skipped when it's
not being used (i.e. `--color=never`).
|
|
|
|
This uses the new EscapeSequenceIterator, saving us a preprocessing step
for each line.
|
|
This commit strips OSC (Operating System Command) sequences before
printing lines. Eventually when time permits, I want to add back
support for printing OSC sequences (and improve it to treat hyperlinks
like an attribute).
Until then, this should help prevent garbled output :)
|
|
|
|
|
|
|
|
|
|
feat: Optionally write to a buffer instead of stdout
|
|
|
|
|
|
|
|
|
|
|
|
The `nu-ansi-term` crate is a fork of `ansi_term` which is maintained by
the Nushell project.
|
|
Fix clippy warnings with Rust 1.68
|
|
When the new flag is set, non-printable characters are printed using caret notation.
|
|
|
|
This reverts commit 8174e022797924aec735ff440806920767f80496. Turns out
it is needed for a common use case, see
https://github.com/sharkdp/bat/issues/2307.
It is not a clean revert, because I adjust CHANGELOG.md and also add a
comment to the test. I also had to resolve a small `use` conflict.
|
|
* Strip BOM from output in interactive mode
* Strip BOM when not loop_through, add regression tests
* Update CHANGELOG.md
* Only strip BOM from beginning of first line
* Fix integration test on macOS that relied on color scheme
* Fix integration test on Windows that relied on detected terminal width
* Fix syntax test that was failing due to a previously wrong (now fixed) highlighting
Co-authored-by: David Peter <mail@david-peter.de>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
|
|
Syntax highlighting is broken when input contains ANSI escape characters
anyway, so there is not much point in trying to handle ANSI escapes in
input.
|
|
* Bump to syntect 5.0.0 to e.g. start lazy-loading themes
Closes #915
Closes #951
Closes #1846
Closes #1854
* Typo fix formated -> formatted
* Update CHANGELOG.md
|
|
We do this to only have one invocation of `highlighter.highlight(...)`
so we don't need to change to `highlighter.highlight_line(...)` in two
places in #2181.
|
|
* Skip highlighting for long lines
* Run cargo fmt, update changelog
|
|
* Underline highlighted lines in ANSI theme
* add test for ansi highlight underline, fix underscore in plain
|
|
Also rename `header` to `header-filename`.
Related to #1701
|
|
Improve handling of ANSI passthrough. Fix ANSI passthrough for --wrap=never. Add test for ANSI passthrough.
|
|
By forwarding the task to find the `Plain Text` syntax to `assets`. Not only does
the code become simpler; we also get rid of a call to `self.get_syntax_set()`
which is beneficial to the long term goal of replacing `syntaxes.bin` with
`minimal_syntaxes.bin`.
Note that the use of `.expect()` is not a regression in error handling. It was
previously hidden in `.find_syntax_plain_text()`.
|
|
The main benefit is that we get rid of a call to `assets.get_syntax_set()`,
which in turn makes it easier to later get rid of `syntaxes.bin`.
|
|
|
|
|
|
|
|
We can't use #[from] on Error::Msg(String) because String does not implement Error.
(Which it shouldn't; see e.g. https://internals.rust-lang.org/t/impl-error-for-string/8881.)
So we implement From manually for Error::Msg, since our current code was written
in that way for error-chain.
|
|
They are all of the following type:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
|
|
(#1776)
To improve startup performance, we will later load smaller `SyntaxSet`s instead
of one giant one. However, the current API assumes only one `SyntaxSet` is ever used,
and that that implicitly is the `SyntaxSet` from which returned `SyntaxReference`s
comes.
This change changes the API to reflect that `SyntaxSet` and `SyntaxReference`
are tightly coupled, and enables the use of several `SyntaxSet`.
|
|
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.
|
|
Since we only modify `pub(crate)` items, the stable bat-as-a-library API is not
affected.
This takes us one step closer to making SyntaxSet lazy-loaded, which in turn
takes us one step closer to solving #951.
|
|
|
|
|
|
being set
|
|
This combines ansi-light and ansi-dark into a single theme that works
with both light and dark backgrounds. Instead of specifying white/black,
the ansi theme uses the terminal's default foreground/background color
by setting alpha=01, i.e. #00000001. This is in addition to the alpha=00
encoding where red contains an ANSI color palette number.
Now, `--theme ansi-light` and `--theme ansi-dark` will print a
deprecation notice and use ansi instead (unless the user has a custom
theme named ansi-light or ansi-dark, which would take precedence).
|
|
This fixes #1438.
Note however, that using a pager such as less will add a newline itself.
So to actually not print a newline for such files, you need to either
disable paging:
bat --style=plain --paging=never no-newline-at-end-of-file.txt
or use a "pager" that does not add a newline:
bat --style=plain --pager=cat no-newline-at-end-of-file.txt
Note that we also update syntax tests file since a bunch of them had
missing newlines on the last lines.
|
|
Since it has a functional role, we can not just replace it, we must keep
it around. This also allows us to simplify the code slightly.
We must fix this before we fix #1438 since otherwise the \n will be
missing with --style=plain, since we will stop adding it if it is
missing.
|