Commit Graph

931 Commits (9eaed3e3f088d210467727201b0fb2b4e1e8f763)

Author SHA1 Message Date
Martin Nordholts 19c3e82abf
Replace deprecated 'error-chain' with 'thiserror' (#1820)
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.
3 years ago
Martin Nordholts f1c0fd7343
Don't take a HighlightingAssets detour to build assets (#1802)
Move code to build assets to its own file. That results in better modularity and flexibility.

It also allows us to simplify HighlightingAssets a lot, since it will now always
be initialized with a SerializedSyntaxSet.
3 years ago
Bojan Durdevic c86a179412 PR comments addressed for line range +delta syntax 3 years ago
Bojan Durdevic 0748783404 Support for line range plus syntax 3 years ago
Martin Nordholts ba8a694314 Add LANG and LC_ALL to --diagnostics output
To make it easier to debug problems like #1806 in the future.
3 years ago
Martin Nordholts ed09f90e5e Fix all lints that are new with Rust 1.54
They are all of the following type:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
3 years ago
Martin Nordholts f5c1cb2dff Run 'cargo fmt' 3 years ago
Martin Nordholts 25fa577cd0 Make 'build-assets' an optional capability for application
Also structure features a bit more clever to avoid duplication of
feature dependency declarations.
3 years ago
Martin Nordholts deddc81426 src/assets.rs: Use ThemeSet::new() instead of BTreeMap::new() 3 years ago
Bill Risher bf78288e9e feat(config): added recognition of $BAT_CONFIG_DIR 3 years ago
Martin Nordholts 89217e0d58 Make --no-paging and --no-pager work again 3 years ago
Martin Nordholts 905902d811 bin: Allow to build without bugreport 3 years ago
Martin Nordholts d8b813c0bf
When returning a SyntaxReference, also return the SyntaxSet that contains it (#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`.
3 years ago
Martin Nordholts 5236ed135e Fix typo in unreachable!(..) message for --wrap 3 years ago
Martin Nordholts 47d955a2ab Add code for analyzing dependencies between syntaxes
And also to generate independent SyntaxSets. This will later be used
to improve bat startup time.
3 years ago
Martin Nordholts 8ecd23eab4 Make --style docs reflect that 'full' is default
Closes #1742
3 years ago
Martin Nordholts 0331d28ee4 cargo fmt 3 years ago
Martin Nordholts 28eca6a2be Use assert!(..) instead of assert_eq!(true, ..)
This fixes all of these lint warnings:
https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

They only appear in recent versions of clippy. Not on our MSRV.
3 years ago
Keith Hall 3b020fd95a
Merge pull request #1771 from sharkdp/warn_when_missing_contexts
Warn when building assets from files if some referenced contexts are missing
3 years ago
Keith Hall 50e1c6074f Warn when building assets from files if some referenced contexts are missing 3 years ago
Martin Nordholts a610987ef7 assets::tests: Add get_syntax_name() helper
And instead of taking a get_syntax_set() detour to return a
name that represents "no syntax", return such a string directly.
3 years ago
Martin Nordholts ffdf349a96 HighlightingAssets: Encapsulate theme_set behind a getter
Mainly to prepare for potential lazy-loading in the future to
improve startup performance. Like we did for syntax_set.
3 years ago
Martin Nordholts 6acec2c074 Reduce startup time in loop-through mode with 80%-90%
Instead of 100 ms - 50 ms, startup takes 10 ms - 5 ms.

HighlightingAssets::get_syntax_set() is never called when e.g. piping the bat
output to a file (see Config::loop_through), so by loading the SyntaxSet only
when needed, we radically improve startup time when it is not needed.
3 years ago
Martin Nordholts 1bac3750df HighlightingAssets: Move out fn get_integrated_*set() to module scope
They are just a way to get access to data embedded in the binary, so they don't
conceptually belong inside HighlightingAssets.

This has the nice side effect of getting HighlightingAssets::from_cache() and
::from_binary(), that are highly related, next to each other.
3 years ago
Martin Nordholts b040efff79 Support a hidden arg --no-custom-assets that skips loading assets from the cache 3 years ago
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.
3 years ago
Martin Nordholts c0e09662b4 HighlightingAssets::get_extension_syntax(): Split up into smaller methods
To make the code easier to understand and change.
3 years ago
Martin Nordholts ccf4563573 Make loading of cached assets closer in performance to integrated assets
Using BufReader makes sense for large files, but assets are never large enough
to require buffering. It is significantly faster to load the file contents in
one go, so let's do that instead.

Closes #1753
3 years ago
Martin Nordholts f6fc826dc6 HighlightingAssets: Introduce private fn new() helper
It already now reduces code duplication slightly, but will become even more
useful in the future when we add more complicated logic such as lazy-loading.
3 years ago
Martin Nordholts 375d55aa5d HighlightingAssets: Encapsulate syntax_set behind a getter
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.
3 years ago
Martin Nordholts 6ef2bb3283 De-duplicate some themes.bin and syntaxes.bin related code 3 years ago
David Peter 33c11d64f0 Run cargo fmt 3 years ago
David Peter 3fa09dbe2e Use resolved path for --diagnostic as well 3 years ago
David Peter bf2b2df9c9 Fix for Windows: do not run binaries from CWD
This fixes a bug on Windows where `Command::new` would also run
executables from the current working directory, possibly resulting in
accidental runs of programs called `less`.
3 years ago
David Peter 21338ed789 Abort ignored filename suffix stripping early on unworkable filenames 3 years ago
David Peter dc8ab0b5ce Simplify ignored filename suffix stripping 3 years ago
Ville Skyttä 355e62efe9 Find syntax ignoring known backup/template filename suffixes
For example, fall back to `foo.extension` for `foo.extension~`,
`foo.extension.orig`, `foo.extension.in.in` etc.
3 years ago
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.
3 years ago
Ville Skyttä 90e48e9b61 Spelling fixes 3 years ago
Mohamed Abdelnour aa74d19940 Refactor "Use `matches` macro" 3 years ago
Mohamed Abdelnour 425a0f90e9 Use the functional update syntax 3 years ago
Mohamed Abdelnour a27814db8e Implement `From<..>` instead of `Into<..>` 3 years ago
Mohamed Abdelnour 9702f5256c Use the functional update syntax 3 years ago
Mohamed Abdelnour 23fd11e806 Use `matches` macro 3 years ago
Mohamed Abdelnour 304ee1489c Use `!theme.is_empty()` 3 years ago
Allen Wild 91a347bf6d Fix less version parsing for minor versions of less
Less 581.2 is here, and it has a ".2" in the version string, which can't
be parsed as a usize.

Update the check to find a non-digit character rather than a space. This
ignores the minor version, but parses the major version correctly.
3 years ago
Martin Nordholts e04fbd1992 Include LESS in --diagnostic
So issues like #1586 are easier to troubleshoot.
4 years ago
Sean McLoughlin d89fa3ebc2 Add SystemVerilog support 4 years ago
David Peter 2e7f2b6c07 'mut self' => 'self', remove pub 4 years ago
Aleksey Kladov 35347c2310 Improve readability
Using `Path`s for paths expresses intent more clearly.
4 years ago
Niklas Mohrin 694b31909a Change circle detection to use new more conservative method and run in main loop instead of before the loop 4 years ago
David Peter ca60937c2e Do not ignore non-existent BAT_CONFIG_PATH
Do not ignore `BAT_CONFIG_PATH` if it doesn't exist. Both when
generating a new config file with `--generate-config-file` and
when attempting to read the config.

Also, provide a better error message in case the file can not
be created.

closes #1550
4 years ago
David Peter 94496df3b0 Fix broken resolv.conf highlighting
closes #1510

The change in `create_highlighted_versions.py` fixes a "unknown theme
"'1337'" warning. The single quotes were wrong. `bat` was always falling
back to the default theme, so let's use that for now.
4 years ago
David Peter 7eabb5e05a Highlight *.pac files as JavaScript
closes #1515
4 years ago
David Peter 9ad401be87 Fix clippy suggestion 4 years ago
Ethan P f874c8e4db Use less binary specified in bat config for --diagnostic 4 years ago
Ethan P 025c5c061b Make less version check accept a path to the less binary 4 years ago
Caden Haustein 573f34d757
Update dependencies; replace unmaintained (#1522)
* Update dependencies; replace unmaintained

* Fix errors

* Revert dependency changes

* Revert git2 to 0.13.15

Co-authored-by: David Peter <mail@david-peter.de>
4 years ago
Martin Nordholts dc1620d1f0 get_pager(): Simplify use_less_instead expression 4 years ago
Martin Nordholts dd0d44bbb3 Fix #1413 Can't use `bat` at all! (Error: Use of bat as a pager is disallowed...)
Fixed by implementing the proposal by sharkdp:

* Allow PAGER=bat, but ignore the setting in bat and simply default to
  less. Unless of course, BAT_PAGER or --pager is used to overwrite the
  value of PAGER.

* Disallow the usage of bat within BAT_PAGER and --pager.
4 years ago
sharkdp 060b9981b5 Remove deprecated PrettyPrinter methods 4 years ago
sharkdp 1ae16fca90 Improve --map-syntax documentation, see #1386 4 years ago
Martin Nordholts 7809008016 PagerKind::from(): Simplify 4 years ago
Martin Nordholts dd6f57e107 pager.rs: Some comment fixups 4 years ago
Martin Nordholts dfe7a60140 PagerSource: [Bat]PagerEnvVar -> EnvVar[Bat]Pager 4 years ago
Martin Nordholts fc30277cfa pager.rs: Limit visibilities to pub(crate) 4 years ago
Martin Nordholts 02e6ff4183 Merge remote-tracking branch 'origin/master' into fix-1063 4 years ago
sharkdp c5c28eb05b --diagnostic: add MANPAGER environment variable 4 years ago
sharkdp cd7be018fe Fix clippy suggestion: .or_else(|| Some(…)) => .or(Some(…)) 4 years ago
sharkdp 03a2710a08 Use new matches!(…) macro to simplify code 4 years ago
sharkdp 09fbabb0b8 Add a Default implementation for PrettyPrinter 4 years ago
mark chaitin de6cb75f4b Addressed PR feedback. Upped min version and used matches! macro 4 years ago
mark chaitin 83c9cb7907 fix bug where long lines were truncated in plain mode without wrap=never not being set 4 years ago
Csaba Henk fed30b1b36 Fix theme dir hint in --list-themes output 4 years ago
Martin Nordholts da10166625 Merge remote-tracking branch 'origin/master' into fix-1063 4 years ago
sharkdp 26136be903 Add --diagnostics alias 4 years ago
sharkdp 6a52f69b58 Update to bugreport 0.3.0 4 years ago
sharkdp 60406c7c2d Exhaustive list of relevant environment variables 4 years ago
sharkdp dec94b4111 Add config file, compile time info and less version 4 years ago
sharkdp ebb97e94a9 Add --diagnostic option to bat 4 years ago
Martin Nordholts 46487b201f Merge remote-tracking branch 'origin/master' into fix-1063 4 years ago
Niklas Mohrin 21ae26cb17 Add cycle detection with clircle, now v0.2 4 years ago
Martin Nordholts bfa5342331 Also replace 'more' from PAGER with 'less'
But first do some quite significant refactorings to keep the code clean
and easy to understand.
4 years ago
Martin Nordholts 22bdc7c20f When PAGER=most, don't print a warning to stderr, silently use less instead 4 years ago
Martin Nordholts 552545fe5f Merge remote-tracking branch 'origin/master' into fix-1063 4 years ago
Martin Nordholts dcfe883f4b Simplify and polish pager.rs and related code 4 years ago
Martin Nordholts 05e9da390f bat cache --build: Print syntect error message for themes if any
This will fix #614 by making it clear what is wrong by showing the
following error message:

    Failed to load one or more themes from
    '/Users/me/.config/bat/themes' (reason: 'Invalid syntax theme
    settings')

We also need to add a check if theme_dir.exists(), otherwise an absent
dir will seem like an error:

    Failed to load one or more themes from
    '/Users/me/.config/bat/themes' (reason: 'IO error for
    operation on /Users/me/.config/bat/themes: No such file or
    directory (os error 2)')

(This is the same check we already have for syntax_dir.)
4 years ago
Martin Nordholts cc0f8ca813 Merge remote-tracking branch 'origin/master' into fix-1063 4 years ago
Martin Nordholts 9c16571347 bat --list-languages: remove unnecessary format!() call
To trigger/verify the changed code, run

    bat --list-languages   # or -L

This is the last clippy warning in the code that you get if you run

    cargo clippy --all-targets --all-features -- --allow clippy::style

so by fixing it it becomes easier to spot when a new warning is
introduced (that does not belong to the clippy category clippy::style).
And by making it easy to spot new warnings, we increase chance of such
regressions not ending up in the code base.
4 years ago
Martin Nordholts 47bb4a9c0f Introduce bat_warning! helper macro
This macro is intended to be package-internal and is not to be
considered part of the public lib API.

Use it in three places to reduce code duplication. However, main reason
for this refactoring is to allow us to fix #1063 without duplicating the
code yet another time.

The macro can also be used for the "Binary content from {} will not be
printed to the terminal" message if that message starts to use eprintln!
instead (if ever).

To trigger/verify the changed code, the following commands can be used:

    cargo run -- --theme=ansi-light tests/examples/single-line.txt
    cargo run -- --theme=does-not-exist tests/examples/single-line.txt
    cargo run -- --style=grid,rule tests/examples/single-line.txt
4 years ago
Martin Nordholts 6d1c7d5f57 Fix clippy::if_same_then_else warning in --paging=auto logic 4 years ago
Mitchell Kember 3099f51ba7 Add ansi theme to replace ansi-light and ansi-dark
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).
4 years ago
Lovecraftian Horror b349155f2f Remove repeated `contains` calls 4 years ago
Stefan Kunkel bf96e6e642 make bat -L use plain style 4 years ago
Stefan Kunkel cffacad306 make bat -L use pager 4 years ago
David Peter 73c16574e6
Merge branch 'master' into fix-1438-newline-can-be-added-even-if-style-plain 4 years ago
Martin Nordholts 68d525cd8b Don't add artificial newline to last line if --style=plain
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.
4 years ago
Martin Nordholts c3fc1b88fe replace_nonprintable: Keep \n around
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.
4 years ago
rsteube 84b0702399 only print themes hint in interactive mode 4 years ago
Martin Nordholts 986d0e9777 Ignore PAGER=most by default with a warning to stderr
closes #1063
4 years ago
Martin Nordholts f4202361b4 Add Pager helper with info about where the value comes from
In preparation of fixing issue #1063.
This is a pure refactoring with no intended functional side effects.
4 years ago
sharkdp a6810e3353 Revert "Add io cycle detection with clircle"
This reverts commit aa2ae19dfd.
4 years ago
sharkdp 1fbdef06aa Use unreachable!(…) 4 years ago
MarcoIeni f5531cc7fa remove all matches 4 years ago
MarcoIeni 2ccff145ed remove unuseful matches expression 4 years ago
MarcoIeni 43b2ee5e71 fix some clippy warnings 4 years ago
Niklas Mohrin 31793cfa62 Add io cycle detection with clircle 4 years ago
Ethan P 61f947a580
Merge pull request #1276 from tommilligan/style-rule
style: add component 'rule' for horizontal file delimiter
4 years ago
Nicholas L 8e8131590c Use platform based path concatenation 4 years ago
Nicholas L 3acfe790b9 Add extra themes help to output 4 years ago
Adrian Rivera 9837948c3a Throws an error when `bat` is being user as pager.
As mentioned on #1334 `bat` should not be used as a value for `pager`,
this change checks both the balue of `bat` provided as a parameter or
as an environment variable.
4 years ago
Tom Milligan 3015ebfba1
disable rule when grid enabled, and print warning 4 years ago
Tom Milligan aa4000cb0d
style: add component 'rule' for horizontal file delimiter 4 years ago
sharkdp b3903175c8 Auto-format Rust code 4 years ago
gahag 6615eceb18 Code review: replace `if let` with equals operator 4 years ago
gahag 53f5a37f01 Code review
- Replace bools with enums
- Replace short flag with long flag
4 years ago
gahag bbef2f41ec Add `-S` flag to less when `--wrap=never` (closes #1255)
Prevent less from wrapping lines by setting the proper flag when `--wrap=never`.
If the user set a custom value for `--pager`, no additional flag is set.
4 years ago
henil 8ff890635f add an after help NOTE 4 years ago
sharkdp 30993a8bfc Simplify code 4 years ago
sharkdp 2258fb2713 Remove .unwrap() in insert call to prevent crashes 4 years ago
sharkdp a46191b8bf Remove .unwrap() to prevent crashes 4 years ago
sharkdp 9c4c3e965b Remove non-working unit test 4 years ago
Ahmed El Gabri 31acbe20d3 Support XDG_CONFIG_HOME git config files 4 years ago
sharkdp 32d22f464d Improve --style help text, closes #1146 4 years ago
sharkdp 71b2089384 Code formatting 4 years ago
sharkdp 57aa88a13a Improve --file-name help text, closes #1109 4 years ago
sharkdp f84aceec3d Fix unwrap error 4 years ago
Kienyew 83c7750656 Use unwrap 4 years ago
Kienyew c477e23fe9 Handle file extension conflicts in --list-languages 4 years ago
Kienyew 31fb7087f1 Revert to previous commit 4 years ago
Kienyew 52d6701f8f Fix undesired behavior 4 years ago
Kienyew f97634011e Handle file extension conflicts in --list-languages (#1076) 4 years ago
sharkdp 5df449bcf3 Remove unnecessary parenthesis 4 years ago
Alexander Karlis 6017989c4c removed printlns, updated Changelog, updated man 4 years ago
Alexander Karlis d349974089 updated PR based on comments 4 years ago
Alexander Karlis ccdea6a429 remove println 4 years ago
Alexander Karlis fdf11326ef added additional alias for color=always when always-decorations flag is triggered 4 years ago
Alexander Karlis 565a80305c Added new alias for 'decoration=always' 4 years ago
Niklas Mohrin ad18f070ae Adds custom mapping for nginx and apache config files 4 years ago
Kienyew cab5ddf6ae Fix Typo 4 years ago
Mitchell Kember f9d5e81f0e Add new theme: base16-256
Bat already has a base16 theme. The new base16-256 theme is for users
of base16-shell, who configure their terminal with a 256-color variant
of a base16 theme. These variants put some of the base16 colors in
elsewhere in the 256-color table to avoid clobbering bright color slots
(ansi codes 8 to 15) with colors that don't respect the ordinary meaning
of that slot (e.g. bright green in ordinary base16 is not green).

For more details, see https://github.com/chriskempson/base16-shell
4 years ago
sharkdp 2b3457e8d6 Update --help text for --color 4 years ago
Dash Peters 99819087f1 Switch to "·" (U+00B7) Middle Dot from "•" (U+2022) Bullet 4 years ago
Attila Gonda a0b89a68d9 Update generated config to reflect pager argument behaviour 4 years ago
Dash Peters c264f74771 Hide alias in help, update man and completions
A long alias doesn't make sense, since `--paging=never` already exists
4 years ago
Dash Peters f53ea60ed4 Merge remote-tracking branch 'sharkdp/master' 4 years ago
David Peter 3a62e3d188
Merge pull request #1066 from gsomix/feature/1061-show-all-redirected
Enable non-printable characters for redirected output
4 years ago
Evgeniy Andreev (gsomix) 3c5ce9f86c Enable non-printable chars for redirected output (#1061) 4 years ago
Dash Peters 5fdeeabb44 Change to name no-paging, add long flag and alias 4 years ago
Dash Peters 2575aae945 Add short flag for --paging=never 4 years ago
Caio Alonso fc121f0c87 Defaults *.fs to F# 4 years ago
Guido Cella 44deddbbfe Highlight pacman hooks as ini 4 years ago
Guido Cella aa8a2b1769 Highlight systemd files as ini 4 years ago
sharkdp 19aa878a08 Remove explicit type annotation 4 years ago
sharkdp 9f52012443 Prevent allocation of additional Strings 4 years ago
sharkdp e57e9b6dbb Use 'or_insert_with' 4 years ago
sharkdp 74e8373e34 Return mappings as a slice 4 years ago
sharkdp ec2722d465 Use 'if let' instead of 'match' 4 years ago
Alex Novak 9e2ea5fdd4 Incorporating feedback 4 years ago
Alex Novak 48b4a6a906 Adds a little logic to main to get other mappings from config 4 years ago
Roy Ivy III 99226b745f Revert 9ed8db22c ('windows' pager process execution fix) based on PR feedback/owner request 4 years ago
Roy Ivy III a2c09b41bc Fix pager process execution under 'windows'
## [why]

For 'windows' platforms, directly spawning a process (eg, called PATHNAME) bypasses the
usual windows shell machinery for determining which process to execute. Specifically,
the extensions in PATHEXT will not be used to determine the final executable. So,
`PATHNAME.bat`, `PATHNAME.cmd`, ... will *not* be executed even if on they exist on the
PATH; and this is counter to the usual expectation of a Windows user. Additionally,
built-in commands, such as `echo` and `dir`, will never be accessible as they do not
have a PATH to execute and, so, will never be found.

To use the usual machinery, giving access to PATHNAME.bat and `echo`, execute the PATHNAME
using the windows shell, eg `cmd /d/c PATHNAME`. Note this may expose the constructed
command line to the windows shell quoting vagaries (sadly, that may be part of the price).

Following Windows standards, the ComSpec environment variable is used to determine which
shell to use, with a fallback to the "modern", built-in `cmd` shell.
4 years ago
Roy Ivy III 9cc8e52512 Fix compiler warning for 'windows' tests (dead_code) 4 years ago
Ethan P 342cae2dc6 Change use of 'BatInput' to 'input::Input' 4 years ago
Ethan P d2b26a5f1f Remove unnecessary '-> ()'s 4 years ago
Ethan P 9d08c0102e Replace Input::stdin_as_file with bat-application functions 4 years ago
Ethan P a3357547ea Remove unused with_name for theme preview file 4 years ago
Ethan P 7a9decad70 Remove Input.as_file and add Input::stdin_as_file 4 years ago
Ethan P a8d7141c4c Improve documentation for Input API 4 years ago
Ethan P 0f06d3b90d Reexport bat::pretty_printer::Input as bat::Input 4 years ago
Ethan P 589c94aa93 Fix regression with --list-themes and --language 4 years ago
Ethan P 798b742617 Refactor InputDescription API into Input API 4 years ago
Ethan P 11a72ab765 Fix a typo 4 years ago
Ethan P 0319149b4d [breaking] Remove special handling for theme previews 4 years ago
Ethan P 2f823d59b0 Add PrettyPrinter::input function 4 years ago
Ethan P 981352992b Add InputDescription API 4 years ago
Ethan P 384ea38bd9 Add documentation to InputDescription 4 years ago
Ethan P 8b481dd41f Add support for NO_COLOR env var (#1021) 4 years ago
sharkdp 9cb43ef64d Update tests 4 years ago
sharkdp bd17fd571f Switch from path-absolutize to path_abs
closes #1022
4 years ago
sharkdp 8f1babf346 Mark 'vcs_modification_markers' as deprecated 4 years ago
sharkdp fa25695b74 Make 'vcs_modification_markers' change non-breaking 4 years ago
sharkdp 943b1f82b6 Fix syntax detection for symlinks
closes #1001
4 years ago
sharkdp c4031ad65c Fix syntax detection for files called 'rails'
closes #1008
4 years ago
Ethan P 35b6067496 Print error message when invalid syntax is specified 4 years ago
Ethan P 5aa20c090b Refactor HighlightingAssets::get_syntax to return Result type 4 years ago
Ethan P 887e61a99d
Allow application to be built without git support
Caveats:
The help descriptions aren't changed with you remove the "git" feature.
4 years ago
Ethan P 0aca8cab0b
Remove vcs_modification_markers from PrettyPrinter 'git' feature disabled 4 years ago
Ethan P b8687bc969
Merge branch 'master' of github.com:sharkdp/bat into string-input 4 years ago
Ethan P cc52f79e42
Add helper fn for checking if opened input is theme preview file 4 years ago
Ethan P 59140b458c
Consolidate syntax detection behavior for all InputKind types 4 years ago
Ethan P 157b8dd848
Rename test for checking if inputkinds are consistent 4 years ago
Ethan P 1fb669ae1a
Test that OrdinaryFile consistent with CustomReader 4 years ago
Ethan P 7d07aa395a
Change assets.rs tests to use InputKind::CustomReader
This should avoid errors in filesystems that don't
support UTF-8 or invalid UTF-8.
4 years ago
Prat T b3373398e8 Remove padding if the header style is not enabled 4 years ago
Prat T 0040fef215 Add padding above headers when no grid 4 years ago
Ethan P f39487fca9
Make syntax detection more consistent for Reader and File inputs 4 years ago
Mitchell Kember f59d00d4c7 Fix base16, and combine 00 and 0f alpha encodings
This changes the base16 theme back from #RRGGBB0f to #RRGGBB00,
reverting part of #934. That PR used the 0f encoding to produce ANSI
escape sequences 30-37 and 40-47 rather than 38;5 and 48;5 which require
256-color support. Unfortunately, it resulted in base16 using the wrong
colors becuase ansi_term does not support the bright variants (90-97 and
100-107) so it simply mapped them to the non-bright colors.

This PR makes combines the 00 and 0f alpha encodings into 00, and makes
them use the Color enum for the first 8 colors and Fixed otherwise. This
means the ansi-light and ansi-dark themes will work on terminals without
256-color support, and base16 will render bright colors correctly.
4 years ago
sharkdp 48a7ce3bf2 Write error messages to pager, if attached
closes #946
4 years ago
sharkdp 5fe8a8342b Add annotations again 4 years ago
sharkdp 989109145a Add '-d' for '--diff' 4 years ago
sharkdp 23afc8e90c Skip non-file inputs when using --diff 4 years ago
sharkdp 8e18786556 Run 'cargo fmt' 4 years ago
sharkdp 81488adf8b Use unreachable!(…) 4 years ago
Lzu Tao e37e9c1214 Fix some clippy lints
Some might actually improve perf
4 years ago
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
4 years ago
sharkdp 0064321323 cargo fmt 5 years ago
sharkdp 793af6b911 Add a syntax mapping for bats own config file 5 years ago
sharkdp 5d71056209 Fix import in app 5 years ago
sharkdp eb7d4d002a Update documentation 5 years ago
sharkdp 62b32bd848 Make module private 5 years ago
sharkdp 8961f7aef8 Move PagingMode to separate module 5 years ago
sharkdp 17f3a3b95d Simpler highlight method 5 years ago
sharkdp 261a7ea154 Add *_with_name methods 5 years ago
sharkdp 53a973e9dd Add syntaxes and themes method 5 years ago
sharkdp cba9df746e Add paging to advanced example 5 years ago
sharkdp 12eee0c590 Fix warnings for --no-default-features mode 5 years ago
sharkdp 702cb198da Rename error module 5 years ago
sharkdp 13f671b499 Update examples 5 years ago
sharkdp 49f4322054 Fix example 5 years ago
sharkdp 6a124591df Easier configuration of style components 5 years ago
sharkdp 7a87315b94 Fix #937 5 years ago
sharkdp 0cde4e9121 Numbers => LineNumbers 5 years ago
sharkdp 36dde9275a Simplify style_components 5 years ago
sharkdp a8f759c080 Rename wrap => wrapping 5 years ago
sharkdp f034be71e7 rename run => print 5 years ago
sharkdp eee35e54e9 Update documentation 5 years ago
sharkdp ec0ce05455 Better API for highlighting lines 5 years ago
sharkdp 13e6b3fac7 Reduce public API 5 years ago
sharkdp 26c951fec4 Fix warnings, sort imports, input from string 5 years ago
sharkdp 590960f7f5 Completely refactor 'input' module 5 years ago
sharkdp b4d54106fe Fix comment 5 years ago
sharkdp f3b90ddb38 Add InputDescription 5 years ago
sharkdp 3bacfc5184 Allow fluent style 5 years ago
sharkdp f8d0956893 Rename InputFile => Input 5 years ago
sharkdp 1dc328ad49 Separate inputs from config 5 years ago
sharkdp 5e5cb89da6 Add all builder options 5 years ago
sharkdp 057e4eced1 Large refactoring towards a better builder structure 5 years ago
sharkdp 27974616bf Initial verison of PrettyPrinter builder 5 years ago
sharkdp 319ab779ee Use 4-bit ANSI codes for base16 theme
closes #865
5 years ago
sharkdp 864656bd11 Pass --no-init on Windows if less version < 559
We used to call `less` with
``` bash
less --RAW-CONTROL-CHARS --quit-if-one-screen --no-init
```
We only passed `--no-init` because there was a bug with previous versions
of `less` which required the use of `--no-init` in combination with
`--quit-if-one-screen` to prevent this "no output" issue from happening.

Since bat 0.13, [we omit the `--no-init` option](0ecc94956b/src/output.rs (L85-L97))
if we can detect that the version of `less` is higher than or equal to 530. We
did that because `--no-init` breaks mouse support and because [less 530 fixed
the above-mentioned bug](http://www.greenwoodsoftware.com/less/news.530.html).
However, it seems that this bug was *not* fixed on Windows!

According to @gwsw, the issue should be fixed with less 559 on Windows.

closes #887
5 years ago
sharkdp 2e9cf63a5f Fix compilation of library 5 years ago
sharkdp 72618db179 Add metadata information to cached assets
When saving/reading user-provided syntaxes or themes, `bat` will now maintain a
`metadata.yaml` file which includes information about the `bat` version which was
used to create the cached files. When loading cached files, we now print an error
if they have been created with an incompatible version

closes #882
5 years ago
sharkdp c8273369cc Make get_cache_dir private 5 years ago
sharkdp 859ff50766 Update default config file, add comment about tmux mouse scrolling support 5 years ago
sharkdp ce583eb9bf Revert "Pass '--mouse' to less versions >= 551"
This reverts commit cb21b74ecd.
5 years ago
sharkdp 3a195be14e Revert "Only enable --mouse when running from tmux, see #904"
This reverts commit 5f6e310152.
5 years ago
sharkdp 5f6e310152 Only enable --mouse when running from tmux, see #904 5 years ago
sharkdp 82e20bfe14 Fix bug for file with invalid-utf8 filenames 5 years ago
sharkdp c386cb35fb Pass '--mouse' to less versions >= 551
When using `less` version 551 or newer, `bat` will now pass the `--mouse` argument, allowing
for (better) mouse scrolling support in some terminals.

closes #904
5 years ago
sharkdp a6d9d1551f Improve error message 5 years ago
sharkdp 34619a2e89 Small refactoring, handle invalid UTF-8 filenames 5 years ago
Kyle Criddle 83d408bab3 Extract common syntax functionality to helper fns 5 years ago
sharkdp 8067fd9eda Fix build on 1.37 5 years ago
sharkdp 98ba9e0101 Use to_string_lossy 5 years ago
sharkdp 1b8ce60054 Pass stdin as a generic BufRead, fix stdin tests 5 years ago
sharkdp d5a31dc2ec Remove commented-out code 5 years ago
sharkdp 051dd4ba87 Make filename method private 5 years ago
sharkdp 2ad1848859 Do not take optional as argument 5 years ago
sharkdp 90e7d2fe33 Rename field name, new constructors 5 years ago
Kyle Criddle 04fa84aea7 Moved user_provided_filename to be contained within OrdinaryFile struct 5 years ago
Kyle Criddle a3f8140fbe Use --file-name to detect syntax highlighting
Closes #891
5 years ago
sharkdp 495fab24a5 cargo fmt 5 years ago
David Tolnay 42e3825daf Updates for review of PR 899 5 years ago
David Tolnay 014d754588 Move paging support behind a feature 5 years ago
David Tolnay 4e11abdf9b Move git changes support behind a feature 5 years ago
David Tolnay 570805bc98 Strip dependencies of bat-as-a-library 5 years ago
sharkdp 3e8d444c78 Fix for Rust 1.37 5 years ago
David Peter 37b3b8730d
Merge pull request #871 from neuronull/fix_654_stdin_filename
Implement --file-name<name> option
5 years ago
Josh Mickley 40a827ebcb Graceful handling of error conditions 5 years ago
Josh Mickley 376c556862 Add option to generate a default config file, fixes #870 5 years ago
Kyle Criddle 83772bd2cf Minor --file-name code hygeine 5 years ago
Kyle Criddle 131d113ff5 Merge branch 'fix_654_stdin_filename' of github.com:neuronull/bat into fix_654_stdin_filename 5 years ago
Kyle Criddle 38178fedf4 Merge branch 'master' into fix_654_stdin_filename 5 years ago
Kyle Criddle 59f2e2d58d Implemented --file-name for multiple files + tests 5 years ago
Kyle Criddle fb3c775c8b --file-name for normal files. integration tests. 5 years ago
Kyle Criddle 8adce9fae8 Implement --file-name<name> option
- can specify filename to be displayed when printing.
- useful for when piping data from STDIN

Closes #654
5 years ago
sharkdp eb2f3ddb7c Rename test methods 5 years ago
sharkdp dfd3ef022e Add more default mappings, reverse traversal 5 years ago
sharkdp 978def2d40 Update documentation 5 years ago
sharkdp 57aed07814 Use absolute path for lookup in database 5 years ago
sharkdp bd8a13dbc9 Initial implementation of glob-based syntax mapping 5 years ago
sharkdp 32346612b7 Move syntaxes, fixes #874 5 years ago
sharkdp dfe5eb3e98 Add an even simple example 5 years ago
sharkdp 2c2861db6a Further simplify module structure 5 years ago
sharkdp bb0a3d586e Simplify public API module structure 5 years ago
sharkdp 90397a8aac Hide SyntaxMapping::replace 5 years ago
sharkdp 84ba323b1c Rename output component to 'style compinent', move wrap to separate module 5 years ago
sharkdp a8851e1307 Hide methods from line_range 5 years ago
sharkdp d4a39f99d2 Hide API of InputFileReader 5 years ago
sharkdp 8c500a7e40 Hide get_syntax, move tests to module 5 years ago
sharkdp acf51bd7b3 Rename methods and parameters 5 years ago
sharkdp 83dc13a86d Add fallback theme, remove BAT_THEME_DEFAULT 5 years ago
sharkdp 094c526a0e Hide some methods from HighlightingAssets 5 years ago
sharkdp 62f2d0c100 Do not export syntax_set and theme_set 5 years ago
sharkdp fc1ca0875a Move error handling to a callback 5 years ago
sharkdp a7338e2ea2 Run cargo fmt 5 years ago
sharkdp 9b8ddb24d1 move Config struct to separate file 5 years ago
sharkdp 7e0115641d Move error module to separate file 5 years ago
sharkdp fedd32173e Restructure and fix bug in line range module 5 years ago