1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-05-08 02:15:10 +01:00

Compare commits

...

133 Commits

Author SHA1 Message Date
David Peter
b7f9662097
Update README.md 2025-05-05 08:46:01 +02:00
Keith Hall
79ecb11ce2
Add new sponsor Graphite to Readme ()
* Add new sponsor Graphite to Readme

* hide bullet points in sponsors section of readme

* remove bullet points
2025-05-05 08:44:24 +02:00
Integral
4e9bb610b3 docs(README): fix broken link of Visual C++ Redistributable 2025-05-01 13:33:43 +02:00
dependabot[bot]
c88faf8cfa
Bump assets/themes/zenburn from 9c588eb to 4f21745 ()
Bumps [assets/themes/zenburn](https://github.com/colinta/zenburn) from `9c588eb` to `4f21745`.
- [Commits](9c588ebc11...4f21745723)

---
updated-dependencies:
- dependency-name: assets/themes/zenburn
  dependency-version: 4f217457230ff5f31d594b0e20474b69294988d4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-01 03:10:48 +00:00
Keith Hall
0b48eab7a6
Merge pull request from forkeith/livescript_fix
remove LiveScript submodule
2025-04-30 22:42:30 +03:00
Keith Hall
ccfbd1ee31 remove LiveScript submodule
the repo has gone away, causing all our CI etc. to break

we can keep the highlighting though because we have a .sublime-syntax file
2025-04-30 22:32:48 +03:00
Keith Hall
98c9a5d948
Merge pull request from gthb/patch-1
Fix copy-paste mistake in bat.1.in
2025-04-15 21:55:35 +03:00
Keith Hall
96ea42e5f4
Merge branch 'master' into patch-1 2025-04-15 21:25:32 +03:00
Keith Hall
2ff2a818ef
Merge pull request from ajesipow/read-from-tail
Support relative negative line ranges
2025-04-15 21:16:39 +03:00
Keith Hall
dd694c266e
Merge branch 'master' into patch-1 2025-04-15 21:00:19 +03:00
Keith Hall
c4461f7d78
Merge branch 'master' into read-from-tail 2025-04-15 20:59:51 +03:00
Keith Hall
77de5160ac
Merge pull request from sharkdp/fix_ci
use latest Ubuntu for CI jobs now that GitHub deprecated 20.04
2025-04-15 20:59:14 +03:00
Keith Hall
b9fcc5ae2d use latest Ubuntu for CI jobs now that GitHub deprecated 20.04 2025-04-15 20:30:56 +03:00
Keith Hall
e42883bf2c Merge branch 'master' into read-from-tail 2025-04-15 20:27:26 +03:00
Keith Hall
5c41a45931
Merge branch 'master' into patch-1 2025-04-15 20:09:50 +03:00
dependabot[bot]
ba49ba0acd
Bump assets/themes/zenburn from 86d4ee7 to 9c588eb ()
Bumps [assets/themes/zenburn](https://github.com/colinta/zenburn) from `86d4ee7` to `9c588eb`.
- [Commits](86d4ee7a1f...9c588ebc11)

---
updated-dependencies:
- dependency-name: assets/themes/zenburn
  dependency-version: 9c588ebc11c3e6487b081bd54528af08baa8a09a
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-13 10:36:54 +00:00
dependabot[bot]
5d75632c8e
Bump assets/syntaxes/02_Extra/PowerShell from c0372a1 to a08b55b ()
Bumps [assets/syntaxes/02_Extra/PowerShell](https://github.com/PowerShell/EditorSyntax) from `c0372a1` to `a08b55b`.
- [Commits](c0372a1d2d...a08b55bf11)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/PowerShell
  dependency-version: a08b55bf1146c210f58e844be53c2aa78fd5e610
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-13 10:14:09 +00:00
dependabot[bot]
e202a33ea1
Bump assets/syntaxes/02_Extra/Apache from 163bc03 to cf6cefc ()
Bumps [assets/syntaxes/02_Extra/Apache](https://github.com/colinta/ApacheConf.tmLanguage) from `163bc03` to `cf6cefc`.
- [Commits](163bc03ae8...cf6cefc51e)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Apache
  dependency-version: cf6cefc51ebb46b1b54906433edbae0fe9c71cad
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-13 09:50:51 +00:00
Keith Hall
93be82ebc9
Merge pull request from chetanjangir0/add-gdscript-support
Add GDScript Syntax Support ()
2025-04-13 12:31:26 +03:00
Chetan Jangir
0bf4753ff1
Update CHANGELOG.md
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
2025-04-13 14:51:53 +05:30
Chetan Jangir
fbb07a1494
Merge branch 'master' into add-gdscript-support 2025-04-13 10:00:58 +05:30
Keith Hall
debb66f8b0
Merge pull request from AdamGaskins/bash-zsh
Fix syntax highlighting for bash/zsh
2025-04-12 18:21:01 +03:00
Adam Gaskins
45185b36fb
Merge branch 'master' into bash-zsh 2025-04-12 11:09:33 -04:00
Adam Gaskins
e761d79512
Update CHANGELOG.md
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
2025-04-12 11:08:57 -04:00
chetanjangir0
14064dd987 regenerated the highlighted file 2025-04-12 19:14:15 +05:30
chetanjangir0
3eef8590f4 genereated highlighted syntax test file 2025-04-12 18:00:43 +05:30
chetanjangir0
3e7ad18fe3 fixed merge conflicts 2025-04-12 17:22:18 +05:30
Keith Hall
80a38590b8
Merge pull request from HSM95/fix/multibyte-chars
Fix for multibyte characters in file path
2025-04-12 11:30:28 +03:00
Keith Hall
44a6e29da7
Merge branch 'master' into fix/multibyte-chars 2025-04-12 11:20:48 +03:00
Gunnlaugur Thor Briem
a6e847e267
Fix copy-paste mistake in bat.1.in
The `--theme-light` documentation says “dark” in two places where it should say “light” (presumably copy-pasted from the `--theme-dark` documentation)
2025-04-10 10:56:19 +00:00
Martin Nordholts
2f70906665 Cargo.toml: Document that MSRV can be bumped if there is a reason for it
To the best of my knowledge our current MSRV rule is that we can bump
MSRV whenever there is a reason for it. Let's document it.
2025-04-08 05:00:00 +02:00
Adam Gaskins
c4c919aa31 Update CHANGELOG.md 2025-04-07 17:43:56 -04:00
Adam Gaskins
51491c3c08 Fix syntax highlighting for bash/zsh 2025-04-07 17:43:56 -04:00
Martin Nordholts
ea17f6ad28 Make mention (@ in front of name) in CHANGELOG entry optional 2025-04-07 17:31:12 +02:00
Martin Nordholts
3691c9945a CICD: Stop building for x86_64-pc-windows-gnu which fails
Let's not build for platforms that are broken. If someone fixes the
build we can of course add it back.
2025-04-07 17:31:12 +02:00
Keith Hall
57629bcaca
Merge pull request from einfachIrgendwer0815/feature/page_list_themes
Add paging to `--list-themes`
2025-04-05 09:08:35 +03:00
HSM95
b38ee77628
Merge branch 'master' into fix/multibyte-chars 2025-04-03 00:49:55 -07:00
Haris Mohamedy
b5413cc015 Do not split into graphemes if not necessary 2025-04-03 00:49:14 -07:00
einfachIrgendwer0815
5edaa96164 Update CHANGELOG 2025-04-02 11:27:37 +02:00
einfachIrgendwer0815
12a2a451b4 Add paging to --list-themes 2025-04-02 11:27:37 +02:00
Keith Hall
fc7dff50b0
Merge pull request from dan-hipschman/fix-syntax-test-compare-script
Make highlight tests fail when new syntaxes don't have fixtures
2025-04-02 05:21:30 +03:00
Dan Hipschman
9272e09058 Make highlight tests fail when new syntaxes don't have fixtures 2025-04-01 13:08:19 -07:00
dependabot[bot]
b13c4d5f8d
Bump indexmap from 2.7.0 to 2.8.0 ()
Bumps [indexmap](https://github.com/indexmap-rs/indexmap) from 2.7.0 to 2.8.0.
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/main/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.7.0...2.8.0)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-version: 2.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 03:39:30 +00:00
dependabot[bot]
d7b10b4352
Bump etcetera from 0.8.0 to 0.10.0 ()
Bumps [etcetera](https://github.com/lunacookies/etcetera) from 0.8.0 to 0.10.0.
- [Release notes](https://github.com/lunacookies/etcetera/releases)
- [Commits](https://github.com/lunacookies/etcetera/compare/v0.8.0...v0.10.0)

---
updated-dependencies:
- dependency-name: etcetera
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 03:11:49 +00:00
dependabot[bot]
05cddff72d
Bump anyhow from 1.0.95 to 1.0.97 ()
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.95 to 1.0.97.
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.95...1.0.97)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-version: 1.0.97
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 02:44:03 +00:00
Haris Mohamedy
a55d23aaa4 Add PR to CHANGELOG 2025-03-31 17:50:23 -07:00
Haris Mohamedy
18b71743c8 Fix for multibyte characters in file path 2025-03-31 17:29:18 -07:00
dependabot[bot]
f761ff6824
Bump assets/syntaxes/02_Extra/Org_mode from 4976d8f to bb6e5d8 ()
Bumps [assets/syntaxes/02_Extra/Org_mode](https://github.com/jezcope/Org.tmbundle) from `4976d8f` to `bb6e5d8`.
- [Release notes](https://github.com/jezcope/Org.tmbundle/releases)
- [Commits](4976d8f84e...bb6e5d8481)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Org_mode
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-29 06:55:24 +00:00
dependabot[bot]
8e2d233445
Bump assets/syntaxes/02_Extra/Zig from 1a4a384 to 8a4a3fe ()
Bumps [assets/syntaxes/02_Extra/Zig](https://github.com/ziglang/sublime-zig-language) from `1a4a384` to `8a4a3fe`.
- [Release notes](https://github.com/ziglang/sublime-zig-language/releases)
- [Commits](1a4a38445f...8a4a3fe4a0)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Zig
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-29 06:41:10 +00:00
Keith Hall
59b1f362f6
Merge pull request from chetanjangir0/add-odin-syntax
Add Odin Language Syntax Support
2025-03-29 08:23:52 +02:00
Chetan Jangir
a73c641a0f
Update CHANGELOG.md
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
2025-03-29 11:43:36 +05:30
Chetan Jangir
3d4c72da0b
Merge branch 'master' into add-gdscript-support 2025-03-29 09:44:48 +05:30
Chetan Jangir
71547b3fb3
Merge branch 'master' into add-odin-syntax 2025-03-29 09:44:11 +05:30
Keith Hall
ad8da94d2a
Merge pull request from simono/patch-2
Use built-in detection for OS theme in Readme
2025-03-29 05:27:11 +02:00
Simon Olofsson
5ea762a46c Use built-in detection for OS theme in Readme 2025-03-29 05:15:38 +02:00
Keith Hall
bbb5829ad9
Merge pull request from simono/patch-1
Add abbreviations for fish to Readme
2025-03-29 05:13:14 +02:00
Simon Olofsson
c00b382f13
Add abbreviations for fish to Readme 2025-03-28 22:01:23 +01:00
Chetan
964e2bdac3 updated changelog for pr number 2025-03-28 12:23:34 +00:00
Chetan
2e7ab99099 Add Odin submodule and syntax test file 2025-03-28 12:17:45 +00:00
Chetan
4175f28979 Update changelog entry for GDScript support () 2025-03-23 13:53:32 +00:00
Chetan
207f90f01b Add GDScript submodule and syntax test file for GDScript support, see #XXX (@chetanjangir0) 2025-03-23 13:24:30 +00:00
dependabot[bot]
5c43ddb56c
Bump assets/syntaxes/02_Extra/cmd-help from 209559b to 68e727b ()
Bumps [assets/syntaxes/02_Extra/cmd-help](https://github.com/victor-gp/cmd-help-sublime-syntax) from `209559b` to `68e727b`.
- [Commits](209559b72f...68e727bad4)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/cmd-help
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 17:23:30 +00:00
dependabot[bot]
3838766dd4
Bump assets/syntaxes/02_Extra/Docker from 0f6b7bc to c001fb2 ()
Bumps [assets/syntaxes/02_Extra/Docker](https://github.com/asbjornenge/Docker.tmbundle) from `0f6b7bc` to `c001fb2`.
- [Release notes](https://github.com/asbjornenge/Docker.tmbundle/releases)
- [Commits](0f6b7bc87a...c001fb2805)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 16:13:59 +00:00
David Peter
a006457a72 Update Warp link 2025-03-09 19:20:02 +01:00
David Peter
0449107230 Update sponsors 2025-03-04 19:30:20 +01:00
dependabot[bot]
75313d886b
Bump assets/syntaxes/02_Extra/Nix from 9032bd6 to 48c497c ()
Bumps [assets/syntaxes/02_Extra/Nix](https://github.com/wmertens/sublime-nix) from `9032bd6` to `48c497c`.
- [Release notes](https://github.com/wmertens/sublime-nix/releases)
- [Commits](9032bd6137...48c497c709)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Nix
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-01 03:25:07 +00:00
Keith Hall
4998f58847
Merge pull request from sharkdp/debsources
Add debsources syntax
2025-02-25 22:28:09 +02:00
Keith Hall
ffc094bd91 Add debsources syntax 2025-02-25 22:17:00 +02:00
Keith Hall
343326eacf
Merge pull request from sharkdp/csproj_xml_mapping
Map various .NET file extensions to XML syntax
2025-02-25 05:09:12 +02:00
Keith Hall
d31bc4347a Map various .NET file extensions to XML syntax 2025-02-23 20:20:52 +02:00
Keith Hall
adfb951e51
Merge pull request from sharkdp/ndjson
Add mapping for ndjson file extension to JSON syntax
2025-02-15 12:16:52 +02:00
Keith Hall
2843a2c0e8 Add mapping for ndjson file extension to JSON syntax 2025-02-15 08:46:22 +02:00
Keith Hall
94d3dc254e
Merge pull request from sharkdp/syslog_error_highlighting_fix
Syslog error highlighting fix
2025-02-10 20:46:54 +02:00
Keith Hall
915eb55779
Merge branch 'master' into syslog_error_highlighting_fix 2025-02-09 22:20:14 +02:00
Keith Hall
547bc38118
Merge pull request from sharkdp/csv_1977
Correctly handle CSV files with a single separator throughout
2025-02-09 20:49:14 +02:00
Keith Hall
93fd013aa1 Update changelog 2025-02-09 20:37:53 +02:00
Keith Hall
512bfde7ce Correctly handle CSV files with a single separator throughout
better auto-detection of CSV delimiter
- files with a tsv extension are automatically detected as tab delimited
- other files parsed as CSV go through the following steps:
  - if the first line contains at least 3 of the same separator, it uses that separator as a delimiter
  - if the first line contains only one supported separator character, it uses that separator as a delimiter
  - otherwise it falls back to treating all supported delimiters as the delimiter

 supported delimiters, in precedence order:
 - comma `,`
 - semi-colon `;`
 - tab `\t`
 - pipe `|`
2025-02-09 20:37:53 +02:00
Keith Hall
27ba45ded7 patch Monokai Extended theme for better Syslog error highlighting 2025-02-09 20:32:48 +02:00
Keith Hall
c0898dedb1 fix meta scope ordering to come before constant.numeric scope for times 2025-02-09 20:31:31 +02:00
Keith Hall
b82b920420 attempt to fix syslog error highlighting 2025-02-09 20:31:31 +02:00
Keith Hall
ac40f7cfd8
Merge pull request from victor-gp/fix-submodules-for-dependabot
Rename submodule paths to fix Dependabot submodule updates
2025-02-04 05:15:14 +02:00
Víctor González Prieto
330c51de9f Add Changelog entry 2025-02-04 00:15:45 +01:00
Víctor González Prieto
0ed527f0d1 Replace spaces in git submodule paths
To mitigate a bug in the GitHub API that broke the Dependabot action
that updates submodules. See .
2025-02-03 22:01:33 +01:00
Keith Hall
7df1dec65c
Merge pull request from odilf/master
Add syntax mapping for `nix`s `flake.lock`
2025-02-02 21:20:33 +02:00
odilf
61d42ee87b Add syntax mapping for nixs flake.lock 2025-02-02 21:10:03 +02:00
Keith Hall
a95e65eea1
Merge pull request from einfachIrgendwer0815/style/fix_lints
Fix clippy lint warnings
2025-02-02 21:05:43 +02:00
einfachIrgendwer0815
71dce0e7f3
Fix clippy::duplicated_attributes warnings 2025-02-02 15:08:16 +01:00
einfachIrgendwer0815
53af1dc32d
Fix clippy::unnecessary_filter_map warnings 2025-02-02 15:08:15 +01:00
einfachIrgendwer0815
52252b15d6
Fix clippy::needless_lifetimes warnings 2025-02-02 15:08:15 +01:00
einfachIrgendwer0815
bc24ce9ad4
Fix clippy::needless_update warnings 2025-02-02 15:08:15 +01:00
einfachIrgendwer0815
625e986552
Fix clippy::manual_ignore_case_cmp warnings 2025-02-02 15:08:14 +01:00
einfachIrgendwer0815
095442191c
Fix clippy::ptr_arg warnings 2025-02-02 15:08:14 +01:00
einfachIrgendwer0815
cc46282866
Fix clippy::into_iter_on_ref warnings 2025-02-02 15:08:13 +01:00
einfachIrgendwer0815
cbc9c3629d
Fix clippy::manual_pattern_char_comparison warnings 2025-02-02 15:08:13 +01:00
einfachIrgendwer0815
2c49d905e4
Fix clippy::legacy_numeric_constants warnings 2025-02-02 15:08:12 +01:00
einfachIrgendwer0815
f0e2f642e0
Fix clippy::redundant_closure warnings 2025-02-02 15:08:12 +01:00
einfachIrgendwer0815
3d0f0c0565
Fix clippy::unnecessary_map_or warnings 2025-02-02 15:08:12 +01:00
einfachIrgendwer0815
3d442cdf98
Fix clippy::needless_borrow warnings 2025-02-02 15:08:11 +01:00
einfachIrgendwer0815
b009fee5ea
Fix clippy::needless_return warnings 2025-02-02 15:08:11 +01:00
einfachIrgendwer0815
6cf747678c
Fix clippy::needless_borrows_for_generic_args warnings 2025-02-02 15:08:11 +01:00
dependabot[bot]
db812e1179
Bump thiserror from 1.0.69 to 2.0.11 ()
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.69 to 2.0.11.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.69...2.0.11)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-01 04:35:19 +00:00
dependabot[bot]
995f23b58f
Bump tempfile from 3.15.0 to 3.16.0 ()
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.15.0 to 3.16.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.15.0...v3.16.0)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-01 04:18:58 +00:00
dependabot[bot]
ef3830234d
Bump itertools from 0.13.0 to 0.14.0 ()
Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.13.0 to 0.14.0.
- [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-itertools/itertools/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: itertools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-01 03:53:27 +00:00
dependabot[bot]
4fc55cfcec
Bump semver from 1.0.24 to 1.0.25 ()
Bumps [semver](https://github.com/dtolnay/semver) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/dtolnay/semver/releases)
- [Commits](https://github.com/dtolnay/semver/compare/1.0.24...1.0.25)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-01 03:24:58 +00:00
Keith Hall
487ac3bc48
Merge pull request from buzden/add-idris-syntax
[ new ] Add support for Idris 2 programming language
2025-01-27 23:00:05 +02:00
Denis Buzdalov
d6cb3ba747 [ new ] Add support for Idris 2 programming language 2025-01-27 23:47:20 +03:00
Keith Hall
a9a2dceb72
Merge pull request from buzden/fix-readme-translation
Correct and update one readme's translation according to the main english one
2025-01-27 22:35:23 +02:00
Keith Hall
bee08e48ae
Merge branch 'master' into fix-readme-translation 2025-01-27 22:20:35 +02:00
Keith Hall
b14fb9db24
Merge pull request from einfachIrgendwer0815/fix/list_themes_2
Fix: Don't output default theme info to piped stdout
2025-01-27 21:59:18 +02:00
Keith Hall
91acb0d16f update changelog to mention --list-themes bugfix when stdout is piped 2025-01-27 21:43:57 +02:00
einfachIrgendwer0815
4f161705a3
Fix: Don't output default theme info to piped stdout 2025-01-27 17:11:26 +01:00
Keith Hall
f8c6e90647
Merge pull request from cyqsimon/paru
Add syntax mapping for paru configuration files
2025-01-24 23:21:29 +02:00
cyqsimon
dd9dc4f76b Write changelog 2025-01-24 23:02:57 +02:00
cyqsimon
94f49fd99b Add syntax mapping for paru configuration 2025-01-24 23:02:57 +02:00
Keith Hall
498df11a50
Merge pull request from dtolnay-contrib/vendorbug
Work around `cargo vendor` losing syntax_mapping builtins directory
2025-01-18 09:31:35 +02:00
David Tolnay
db7da314e7
Work around cargo vendor losing syntax_mapping builtins directory 2025-01-17 21:30:37 -08:00
David Peter
33aabc696a Move section slightly further down 2025-01-15 08:34:52 +01:00
oliviajohnsto
648bedf290 Add Warp Pack sponsorship 2025-01-15 08:34:52 +01:00
Keith Hall
dd3d1b8cdb
Merge pull request from philipp-tailor/patch-1
Fix tiny accidental repetition in README.md
2025-01-10 19:31:42 +02:00
Philipp Schneider
b39a156d57
Update README.md
Fixes copy and paste error, where same option was listed twice, instead of the 2 distinct options of `--theme` for different system appearances.
2025-01-10 17:45:26 +01:00
Keith Hall
b6158c09b4
Merge pull request from bash/fix-env-var-names
Fix name of BAT_THEME_{DARK,LIGHT} env vars
2025-01-09 18:50:02 +02:00
Tau Gärtli
8a11a46f66
Add integration tests 2025-01-09 08:20:36 +01:00
Tau Gärtli
4d73c1e511
Add changelog entry 2025-01-09 08:20:36 +01:00
Tau Gärtli
280f3eeb4e
Fix name of BAT_THEME_{DARK,LIGHT} env vars 2025-01-09 08:20:36 +01:00
Keith Hall
1321160203
Merge pull request from branchvincent/git2
Bump git2 to 0.20
2025-01-08 06:52:03 +02:00
Branch Vincent
01680e444b
Bump git2 to 0.20 2025-01-07 20:30:27 -08:00
Keith Hall
2435453c33
Merge pull request from sharkdp/keith-hall-patch-1
Post release steps
2025-01-07 21:51:03 +02:00
Keith Hall
6e466e5ab4
Post release steps
Add new unreleased section at top of change log
2025-01-07 21:30:39 +02:00
Denis Buzdalov
004d2d5122 [ readme ] Correct and update one readme's translation 2024-12-17 13:49:23 +03:00
Alex Jesipow
60b3428ad7 Fix lock file 2024-08-10 11:38:38 +02:00
Alex
571970f8ff
Merge branch 'master' into read-from-tail 2024-08-10 11:34:45 +02:00
Alex Jesipow
18a0653ce8 Add changelog entry 2024-08-10 11:27:34 +02:00
Alex Jesipow
569286055c Support relative negative line ranges 2024-08-10 10:37:19 +02:00
95 changed files with 2691 additions and 801 deletions
.github/workflows
.gitmodulesCHANGELOG.mdCargo.lockCargo.tomlREADME.md
assets
build
doc
examples
src
tests

@ -53,7 +53,7 @@ jobs:
ensure_cargo_fmt:
name: Ensure 'cargo fmt' has been run
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@stable
with:
@ -63,7 +63,7 @@ jobs:
min_version:
name: Minimum supported rust version
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: crate_metadata
steps:
- name: Checkout source code
@ -81,7 +81,7 @@ jobs:
license_checks:
name: License checks
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
@ -90,7 +90,7 @@ jobs:
test_with_new_syntaxes_and_themes:
name: Run tests with updated syntaxes and themes
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
@ -119,7 +119,7 @@ jobs:
test_with_system_config:
name: Run tests with system wide configuration
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
@ -135,7 +135,7 @@ jobs:
documentation:
name: Documentation
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
@ -164,19 +164,18 @@ jobs:
fail-fast: false
matrix:
job:
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04, dpkg_arch: arm64, use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, dpkg_arch: arm64, use-cross: true }
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, dpkg_arch: armhf, use-cross: true }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, dpkg_arch: musl-linux-armhf, use-cross: true }
- { target: aarch64-unknown-linux-musl , os: ubuntu-latest, dpkg_arch: arm64, use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-latest, dpkg_arch: arm64, use-cross: true }
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-latest, dpkg_arch: armhf, use-cross: true }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-latest, dpkg_arch: musl-linux-armhf, use-cross: true }
- { target: i686-pc-windows-msvc , os: windows-2019, }
- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, dpkg_arch: i686, use-cross: true }
- { target: i686-unknown-linux-musl , os: ubuntu-20.04, dpkg_arch: musl-linux-i686, use-cross: true }
- { target: i686-unknown-linux-gnu , os: ubuntu-latest, dpkg_arch: i686, use-cross: true }
- { target: i686-unknown-linux-musl , os: ubuntu-latest, dpkg_arch: musl-linux-i686, use-cross: true }
- { target: x86_64-apple-darwin , os: macos-13, }
- { target: aarch64-apple-darwin , os: macos-14, }
- { target: x86_64-pc-windows-gnu , os: windows-2019, }
- { target: x86_64-pc-windows-msvc , os: windows-2019, }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04, dpkg_arch: amd64, use-cross: true }
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, dpkg_arch: musl-linux-amd64, use-cross: true }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-latest, dpkg_arch: amd64, use-cross: true }
- { target: x86_64-unknown-linux-musl , os: ubuntu-latest, dpkg_arch: musl-linux-amd64, use-cross: true }
env:
BUILD_CMD: cargo
steps:

@ -30,4 +30,4 @@ jobs:
echo "Added lines in CHANGELOG.md:"
echo "$ADDED"
echo "Grepping for PR info (see CONTRIBUTING.md):"
grep "#${PR_NUMBER}\\b.*@${PR_SUBMITTER}\\b" <<< "$ADDED"
grep "#${PR_NUMBER}\\b.*${PR_SUBMITTER}\\b" <<< "$ADDED"

20
.gitmodules vendored

@ -65,7 +65,7 @@
path = assets/themes/onehalf
url = https://github.com/sonph/onehalf
[submodule "assets/syntaxes/JavaScript (Babel)"]
path = assets/syntaxes/02_Extra/JavaScript (Babel)
path = assets/syntaxes/02_Extra/JavaScript_(Babel)
url = https://github.com/babel/babel-sublime
[submodule "assets/syntaxes/FSharp"]
path = assets/syntaxes/02_Extra/FSharp
@ -89,7 +89,7 @@
path = assets/themes/sublime-snazzy
url = https://github.com/greggb/sublime-snazzy
[submodule "assets/syntaxes/Assembly (ARM)"]
path = assets/syntaxes/02_Extra/Assembly (ARM)
path = assets/syntaxes/02_Extra/Assembly_(ARM)
url = https://github.com/tvi/Sublime-ARM-Assembly
[submodule "assets/syntaxes/protobuf-syntax-highlighting"]
path = assets/syntaxes/02_Extra/Protobuf
@ -108,7 +108,7 @@
path = assets/syntaxes/02_Extra/Fish
url = https://github.com/Phidica/sublime-fish.git
[submodule "assets/syntaxes/Org mode"]
path = assets/syntaxes/02_Extra/Org mode
path = assets/syntaxes/02_Extra/Org_mode
url = https://github.com/jezcope/Org.tmbundle.git
[submodule "assets/syntaxes/DotENV"]
path = assets/syntaxes/02_Extra/DotENV
@ -142,7 +142,7 @@
path = assets/themes/dracula-sublime
url = https://github.com/dracula/sublime.git
[submodule "assets/syntaxes/HTML (Twig)"]
path = assets/syntaxes/02_Extra/HTML (Twig)
path = assets/syntaxes/02_Extra/HTML_(Twig)
url = https://github.com/Anomareh/PHP-Twig.tmbundle.git
[submodule "assets/themes/Nord-sublime"]
path = assets/themes/Nord-sublime
@ -197,9 +197,6 @@
[submodule "assets/syntaxes/02_Extra/Lean"]
path = assets/syntaxes/02_Extra/Lean
url = https://github.com/leanprover/vscode-lean.git
[submodule "assets/syntaxes/02_Extra/LiveScript"]
path = assets/syntaxes/02_Extra/LiveScript
url = https://github.com/paulmillr/LiveScript.tmbundle
[submodule "assets/syntaxes/02_Extra/Zig"]
path = assets/syntaxes/02_Extra/Zig
url = https://github.com/ziglang/sublime-zig-language.git
@ -263,3 +260,12 @@
[submodule "assets/syntaxes/02_Extra/CFML"]
path = assets/syntaxes/02_Extra/CFML
url = https://github.com/jcberquist/sublimetext-cfml.git
[submodule "assets/syntaxes/02_Extra/Idris2"]
path = assets/syntaxes/02_Extra/Idris2
url = https://github.com/buzden/sublime-syntax-idris2
[submodule "assets/syntaxes/02_Extra/GDScript-sublime"]
path = assets/syntaxes/02_Extra/GDScript-sublime
url = https://github.com/beefsack/GDScript-sublime
[submodule "assets/syntaxes/02_Extra/sublime-odin"]
path = assets/syntaxes/02_Extra/sublime-odin
url = https://github.com/odin-lang/sublime-odin

@ -1,3 +1,41 @@
# unreleased
## Features
- Add paging to `--list-themes`, see PR #3239 (@einfachIrgendwer0815)
- Support negative relative line ranges, e.g. `bat -r :-10` / `bat -r='-10:'`, see #3068 (@ajesipow)
## Bugfixes
- Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)
- Prevent `--list-themes` from outputting default theme info to stdout when it is piped, see #3189 (@einfachIrgendwer0815)
- Rename some submodules to fix Dependabot submodule updates, see issue #3198 and PR #3201 (@victor-gp)
- Make highlight tests fail when new syntaxes don't have fixtures PR #3255 (@dan-hipschman)
- Fix crash for multibyte characters in file path, see issue #3230 and PR #3245 (@HSM95)
- Add missing mappings for various bash/zsh files, see PR #3262 (@AdamGaskins)
## Other
- Work around build failures when building `bat` from vendored sources #3179 (@dtolnay)
- CICD: Stop building for x86_64-pc-windows-gnu which fails #3261 (Enselic)
## Syntaxes
- Add syntax mapping for `paru` configuration files #3182 (@cyqsimon)
- Add support for [Idris 2 programming language](https://www.idris-lang.org/) #3150 (@buzden)
- Add syntax mapping for `nix`'s '`flake.lock` lockfiles #3196 (@odilf)
- Improvements to CSV/TSV highlighting, with autodetection of delimiter and support for TSV files, see #3186 (@keith-
- Improve (Sys)log error highlighting, see #3205 (@keith-hall)
- Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall)
- Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall)
- Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall)
- Add syntax definition and test file for GDScript highlighting, see #3236 (@chetanjangir0)
- Add syntax test file for Odin highlighting, see #3241 (@chetanjangir0)
## Themes
## `bat` as a library
# v0.25.0
## Features

1044
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -10,6 +10,7 @@ version = "0.25.0"
exclude = ["assets/syntaxes/*", "assets/themes/*"]
build = "build/main.rs"
edition = '2021'
# You are free to bump MSRV as soon as a reason for bumping emerges.
rust-version = "1.74"
[features]
@ -47,7 +48,7 @@ bincode = "1.0"
console = "0.15.10"
flate2 = "1.0"
once_cell = "1.20"
thiserror = "1.0"
thiserror = "2.0"
wild = { version = "2.2", optional = true }
content_inspector = "0.2.4"
shell-words = { version = "1.1.0", optional = true }
@ -60,7 +61,7 @@ semver = "1.0"
path_abs = { version = "0.5", default-features = false }
clircle = { version = "0.6.1", default-features = false }
bugreport = { version = "0.5.0", optional = true }
etcetera = { version = "0.8.0", optional = true }
etcetera = { version = "0.10.0", optional = true }
grep-cli = { version = "0.1.11", optional = true }
regex = { version = "1.10.6", optional = true }
walkdir = { version = "2.5", optional = true }
@ -68,9 +69,11 @@ bytesize = { version = "1.3.0" }
encoding_rs = "0.8.35"
execute = { version = "0.2.13", optional = true }
terminal-colorsaurus = "0.4"
unicode-segmentation = "1.12.0"
itertools = "0.13.0"
[dependencies.git2]
version = "0.19"
version = "0.20"
optional = true
default-features = false
@ -94,16 +97,16 @@ expect-test = "1.5.0"
serial_test = { version = "2.0.0", default-features = false }
predicates = "3.1.3"
wait-timeout = "0.2.0"
tempfile = "3.8.1"
tempfile = "3.16.0"
serde = { version = "1.0", features = ["derive"] }
[target.'cfg(unix)'.dev-dependencies]
nix = { version = "0.29", default-features = false, features = ["term"] }
[build-dependencies]
anyhow = "1.0.86"
indexmap = { version = "2.3.0", features = ["serde"] }
itertools = "0.13.0"
anyhow = "1.0.97"
indexmap = { version = "2.8.0", features = ["serde"] }
itertools = "0.14.0"
once_cell = "1.20"
regex = "1.10.6"
serde = "1.0"

@ -22,25 +22,22 @@
### Sponsors
A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br>
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=bat&utm_source=github">
<img src="doc/sponsors/workos-logo-white-bg.svg" width="200" alt="WorkOS">
<br>
<strong>Your app, enterprise-ready.</strong>
<br>
<sub>Start selling to enterprise customers with just a few lines of code.</sub>
<br>
<sup>Add Single Sign-On (and more) in minutes instead of months.</sup>
</a>
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=bat_20231001">
<p>
<a href="https://www.warp.dev/bat">
<img src="doc/sponsors/warp-logo.png" width="200" alt="Warp">
<br>
<strong>Warp, the intelligent terminal</strong>
<br>
<sub>Run commands like a power user with AI and your dev teams</sub>
<br>
<sup>knowledge in one fast, intuitive terminal. For MacOS or Linux.</sup>
<sub>Available on MacOS, Linux, Windows</sub>
</a>
</p><p>
<a href="https://graphite.dev/?utm_source=github&utm_medium=repo&utm_campaign=bat">
<img src="doc/sponsors/graphite-logo.jpeg" width="200" alt="Graphite">
<br>
<strong>Graphite is the AI developer productivity platform helping<br>teams on GitHub ship higher quality software, faster</strong>
</a>
</p>
### Syntax highlighting
@ -222,6 +219,12 @@ Note that the [Manpage syntax](assets/syntaxes/02_Extra/Manpage.sublime-syntax)
The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) script is a wrapper that will format code and print it with `bat`.
#### `Warp`
<a href="https://app.warp.dev/drive/folder/-Bat-Warp-Pack-lxhe7HrEwgwpG17mvrFSz1">
<img src="doc/sponsors/warp-pack-header.png" alt="Warp">
</a>
#### Highlighting `--help` messages
You can use `bat` to colorize help text: `$ cp --help | bat -plhelp`
@ -245,6 +248,13 @@ alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain'
```
For `fish`, you can use abbreviations:
```fish
abbr -a --position anywhere -- --help '--help | bat -plhelp'
abbr -a --position anywhere -- -h '-h | bat -plhelp'
```
This way, you can keep on using `cp --help`, but get colorized help pages.
Be aware that in some cases, `-h` may not be a shorthand of `--help` (for example with `ls`).
@ -417,7 +427,7 @@ take a look at the ["Using `bat` on Windows"](#using-bat-on-windows) section.
#### Prerequisites
You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package.
You will need to install the [Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist#latest-microsoft-visual-c-redistributable-version)
#### With WinGet
@ -489,7 +499,7 @@ bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
```
`bat` automatically picks a fitting theme depending on your terminal's background color.
You can use the `--theme-light` / `--theme-light` options or the `BAT_THEME_DARK` / `BAT_THEME_LIGHT` environment variables
You can use the `--theme-dark` / `--theme-light` options or the `BAT_THEME_DARK` / `BAT_THEME_LIGHT` environment variables
to customize the themes used. This is especially useful if you frequently switch between dark and light mode.
You can also use a custom theme by following the
@ -689,7 +699,7 @@ theme based on the OS theme. The following snippet uses the `default` theme when
and the `GitHub` theme when in the _light mode_.
```bash
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
alias cat="bat --theme auto:system --theme-dark default --theme-light GitHub"
```

@ -180,8 +180,8 @@ This option only has an effect when \fB\-\-theme\fP option is set to \fBauto\fR
.HP
\fB\-\-theme\-light\fR <theme>
.IP
Sets the theme name for syntax highlighting used when the terminal uses a dark background.
To set a default theme, add the \fB\-\-theme-dark="..."\fP option to the configuration file or
Sets the theme name for syntax highlighting used when the terminal uses a light background.
To set a default theme, add the \fB\-\-theme-light="..."\fP option to the configuration file or
export the \fBBAT_THEME_LIGHT\fP environment variable (e.g. \fBexport BAT_THEME_LIGHT="..."\fP).
This option only has an effect when \fB\-\-theme\fP option is set to \fBauto\fR or \fBlight\fR.
.HP

@ -21,11 +21,26 @@ index 9c2aa3e..180cbbf 100644
<string>Invalid</string>
<key>scope</key>
- <string>invalid</string>
+ <string>invalid, markup.error</string>
+ <string>invalid, meta.annotation.error-line</string>
<key>settings</key>
<dict>
<key>background</key>
@@ -1042,7 +1042,7 @@
@@ -1038,11 +1038,22 @@
<string>#f8f8f0</string>
</dict>
</dict>
+ <dict>
+ <key>name</key>
+ <string>Error</string>
+ <key>scope</key>
+ <string>markup.error</string>
+ <key>settings</key>
+ <dict>
+ <key>foreground</key>
+ <string>#dd2020</string>
+ </dict>
+ </dict>
<dict>
<key>name</key>
<string>Invalid deprecated</string>
<key>scope</key>

@ -1 +1 @@
Subproject commit 163bc03ae8998a237dfb4be353d0aea198ea17f5
Subproject commit cf6cefc51ebb46b1b54906433edbae0fe9c71cad

@ -2,20 +2,21 @@
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Comma Separated Values
file_extensions:
- csv
- tsv
scope: text.csv
scope: text.csv.comma
variables:
field_separator: (?:[,;|\t])
field_separator: (?:,)
record_separator: (?:$\n?)
contexts:
prototype:
- match: (?={{record_separator}})
pop: true
main:
- match: '^'
push: fields
fields:
- match: ""
- include: record_separator
- match: ''
push:
- field_or_record_separator
- field5
- field_or_record_separator
- field4
- field_or_record_separator
@ -24,54 +25,55 @@ contexts:
- field2
- field_or_record_separator
- field1
main:
record_separator_pop:
- match: (?={{record_separator}})
pop: true
record_separator:
- meta_include_prototype: false
- match: "^"
set: fields
- match: '{{record_separator}}'
scope: punctuation.terminator.record.csv
pop: true
field_or_record_separator:
- meta_include_prototype: false
- match: "{{record_separator}}"
scope: punctuation.terminator.record.csv
pop: true
- match: "{{field_separator}}"
- include: record_separator_pop
- match: '{{field_separator}}'
scope: punctuation.separator.sequence.csv
pop: true
field_contents:
- match: '"'
scope: punctuation.definition.string.begin.csv
push: double_quoted_string
push: scope:text.csv#double_quoted_string
- match: (?={{field_separator}}|{{record_separator}})
pop: true
double_quoted_string:
- meta_include_prototype: false
- meta_scope: string.quoted.double.csv
- match: '""'
scope: constant.character.escape.csv
- match: '"'
scope: punctuation.definition.string.end.csv
- include: record_separator_pop
- match: (?={{field_separator}})
pop: true
field1:
- match: ""
- match: ''
set:
- meta_content_scope: meta.field-1.csv support.type
- meta_content_scope: meta.field-1.csv variable.parameter
- include: field_contents
field2:
- match: ""
- match: ''
set:
- meta_content_scope: meta.field-2.csv support.function
- include: field_contents
field3:
- match: ""
- match: ''
set:
- meta_content_scope: meta.field-3.csv constant.numeric
- include: field_contents
field4:
- match: ""
- match: ''
set:
- meta_content_scope: meta.field-4.csv keyword.operator
- include: field_contents
field5:
- match: ''
set:
- meta_content_scope: meta.field-5.csv string.unquoted
- include: field_contents

@ -0,0 +1,80 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Pipe Separated Values
scope: text.csv.pipe
variables:
field_separator: (?:\|)
record_separator: (?:$\n?)
contexts:
main:
- match: '^'
push: fields
fields:
- include: record_separator
- match: ''
push:
- field_or_record_separator
- field5
- field_or_record_separator
- field4
- field_or_record_separator
- field3
- field_or_record_separator
- field2
- field_or_record_separator
- field1
record_separator_pop:
- match: (?={{record_separator}})
pop: true
record_separator:
- meta_include_prototype: false
- match: '{{record_separator}}'
scope: punctuation.terminator.record.csv
pop: true
field_or_record_separator:
- meta_include_prototype: false
- include: record_separator_pop
- match: '{{field_separator}}'
scope: punctuation.separator.sequence.csv
pop: true
field_contents:
- match: '"'
scope: punctuation.definition.string.begin.csv
push: scope:text.csv#double_quoted_string
- include: record_separator_pop
- match: (?={{field_separator}})
pop: true
field1:
- match: ''
set:
- meta_content_scope: meta.field-1.csv variable.parameter
- include: field_contents
field2:
- match: ''
set:
- meta_content_scope: meta.field-2.csv support.function
- include: field_contents
field3:
- match: ''
set:
- meta_content_scope: meta.field-3.csv constant.numeric
- include: field_contents
field4:
- match: ''
set:
- meta_content_scope: meta.field-4.csv keyword.operator
- include: field_contents
field5:
- match: ''
set:
- meta_content_scope: meta.field-5.csv string.unquoted
- include: field_contents

@ -0,0 +1,79 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Semi-Colon Separated Values
scope: text.csv.semi-colon
variables:
field_separator: (?:;)
record_separator: (?:$\n?)
contexts:
main:
- match: '^'
push: fields
fields:
- include: record_separator
- match: ''
push:
- field_or_record_separator
- field5
- field_or_record_separator
- field4
- field_or_record_separator
- field3
- field_or_record_separator
- field2
- field_or_record_separator
- field1
record_separator_pop:
- match: (?={{record_separator}})
pop: true
record_separator:
- meta_include_prototype: false
- match: '{{record_separator}}'
scope: punctuation.terminator.record.csv
pop: true
field_or_record_separator:
- meta_include_prototype: false
- include: record_separator_pop
- match: '{{field_separator}}'
scope: punctuation.separator.sequence.csv
pop: true
field_contents:
- match: '"'
scope: punctuation.definition.string.begin.csv
push: scope:text.csv#double_quoted_string
- include: record_separator_pop
- match: (?={{field_separator}})
pop: true
field1:
- match: ''
set:
- meta_content_scope: meta.field-1.csv variable.parameter
- include: field_contents
field2:
- match: ''
set:
- meta_content_scope: meta.field-2.csv support.function
- include: field_contents
field3:
- match: ''
set:
- meta_content_scope: meta.field-3.csv constant.numeric
- include: field_contents
field4:
- match: ''
set:
- meta_content_scope: meta.field-4.csv keyword.operator
- include: field_contents
field5:
- match: ''
set:
- meta_content_scope: meta.field-5.csv string.unquoted
- include: field_contents

@ -0,0 +1,113 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Separated Values
file_extensions:
- csv
scope: text.csv
variables:
field_separator_chars: ',;\t|'
field_separator: (?:[{{field_separator_chars}}])
record_separator: (?:$\n?)
contexts:
main:
- meta_include_prototype: false
- include: three_field_separators
- include: single_separator_type_on_line
- match: '^'
push: unknown-separated-main
three_field_separators:
- match: ^(?=(?:[^,]*,){3})
set: scope:text.csv.comma
- match: ^(?=(?:[^;]*;){3})
set: scope:text.csv.semi-colon
- match: ^(?=(?:[^\t]*\t){3})
set: scope:text.csv.tab
- match: ^(?=(?:[^|]*\|){3})
set: scope:text.csv.pipe
single_separator_type_on_line:
- match: ^(?=[^{{field_separator_chars}}]*,[^;\t|]*$)
set: scope:text.csv.comma
- match: ^(?=[^{{field_separator_chars}}]*;[^,\t|]*$)
set: scope:text.csv.semi-colon
- match: ^(?=[^{{field_separator_chars}}]*\t[^,;|]*$)
set: scope:text.csv.tab
- match: ^(?=[^{{field_separator_chars}}]*\|[^,;\t]*$)
set: scope:text.csv.pipe
unknown-separated-main:
- include: record_separator
- match: ''
push:
- field_or_record_separator
- field5
- field_or_record_separator
- field4
- field_or_record_separator
- field3
- field_or_record_separator
- field2
- field_or_record_separator
- field1
record_separator_pop:
- match: (?={{record_separator}})
pop: true
record_separator:
- meta_include_prototype: false
- match: '{{record_separator}}'
scope: punctuation.terminator.record.csv
field_or_record_separator:
- meta_include_prototype: false
- include: record_separator_pop
- match: '{{field_separator}}'
scope: punctuation.separator.sequence.csv
pop: true
field_contents:
- match: '"'
scope: punctuation.definition.string.begin.csv
push: double_quoted_string
- include: record_separator_pop
- match: (?={{field_separator}})
pop: true
double_quoted_string:
- meta_include_prototype: false
- meta_scope: string.quoted.double.csv
- match: '""'
scope: constant.character.escape.csv
- match: '"'
scope: punctuation.definition.string.end.csv
pop: true
field1:
- match: ''
set:
- meta_content_scope: meta.field-1.csv variable.parameter
- include: field_contents
field2:
- match: ''
set:
- meta_content_scope: meta.field-2.csv support.function
- include: field_contents
field3:
- match: ''
set:
- meta_content_scope: meta.field-3.csv constant.numeric
- include: field_contents
field4:
- match: ''
set:
- meta_content_scope: meta.field-4.csv keyword.operator
- include: field_contents
field5:
- match: ''
set:
- meta_content_scope: meta.field-5.csv string.unquoted
- include: field_contents

@ -0,0 +1,83 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Tab Separated Values
scope: text.csv.tab
file_extensions:
- tsv
variables:
field_separator: (?:\t)
record_separator: (?:$\n?)
contexts:
main:
- match: '^'
push: fields
fields:
- include: record_separator
- match: ''
push:
- field_or_record_separator
- field5
- field_or_record_separator
- field4
- field_or_record_separator
- field3
- field_or_record_separator
- field2
- field_or_record_separator
- field1
record_separator_pop:
- match: (?={{record_separator}})
pop: true
record_separator:
- meta_include_prototype: false
- match: '{{record_separator}}'
scope: punctuation.terminator.record.csv
pop: true
field_or_record_separator:
- meta_include_prototype: false
- include: record_separator_pop
- match: '{{field_separator}}'
scope: punctuation.separator.sequence.csv
pop: true
field_contents:
- match: '"'
scope: punctuation.definition.string.begin.csv
push: scope:text.csv#double_quoted_string
- include: record_separator_pop
- match: (?={{field_separator}})
pop: true
field1:
- match: ''
set:
- meta_content_scope: meta.field-1.csv variable.parameter
- include: field_contents
field2:
- match: ''
set:
- meta_content_scope: meta.field-2.csv support.function
- include: field_contents
field3:
- match: ''
set:
- meta_content_scope: meta.field-3.csv constant.numeric
- include: field_contents
field4:
- match: ''
set:
- meta_content_scope: meta.field-4.csv keyword.operator
- include: field_contents
field5:
- match: ''
set:
- meta_content_scope: meta.field-5.csv string.unquoted
- include: field_contents

@ -1 +1 @@
Subproject commit 0f6b7bc87acf684f7b0790fd480731ffb4615b87
Subproject commit c001fb280561d7c16f0f2837d76af493cf6c3bf8

@ -0,0 +1 @@
Subproject commit 96f5dcf29728aa987123321e2544330eed991a3e

1
assets/syntaxes/02_Extra/Idris2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 7c1bf44c4f9092b7b1e274b1332cf32a089b2b99

@ -1 +0,0 @@
Subproject commit d82aeb737d4883d1a74aba7a07053f90211d427b

@ -1 +1 @@
Subproject commit 9032bd613746b9c135223fd6f26a5fa555f18946
Subproject commit 48c497c709c66a2fb118c534a8de8e4e1c4c401d

@ -1 +0,0 @@
Subproject commit 4976d8f84eeecd94df7da872bf404c125df04c73

1
assets/syntaxes/02_Extra/Org_mode vendored Submodule

@ -0,0 +1 @@
Subproject commit bb6e5d848151135ab8f87bdcb997437b2308718a

@ -1 +1 @@
Subproject commit c0372a1d2df136ca6b3d1a9f7b85031dedf117f9
Subproject commit a08b55bf1146c210f58e844be53c2aa78fd5e610

@ -1 +1 @@
Subproject commit 1a4a38445fec495817625bafbeb01e79c44abcba
Subproject commit 8a4a3fe4a051f85c4752b82f586d395cab843c06

@ -0,0 +1,42 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/syntax.html
name: debsources
file_extensions:
- sources.list
scope: text.apt-source-list
contexts:
main:
- include: comments
- match: ^[\w-]+
scope: constant.language.apt-source-list
- match: \w+://\S+
scope: markup.underline.link.apt-source-list
push: distribution
- match: \bmain\b
scope: support.class.apt-source-list
- match: \buniverse\b
scope: support.constant.apt-source-list
- match: \brestricted\b
scope: storage.modifier.apt-source-list
- match: \bmultiverse\b
scope: keyword.other.apt-source-list
- match: '[\w-]+'
scope: constant.other.apt-source-list
comments:
- match: '#'
scope: punctuation.definition.comment.apt-source-list
push: line_comment
line_comment:
- meta_scope: comment.line.apt-source-list
- match: $
pop: true
distribution:
- match: \S+
scope: support.type.apt-source-list
pop: 1
- match: $
pop: 1

@ -1 +1 @@
Subproject commit 209559b72f7e8848c988828088231b3a4d8b6838
Subproject commit c71ba410bdfcc8f627df3219f14e3f2be4fe68ba

@ -38,21 +38,21 @@ contexts:
scope: markup.underline.link.scheme.log
push: url-host
log_level_lines:
- match: ^(?=.*{{error}})
- match: (?=.*{{error}})
push:
- error_line
- error_line_meta
- main_pop_at_eol
- match: ^(?=.*{{warning}})
- match: (?=.*{{warning}})
push:
- warning_line
- warning_line_meta
- main_pop_at_eol
- match: ^(?=.*{{info}})
- match: (?=.*{{info}})
push:
- info_line
- info_line_meta
- main_pop_at_eol
- match: ^(?=.*{{debug}})
- match: (?=.*{{debug}})
push:
- debug_line
- debug_line_meta
- main_pop_at_eol
log_levels:
- match: '{{error}}'
@ -63,16 +63,16 @@ contexts:
scope: markup.info.log
- match: '{{debug}}'
scope: markup.info.log
error_line:
error_line_meta:
- meta_scope: meta.annotation.error-line.log
- include: immediately_pop
warning_line:
warning_line_meta:
- meta_scope: meta.annotation.warning-line.log
- include: immediately_pop
info_line:
info_line_meta:
- meta_scope: meta.annotation.info-line.log
- include: immediately_pop
debug_line:
debug_line_meta:
- meta_scope: meta.annotation.debug-line.log
- include: immediately_pop
immediately_pop:

@ -0,0 +1 @@
Subproject commit 5d6a0ed41e41ec3709ec74f40686dc3761d6596e

@ -8,10 +8,10 @@ scope: text.log.syslog
contexts:
main:
- match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
scope: meta.datetime.syslog constant.numeric.syslog
scope: meta.datetime.syslog
captures:
1: meta.date.syslog
2: meta.time.syslog
1: meta.date.syslog constant.numeric.syslog
2: meta.time.syslog constant.numeric.syslog
push: loghost
- match: ^
push: text
@ -31,22 +31,24 @@ contexts:
structured-data:
- match: '\['
scope: punctuation.section.mapping.begin.syslog
push:
- match: \]
scope: punctuation.section.mapping.end.syslog
pop: true
- match: \w+
scope: variable.parameter.syslog
- match: =
scope: keyword.operator.assignment.syslog
push:
- match: '[^\s\]]+'
scope: constant.other.syslog
pop: true
- match: (?=\])
pop: true
push: structured-data-contents
- match: (?=\S)
set: text
structured-data-contents:
- match: \]
scope: punctuation.section.mapping.end.syslog
pop: true
- match: \w+
scope: variable.parameter.syslog
- match: =
scope: keyword.operator.assignment.syslog
push: structured-data-assignment
structured-data-assignment:
- match: '[^\s\]]+'
scope: constant.other.syslog
pop: true
- match: (?=\])
pop: true
text:
- match: $
pop: true

@ -1 +1 @@
Subproject commit 86d4ee7a1f884851a1d21d66249687f527fced32
Subproject commit 4f217457230ff5f31d594b0e20474b69294988d4

@ -236,8 +236,14 @@ fn get_def_paths() -> anyhow::Result<Vec<PathBuf>> {
];
let mut toml_paths = vec![];
for subdir in source_subdirs {
let wd = WalkDir::new(Path::new("src/syntax_mapping/builtins").join(subdir));
for subdir_name in source_subdirs {
let subdir = Path::new("src/syntax_mapping/builtins").join(subdir_name);
if !subdir.try_exists()? {
// Directory might not exist due to this `cargo vendor` bug:
// https://github.com/rust-lang/cargo/issues/15080
continue;
}
let wd = WalkDir::new(subdir);
let paths = wd
.into_iter()
.filter_map_ok(|entry| {

@ -3,11 +3,11 @@
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
Клон утилиты <i>cat(1)</i> с поддержкой выделения синтаксиса и Git
Клон утилиты <i>cat(1)</i> с поддержкой подсветки синтаксиса и Git
</p>
<p align="center">
<a href="#выделение-синтаксиса">Ключевые возможности</a>
<a href="#подсветка-синтаксиса">Ключевые возможности</a>
<a href="#как-использовать">Использование</a>
<a href="#установка">Установка</a>
<a href="#кастомизация">Кастомизация</a>
@ -19,11 +19,11 @@
[Русский]
</p>
### Выделение синтаксиса
### Подсветка синтаксиса
`bat` поддерживает выделение синтаксиса для огромного количества языков программирования и разметки:
`bat` поддерживает подсветку синтаксиса для огромного количества языков программирования и разметки:
![Пример выделения синтаксиса](https://i.imgur.com/3FGy5tW.png)
![Пример подсветки синтаксиса](https://i.imgur.com/3FGy5tW.png)
### Интеграция с Git
`bat` использует `git`, чтобы показать изменения в коде
@ -31,15 +31,17 @@
![Пример интеграции с Git](https://i.imgur.com/azUAzdx.png)
### Показать непечатаемые символы
### Показ непечатных символов
Вы можете использовать `-A` / `--show-all` флаг, чтобы показать символы, которые невозможно напечатать:
Вы можете использовать флаг `-A` / `--show-all`, чтобы показать непечатные символы:
![Строка с неотображемыми символами](https://i.imgur.com/X0orYY9.png)
### Автоматическое разделение текста
### Автоматический пейджинг терминала
`bat` умеет перенаправлять вывод в `less`, если вывод не помещается на экране полностью.
`bat` умеет перенаправлять вывод в пейджер терминала (например, в `less`), если вывод не помещается на экране полностью.
Если вы хотите, чтобы `bat` работал как `cat` всё время, вы можете установить опцию `--paging=never` в командной строке или в конфигурационном файле.
Если вы намерены использовать `bat` в качестве алиаса для `cat`, вы можете установить `alias cat='bat --paging=never'`, чтобы сохранить изначальное поведение.
### Объединение файлов
@ -86,11 +88,23 @@ bat header.md content.md footer.md > document.md
bat -n main.rs # показываем только количество строк
bat f - g # выводит 'f' в stdin, а потом 'g'.
bat f - g # выводит 'f', потом stdin, а потом 'g'.
```
### Интеграция с другими утилитами
#### `fzf`
Вы можете использовать `bat` как просмотрщик для [`fzf`](https://github.com/junegunn/fzf).
Чтобы это заработало, используйте опцию `--color=always`, чтобы вывод был всегда цветным.
Вы можете также использовать опцию `--line-range`, чтобы уменьшить время загрузки для больших файлов:
```bash
fzf --preview "bat --color=always --style=numbers --line-range=:500 {}"
```
Больше деталей смотрите в [`README` программы `fzf`](https://github.com/junegunn/fzf#preview-window).
#### `find` или `fd`
Вы можете использовать флаг `-exec` в `find`, чтобы посмотреть превью всех файлов в `bat`
@ -121,12 +135,22 @@ tail -f /var/log/pacman.log | bat --paging=never -l log
#### `git`
Вы можете использовать `bat` с `git show`, чтобы просмотреть старую версию файла с выделением синтаксиса:
Вы можете использовать `bat` с `git show`, чтобы просмотреть старую версию файла с подсветкой синтаксиса:
```bash
git show v0.6.0:src/main.rs | bat -l rs
```
Обратите внимание, что выделение синтаксиса не работает в `git diff` на данный момент. Если вам это нужно, посмотрите [`delta`](https://github.com/dandavison/delta).
#### `git diff`
Вы можете использовать `bat` с `git diff` для просмотра строк кода вокруг изменений с подсветкой синтаксиса:
```bash
batdiff() {
git diff --name-only --relative --diff-filter=d | xargs bat --diff
}
```
Если вы хотите использовать это как отдельную программу, посмотрите `batdiff` из [`bat-extras`](https://github.com/eth-p/bat-extras).
Если вам это нужна более полная поддержка для операций с git и diff, посмотрите [`delta`](https://github.com/dandavison/delta).
#### `xclip`
@ -135,17 +159,18 @@ git show v0.6.0:src/main.rs | bat -l rs
```bash
bat main.cpp | xclip
```
`bat` обнаружит перенаправление вывода и выведет обычный текст без выделения синтаксиса.
`bat` обнаружит перенаправление вывода и выведет обычный текст без подсветки синтаксиса.
#### `man`
`bat` может быть использован в виде выделения цвета для `man`, для этого установите переменную окружения
`bat` может быть использован для раскрашивания вывода `man`, для этого установите переменную окружения
`MANPAGER`:
```bash
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
man 2 select
```
(замените `bat` на `batcat`, если у вас Debian или Ubuntu)
Возможно вам понадобится также установить `MANROFFOPT="-c"`, если у вас есть проблемы с форматированием.
@ -153,10 +178,40 @@ man 2 select
Обратите внимание, что [синтаксис manpage](assets/syntaxes/02_Extra/Manpage.sublime-syntax) разрабатывается в этом репозитории и все еще находится в разработке.
Также заметьте, что это [не заработает](https://github.com/sharkdp/bat/issues/1145) с реализацией `man` через Mandocs.
#### `prettier` / `shfmt` / `rustfmt`
[`Prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) — скрипт, который форматирует код и выводит его с помощью `bat`.
#### Подсветка сообщений `--help`
Вы можете использовать `bat`, чтобы подсвечивать текст справки комманд: `$ cp --help | bat -plhelp`
Вы можете сделать такую вспомогательную команду для этого:
```bash
# in your .bashrc/.zshrc/*rc
alias bathelp='bat --plain --language=help'
help() {
"$@" --help 2>&1 | bathelp
}
```
В этом случае, вы можете просто писать `$ help cp` или `$ help git commit`.
Если вы используете `zsh`, вы можете объявить глобальные алиасы для `-h` и `--help`:
```bash
alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain'
```
В этом случае, вы можете продолжать использовать `cp --help`, но при этом получать подцвеченный вывод.
Обратите внимание, что не всегда опция `-h` является краткой формы опции `--help` (например, у `ls`).
Пожалуйста, сообщайте о проблемах с подсветкой справки в [этот репозиторий](https://github.com/victor-gp/cmd-help-sublime-syntax).
## Установка
@ -165,8 +220,7 @@ man 2 select
### Ubuntu (с помощью `apt`)
*... и другие дистрибутивы основанные на Debian.*
`bat` есть в репозиториях [Ubuntu](https://packages.ubuntu.com/eoan/bat) и
[Debian](https://packages.debian.org/sid/bat) и доступен начиная с Ubuntu Eoan 19.10. На Debian `bat` пока что доступен только с нестабильной веткой "Sid".
`bat` доступен на [Ubuntu since 20.04 ("Focal")](https://packages.ubuntu.com/search?keywords=bat&exact=1) и [Debian since August 2021 (Debian 11 - "Bullseye")](https://packages.debian.org/bullseye/bat).
Если ваша версия Ubuntu/Debian достаточно новая, вы можете установить `bat` так:
@ -245,6 +299,14 @@ cd /usr/ports/textproc/bat
make install
```
### On OpenBSD
Вы можете установить `bat` с помощью [`pkg_add(1)`](https://man.openbsd.org/pkg_add.1):
```bash
pkg_add bat
```
### С помощью nix
Вы можете установить `bat`, используя [nix package manager](https://nixos.org/nix):
@ -253,6 +315,14 @@ make install
nix-env -i bat
```
### Через flox
Вы можете установить `bat` используя [Flox](https://flox.dev)
```bash
flox install bat
```
### openSUSE
Вы можете установить `bat` с помощью `zypper`:
@ -261,7 +331,7 @@ nix-env -i bat
zypper install bat
```
### macOS
### На macOS (или Linux) через Homebrew
Вы можете установить `bat` с помощью [Homebrew](http://braumeister.org/formula/bat):
@ -269,6 +339,8 @@ zypper install bat
brew install bat
```
### На macOS через MacPorts
Или же установить его с помощью [MacPorts](https://ports.macports.org/port/bat/summary):
```bash
@ -277,7 +349,19 @@ port install bat
### Windows
Есть несколько способов установить `bat`. Как только вы установили его, посмотрите на секцию ["Использование `bat` в Windows"](#using-bat-on-windows).
Есть несколько способов установить `bat`. Как только вы установили его, посмотрите на секцию ["Использование `bat` в Windows"](#использование-bat-в-windows).
#### Пререквитизы
Вам нужно установить пакет [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads).
#### С помощью WinGet
Вы можете установить `bat` через [WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget):
```bash
winget install sharkdp.bat
```
#### С помощью Chocolatey
@ -293,50 +377,10 @@ choco install bat
scoop install bat
```
Для этого у вас должен быть установлен [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads).
#### Из заранее скомпилированных файлов:
Их вы можете скачать на [странице релизов](https://github.com/sharkdp/bat/releases).
Для этого у вас должен быть установлен [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads).
### С помощью Docker
Вы можете использовать [Docker image](https://hub.docker.com/r/danlynn/bat/), чтобы запустить `bat` в контейнере:
```bash
docker pull danlynn/bat
alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat'
```
### С помощью Ansible
Вы можете установить `bat` с [Ansible](https://www.ansible.com/):
```bash
# Устанавливаем роль на устройстве
ansible-galaxy install aeimer.install_bat
```
```yaml
---
# Playbook для установки bat
- host: all
roles:
- aeimer.install_bat
```
- [Ansible Galaxy](https://galaxy.ansible.com/aeimer/install_bat)
- [GitHub](https://github.com/aeimer/ansible-install-bat)
Этот способ должен сработать со следующими дистрибутивами:
- Debian/Ubuntu
- ARM (например Raspberry PI)
- Arch Linux
- Void Linux
- FreeBSD
- macOS
### Из скомпилированных файлов
Перейдите на [страницу релизов](https://github.com/sharkdp/bat/releases) для
@ -344,15 +388,24 @@ ansible-galaxy install aeimer.install_bat
### Из исходников
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.74.0 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.74.0 или выше. После этого используйте `cargo`, чтобы всё скомпилировать:
```bash
cargo install --locked bat
```
Заметьте, что дополнительные файлы, такие как документация man и подсказки командной строки, не могут быть установлены таким способом.
Они будут сгенерированы командой `cargo` должны быть доступны в папке сборки (в `build`).
Подсказки командной строки также доступны при таком запуске:
```bash
bat --completion <shell>
# see --help for supported shells
```
## Кастомизация
### Темы для выделения текста
### Темы для подсветки синтаксиса
Используйте `bat --list-themes`, чтобы вывести список всех доступных тем. Для выбора темы `TwoDark` используйте `bat` с флагом
`--theme=TwoDark` или выставьте переменную окружения `BAT_THEME` в `TwoDark`. Используйте `export BAT_THEME="TwoDark"` в конфигурационном файле вашей оболочки, чтобы изменить ее навсегда. Или же используйте [конфигурационный файл](https://github.com/sharkdp/bat#configuration-file) `bat`.
@ -372,7 +425,7 @@ bat --list-themes | fzf --preview="bat --theme={} --color=always /путь/к/ф
### Добавление новых синтаксисов
`bat` использует [`syntect`](https://github.com/trishume/syntect/) для выделения синтаксиса. `syntect` может читать
`bat` использует [`syntect`](https://github.com/trishume/syntect/) для подсветки синтаксиса. `syntect` может читать
[файл `.sublime-syntax`](https://www.sublimetext.com/docs/3/syntax.html)
и темы. Чтобы добавить новый синтаксис, сделайте следующее:
@ -403,7 +456,7 @@ bat cache --clear
### Добавление новых тем
Это работает похожим образом, так же как и добавление новых тем выделения синтаксиса
Это работает похожим образом, так же как и добавление новых тем подсветки синтаксиса
Во-первых, создайте каталог с новыми темами для синтаксиса:
```bash
@ -590,7 +643,7 @@ cargo install --locked --force
Есть очень много альтернатив `bat`. Смотрите [этот документ](doc/alternatives.md) для сравнения.
## Лицензия
Copyright (c) 2018-2021 [Разработчики bat](https://github.com/sharkdp/bat).
Copyright (c) 2018-2024 [Разработчики bat](https://github.com/sharkdp/bat).
`bat` распространяется под лицензиями MIT License и Apache License 2.0 (на выбор пользователя).

@ -26,7 +26,7 @@ in the `.sublime-syntax` format.
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
`bat` binary.
5. Use `bat --list-languages` to check if the new languages are available.
5. Use `bat --list-languages` to check if the new languages are available. You may want to do something like `export PATH="`pwd`/target/debug:$PATH"` to ensure the locally compiled version is the one being used.
6. Add a syntax test for the new language. See [below](#Syntax-tests) for details.

Binary file not shown.

After

(image error) Size: 28 KiB

Binary file not shown.

After

(image error) Size: 37 KiB

@ -1,11 +0,0 @@
<svg width="1354" height="420" viewBox="0 0 1354 420" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="1354" height="420" rx="20" fill="white"/>
<path d="M434.751 133.122H466.637L489.595 227.729C493.852 245.585 494.697 256.219 494.697 256.219H495.128C495.128 256.219 496.61 245.808 500.867 227.729L522.757 133.122H558.9L582.066 227.729C586.53 246.223 587.598 256.219 587.598 256.219H588.236C588.236 256.219 588.666 246.223 592.907 227.729L615.02 133.122H646.907L606.523 288.313H571.017L546.576 194.344C541.474 173.936 541.044 164.801 541.044 164.801H540.614C540.614 164.801 540.183 173.936 535.512 194.344L512.553 288.313H475.996L434.751 133.122Z" fill="black"/>
<path d="M641.583 231.934C641.583 196.428 664.541 173.47 699.202 173.47C733.639 173.47 756.597 196.428 756.597 231.934C756.597 267.647 733.639 290.828 699.202 290.828C664.557 290.812 641.583 267.647 641.583 231.934ZM726.832 231.934C726.832 208.976 715.783 195.998 699.202 195.998C681.346 195.998 671.349 210.458 671.349 231.934C671.349 255.323 682.398 268.284 699.202 268.284C717.058 268.284 726.832 253.824 726.832 231.934Z" fill="black"/>
<path d="M770.836 175.21H799.103V196.048H799.741C804.635 185.207 816.322 174.365 836.299 174.365C839.695 174.365 841.831 174.796 843.314 175.21V203.478H842.469C842.469 203.478 839.918 202.633 832.903 202.633C811.013 202.633 799.103 215.594 799.103 239.828V288.295H770.836V175.21Z" fill="black"/>
<path d="M856.5 133.122H884.767V182.865C884.767 212.2 884.336 217.509 884.336 217.509H884.767L926.857 175.212H962.139L912.843 224.11L970.031 288.313H936.646L895.401 241.536L884.767 251.946V288.297H856.5V133.122Z" fill="black"/>
<path d="M970.444 211.285C970.444 163.455 1000.21 131.569 1044.85 131.569C1089.49 131.569 1119.26 163.455 1119.26 211.285C1119.26 259.114 1089.49 291.001 1044.85 291.001C1000.21 291.001 970.444 259.114 970.444 211.285ZM1088.42 211.285C1088.42 178.761 1071 156.855 1044.84 156.855C1018.67 156.855 1001.26 178.761 1001.26 211.285C1001.26 243.809 1018.69 265.715 1044.84 265.715C1070.98 265.715 1088.42 243.809 1088.42 211.285Z" fill="black"/>
<path d="M1130.08 236.656H1162.4C1162.4 254.943 1174.95 265.146 1194.08 265.146C1210.23 265.146 1221.29 257.063 1221.29 245.584C1221.29 232.622 1212.79 229.21 1185.79 223.901C1161.12 219.007 1134.98 210.716 1134.98 178.399C1134.98 151.408 1157.93 131 1193.01 131C1229.57 131 1252.11 150.132 1252.11 179.037H1219.79C1219.79 165.007 1208.95 156.286 1193.01 156.286C1176.86 156.286 1166.86 164.146 1166.86 175.625C1166.86 187.742 1173.88 192.413 1195.56 196.878C1227.65 203.685 1254.02 207.288 1254.02 243.001C1254.02 271.3 1229.36 290.432 1193.01 290.432C1156.02 290.432 1130.08 268.957 1130.08 236.656Z" fill="black"/>
<path d="M100 210C100 214.824 101.269 219.647 103.723 223.793L148.231 300.878C152.8 308.747 159.739 315.178 168.369 318.055C185.377 323.724 202.977 316.447 211.354 301.893L222.1 283.278L179.708 210L224.47 132.408L235.216 113.792C238.431 108.208 242.747 103.638 247.824 100H243.17H178.777C166.677 100 155.508 106.431 149.5 116.923L103.723 196.208C101.269 200.354 100 205.177 100 210Z" fill="#6363F1"/>
<path d="M353.847 210C353.847 205.177 352.578 200.353 350.124 196.207L305.024 118.107C296.647 103.638 279.047 96.3608 262.039 101.945C253.409 104.822 246.47 111.253 241.901 119.122L231.747 136.638L274.139 210L229.378 287.592L218.632 306.208C215.416 311.708 211.101 316.362 206.024 320H210.678H275.07C287.17 320 298.34 313.569 304.347 303.077L350.124 223.792C352.578 219.646 353.847 214.823 353.847 210Z" fill="#6363F1"/>
</svg>

Before

(image error) Size: 3.4 KiB

@ -1,4 +1,6 @@
use bat::{assets::HighlightingAssets, config::Config, controller::Controller, Input};
use bat::{
assets::HighlightingAssets, config::Config, controller::Controller, output::OutputHandle, Input,
};
fn main() {
let mut buffer = String::new();
@ -10,7 +12,10 @@ fn main() {
let controller = Controller::new(&config, &assets);
let input = Input::from_file(file!());
controller
.run(vec![input.into()], Some(&mut buffer))
.run(
vec![input.into()],
Some(OutputHandle::FmtWrite(&mut buffer)),
)
.unwrap();
println!("{buffer}");

@ -370,7 +370,7 @@ mod tests {
pub temp_dir: TempDir,
}
impl<'a> SyntaxDetectionTest<'a> {
impl SyntaxDetectionTest<'_> {
fn new() -> Self {
SyntaxDetectionTest {
assets: HighlightingAssets::from_binary(),

@ -60,7 +60,7 @@ fn to_path_and_stem(source_dir: &Path, entry: DirEntry) -> Option<PathAndStem> {
fn handle_file(path_and_stem: &PathAndStem) -> Result<Option<String>> {
if path_and_stem.stem == "NOTICE" {
handle_notice(&path_and_stem.path)
} else if path_and_stem.stem.to_ascii_uppercase() == "LICENSE" {
} else if path_and_stem.stem.eq_ignore_ascii_case("LICENSE") {
handle_license(&path_and_stem.path)
} else {
Ok(None)

@ -124,7 +124,10 @@ impl App {
// If we have -pp as an option when in auto mode, the pager should be disabled.
if extra_plain || self.matches.get_flag("no-paging") {
PagingMode::Never
} else if inputs.iter().any(Input::is_stdin) {
} else if inputs.iter().any(Input::is_stdin)
// ignore stdin when --list-themes is used because in that case no input will be read anyways
&& !self.matches.get_flag("list-themes")
{
// If we are reading from stdin, only enable paging if we write to an
// interactive terminal and if we do not *read* from an interactive
// terminal.
@ -425,7 +428,7 @@ impl App {
None => StyleComponents(HashSet::from_iter(
StyleComponent::Default
.components(self.interactive_output)
.into_iter()
.iter()
.cloned(),
)),
};

@ -16,6 +16,7 @@ use std::io::{BufReader, Write};
use std::path::Path;
use std::process;
use bat::output::{OutputHandle, OutputType};
use bat::theme::DetectColorScheme;
use nu_ansi_term::Color::Green;
use nu_ansi_term::Style;
@ -205,12 +206,13 @@ pub fn list_themes(
config.language = Some("Rust");
config.style_components = StyleComponents(style);
let stdout = io::stdout();
let mut stdout = stdout.lock();
let mut output_type =
OutputType::from_mode(config.paging_mode, config.wrapping_mode, config.pager)?;
let mut writer = output_type.handle()?;
let default_theme_name = default_theme(color_scheme(detect_color_scheme).unwrap_or_default());
for theme in assets.themes() {
let default_theme_info = if !config.loop_through && default_theme_name == theme {
let default_theme_info = if default_theme_name == theme {
" (default)"
} else if default_theme(ColorScheme::Dark) == theme {
" (default dark)"
@ -221,24 +223,29 @@ pub fn list_themes(
};
if config.colored_output {
writeln!(
stdout,
writer,
"Theme: {}{}\n",
Style::new().bold().paint(theme.to_string()),
default_theme_info
)?;
config.theme = theme.to_string();
Controller::new(&config, &assets)
.run(vec![theme_preview_file()], None)
.run(
vec![theme_preview_file()],
Some(OutputHandle::IoWrite(&mut writer)),
)
.ok();
writeln!(stdout)?;
writeln!(writer)?;
} else if config.loop_through {
writeln!(writer, "{theme}")?;
} else {
writeln!(stdout, "{theme}{default_theme_info}")?;
writeln!(writer, "{theme}{default_theme_info}")?;
}
}
if config.colored_output {
writeln!(
stdout,
writer,
"Further themes can be installed to '{}', \
and are added to the cache with `bat cache --build`. \
For more information, see:\n\n \

@ -119,17 +119,25 @@ pub fn get_pager_executable(config_pager: Option<&str>) -> Option<String> {
#[test]
fn default_config_should_include_all_lines() {
use crate::line_range::MaxBufferedLineNumber;
use crate::line_range::RangeCheckResult;
assert_eq!(LineRanges::default().check(17), RangeCheckResult::InRange);
assert_eq!(
LineRanges::default().check(17, MaxBufferedLineNumber::Tentative(17)),
RangeCheckResult::InRange
);
}
#[test]
fn default_config_should_highlight_no_lines() {
use crate::line_range::MaxBufferedLineNumber;
use crate::line_range::RangeCheckResult;
assert_ne!(
Config::default().highlighted_lines.0.check(17),
Config::default()
.highlighted_lines
.0
.check(17, MaxBufferedLineNumber::Tentative(17)),
RangeCheckResult::InRange
);
}

@ -1,5 +1,3 @@
use std::io::{self, BufRead, Write};
use crate::assets::HighlightingAssets;
use crate::config::{Config, VisibleLines};
#[cfg(feature = "git")]
@ -10,11 +8,14 @@ use crate::input::{Input, InputReader, OpenedInput};
use crate::lessopen::LessOpenPreprocessor;
#[cfg(feature = "git")]
use crate::line_range::LineRange;
use crate::line_range::{LineRanges, RangeCheckResult};
use crate::output::OutputType;
use crate::line_range::{LineRanges, MaxBufferedLineNumber, RangeCheckResult};
use crate::output::{OutputHandle, OutputType};
#[cfg(feature = "paging")]
use crate::paging::PagingMode;
use crate::printer::{InteractivePrinter, OutputHandle, Printer, SimplePrinter};
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
use std::collections::VecDeque;
use std::io::{self, BufRead, Write};
use std::mem;
use clircle::{Clircle, Identifier};
@ -25,7 +26,7 @@ pub struct Controller<'a> {
preprocessor: Option<LessOpenPreprocessor>,
}
impl<'b> Controller<'b> {
impl Controller<'_> {
pub fn new<'a>(config: &'a Config, assets: &'a HighlightingAssets) -> Controller<'a> {
Controller {
config,
@ -35,18 +36,14 @@ impl<'b> Controller<'b> {
}
}
pub fn run(
&self,
inputs: Vec<Input>,
output_buffer: Option<&mut dyn std::fmt::Write>,
) -> Result<bool> {
self.run_with_error_handler(inputs, output_buffer, default_error_handler)
pub fn run(&self, inputs: Vec<Input>, output_handle: Option<OutputHandle<'_>>) -> Result<bool> {
self.run_with_error_handler(inputs, output_handle, default_error_handler)
}
pub fn run_with_error_handler(
&self,
inputs: Vec<Input>,
output_buffer: Option<&mut dyn std::fmt::Write>,
output_handle: Option<OutputHandle<'_>>,
mut handle_error: impl FnMut(&Error, &mut dyn Write),
) -> Result<bool> {
let mut output_type;
@ -88,8 +85,9 @@ impl<'b> Controller<'b> {
clircle::Identifier::stdout()
};
let mut writer = match output_buffer {
Some(buf) => OutputHandle::FmtWrite(buf),
let mut writer = match output_handle {
Some(OutputHandle::FmtWrite(w)) => OutputHandle::FmtWrite(w),
Some(OutputHandle::IoWrite(w)) => OutputHandle::IoWrite(w),
None => OutputHandle::IoWrite(output_type.handle()?),
};
let mut no_errors: bool = true;
@ -241,20 +239,63 @@ impl<'b> Controller<'b> {
reader: &mut InputReader,
line_ranges: &LineRanges,
) -> Result<()> {
let mut line_buffer = Vec::new();
let mut line_number: usize = 1;
let mut current_line_buffer: Vec<u8> = Vec::new();
let mut current_line_number: usize = 1;
// Buffer needs to be 1 greater than the offset to have a look-ahead line for EOF
let buffer_size: usize = line_ranges.largest_offset_from_end() + 1;
// Buffers multiple line data and line number
let mut buffered_lines: VecDeque<(Vec<u8>, usize)> = VecDeque::with_capacity(buffer_size);
let mut reached_eof: bool = false;
let mut first_range: bool = true;
let mut mid_range: bool = false;
let style_snip = self.config.style_components.snip();
while reader.read_line(&mut line_buffer)? {
match line_ranges.check(line_number) {
loop {
if reached_eof && buffered_lines.is_empty() {
// Done processing all lines
break;
}
if !reached_eof {
if reader.read_line(&mut current_line_buffer)? {
// Fill the buffer
buffered_lines
.push_back((mem::take(&mut current_line_buffer), current_line_number));
current_line_number += 1;
} else {
// No more data to read
reached_eof = true;
}
}
if buffered_lines.len() < buffer_size && !reached_eof {
// The buffer needs to be completely filled first
continue;
}
let Some((line, line_nr)) = buffered_lines.pop_front() else {
break;
};
// Determine if the last line number in the buffer is the last line of the file or
// just a line somewhere in the file
let max_buffered_line_number = buffered_lines
.back()
.map(|(_, max_line_number)| {
if reached_eof {
MaxBufferedLineNumber::Final(*max_line_number)
} else {
MaxBufferedLineNumber::Tentative(*max_line_number)
}
})
.unwrap_or(MaxBufferedLineNumber::Final(line_nr));
match line_ranges.check(line_nr, max_buffered_line_number) {
RangeCheckResult::BeforeOrBetweenRanges => {
// Call the printer in case we need to call the syntax highlighter
// for this line. However, set `out_of_range` to `true`.
printer.print_line(true, writer, line_number, &line_buffer)?;
printer.print_line(true, writer, line_nr, &line, max_buffered_line_number)?;
mid_range = false;
}
@ -269,15 +310,12 @@ impl<'b> Controller<'b> {
}
}
printer.print_line(false, writer, line_number, &line_buffer)?;
printer.print_line(false, writer, line_nr, &line, max_buffered_line_number)?;
}
RangeCheckResult::AfterLastRange => {
break;
}
}
line_number += 1;
line_buffer.clear();
}
Ok(())
}

@ -75,7 +75,7 @@ pub(crate) enum InputKind<'a> {
CustomReader(Box<dyn Read + 'a>),
}
impl<'a> InputKind<'a> {
impl InputKind<'_> {
pub fn description(&self) -> InputDescription {
match self {
InputKind::OrdinaryFile(ref path) => InputDescription::new(path.to_string_lossy()),

@ -1,5 +1,3 @@
#![cfg(feature = "lessopen")]
use std::convert::TryFrom;
use std::env;
use std::fs::File;
@ -200,7 +198,7 @@ impl LessOpenPreprocessor {
})
}
fn fall_back_to_original_file(&self, lessopen_stdout: &Vec<u8>, exit_code: ExitStatus) -> bool {
fn fall_back_to_original_file(&self, lessopen_stdout: &[u8], exit_code: ExitStatus) -> bool {
lessopen_stdout.is_empty()
&& (!exit_code.success() || matches!(self.kind, LessOpenKind::PipedIgnoreExitCode))
}

@ -38,7 +38,7 @@ mod less;
mod lessopen;
pub mod line_range;
pub(crate) mod nonprintable_notation;
mod output;
pub mod output;
#[cfg(feature = "paging")]
mod pager;
#[cfg(feature = "paging")]

@ -1,16 +1,26 @@
use crate::error::*;
use itertools::{Itertools, MinMaxResult};
#[derive(Debug, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct LineRange {
lower: usize,
upper: usize,
lower: RangeBound,
upper: RangeBound,
}
/// Defines a boundary for a range
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub(crate) enum RangeBound {
// An absolute line number marking the boundary of a range
Absolute(usize),
// A relative (implicitly negative) offset from the end of the file as a boundary
OffsetFromEnd(usize),
}
impl Default for LineRange {
fn default() -> LineRange {
LineRange {
lower: usize::min_value(),
upper: usize::max_value(),
lower: RangeBound::Absolute(usize::MIN),
upper: RangeBound::Absolute(usize::MAX),
}
}
}
@ -18,8 +28,8 @@ impl Default for LineRange {
impl LineRange {
pub fn new(from: usize, to: usize) -> Self {
LineRange {
lower: from,
upper: to,
lower: RangeBound::Absolute(from),
upper: RangeBound::Absolute(to),
}
}
@ -29,31 +39,47 @@ impl LineRange {
fn parse_range(range_raw: &str) -> Result<LineRange> {
let mut new_range = LineRange::default();
let mut raw_range_iter = range_raw.bytes();
let first_byte = raw_range_iter.next().ok_or("Empty line range")?;
if range_raw.bytes().next().ok_or("Empty line range")? == b':' {
new_range.upper = range_raw[1..].parse()?;
if first_byte == b':' {
if raw_range_iter.next() == Some(b'-') {
// E.g. ':-3'
let value = range_raw[2..].parse()?;
new_range.upper = RangeBound::OffsetFromEnd(value);
} else {
let value = range_raw[1..].parse()?;
new_range.upper = RangeBound::Absolute(value);
}
return Ok(new_range);
} else if range_raw.bytes().last().ok_or("Empty line range")? == b':' {
new_range.lower = range_raw[..range_raw.len() - 1].parse()?;
if first_byte == b'-' {
// E.g. '-3:'
let value = range_raw[1..range_raw.len() - 1].parse()?;
new_range.lower = RangeBound::OffsetFromEnd(value);
} else {
let value = range_raw[..range_raw.len() - 1].parse()?;
new_range.lower = RangeBound::Absolute(value);
}
return Ok(new_range);
}
let line_numbers: Vec<&str> = range_raw.split(':').collect();
match line_numbers.len() {
1 => {
new_range.lower = line_numbers[0].parse()?;
new_range.lower = RangeBound::Absolute(line_numbers[0].parse()?);
new_range.upper = new_range.lower;
Ok(new_range)
}
2 => {
new_range.lower = line_numbers[0].parse()?;
let mut lower_absolute_bound: usize = line_numbers[0].parse()?;
let first_byte = line_numbers[1].bytes().next();
new_range.upper = if first_byte == Some(b'+') {
let upper_absolute_bound = if first_byte == Some(b'+') {
let more_lines = &line_numbers[1][1..]
.parse()
.map_err(|_| "Invalid character after +")?;
new_range.lower.saturating_add(*more_lines)
lower_absolute_bound.saturating_add(*more_lines)
} else if first_byte == Some(b'-') {
// this will prevent values like "-+5" even though "+5" is valid integer
if line_numbers[1][1..].bytes().next() == Some(b'+') {
@ -62,13 +88,14 @@ impl LineRange {
let prior_lines = &line_numbers[1][1..]
.parse()
.map_err(|_| "Invalid character after -")?;
let prev_lower = new_range.lower;
new_range.lower = new_range.lower.saturating_sub(*prior_lines);
let prev_lower = lower_absolute_bound;
lower_absolute_bound = lower_absolute_bound.saturating_sub(*prior_lines);
prev_lower
} else {
line_numbers[1].parse()?
};
new_range.lower = RangeBound::Absolute(lower_absolute_bound);
new_range.upper = RangeBound::Absolute(upper_absolute_bound);
Ok(new_range)
}
_ => Err(
@ -78,37 +105,107 @@ impl LineRange {
}
}
pub(crate) fn is_inside(&self, line: usize) -> bool {
line >= self.lower && line <= self.upper
/// Checks if a line number is inside the range.
/// For ranges with relative offsets range bounds `max_buffered_line_number` is necessary
/// to convert the offset to an absolute value.
pub(crate) fn is_inside(
&self,
line: usize,
max_buffered_line_number: MaxBufferedLineNumber,
) -> bool {
match (self.lower, self.upper, max_buffered_line_number) {
(RangeBound::Absolute(lower), RangeBound::Absolute(upper), _) => {
lower <= line && line <= upper
}
(
RangeBound::Absolute(lower),
RangeBound::OffsetFromEnd(offset),
MaxBufferedLineNumber::Final(last_line_number),
) => lower <= line && line <= last_line_number.saturating_sub(offset),
(
RangeBound::Absolute(lower),
RangeBound::OffsetFromEnd(_),
MaxBufferedLineNumber::Tentative(_),
) => {
// We don't know the final line number yet, so the assumption is that the line is
// still far enough away from the upper end of the range
lower <= line
}
(
RangeBound::OffsetFromEnd(offset),
RangeBound::Absolute(upper),
MaxBufferedLineNumber::Final(last_line_number),
) => last_line_number.saturating_sub(offset) <= line && line <= upper,
(
RangeBound::OffsetFromEnd(_),
RangeBound::Absolute(_),
MaxBufferedLineNumber::Tentative(_),
) => {
// We don't know the final line number yet, so the assumption is that the line is
// still too far away from the having reached the lower end of the range
false
}
(
RangeBound::OffsetFromEnd(lower),
RangeBound::OffsetFromEnd(upper),
MaxBufferedLineNumber::Final(last_line_number),
) => {
last_line_number.saturating_sub(lower) <= line
&& line <= last_line_number.saturating_sub(upper)
}
(
RangeBound::OffsetFromEnd(_),
RangeBound::OffsetFromEnd(_),
MaxBufferedLineNumber::Tentative(_),
) => {
// We don't know the final line number yet, so the assumption is that we're still
// too far away from the having reached the lower end of the range
false
}
}
}
}
#[test]
fn test_parse_full() {
let range = LineRange::from("40:50").expect("Shouldn't fail on test!");
assert_eq!(40, range.lower);
assert_eq!(50, range.upper);
assert_eq!(RangeBound::Absolute(40), range.lower);
assert_eq!(RangeBound::Absolute(50), range.upper);
}
#[test]
fn test_parse_partial_min() {
let range = LineRange::from(":50").expect("Shouldn't fail on test!");
assert_eq!(usize::min_value(), range.lower);
assert_eq!(50, range.upper);
assert_eq!(RangeBound::Absolute(usize::MIN), range.lower);
assert_eq!(RangeBound::Absolute(50), range.upper);
}
#[test]
fn test_parse_partial_relative_negative_from_back() {
let range = LineRange::from(":-5").expect("Shouldn't fail on test!");
assert_eq!(RangeBound::Absolute(usize::MIN), range.lower);
assert_eq!(RangeBound::OffsetFromEnd(5), range.upper);
}
#[test]
fn test_parse_relative_negative_from_back_partial() {
let range = LineRange::from("-5:").expect("Shouldn't fail on test!");
assert_eq!(RangeBound::OffsetFromEnd(5), range.lower);
assert_eq!(RangeBound::Absolute(usize::MAX), range.upper);
}
#[test]
fn test_parse_partial_max() {
let range = LineRange::from("40:").expect("Shouldn't fail on test!");
assert_eq!(40, range.lower);
assert_eq!(usize::max_value(), range.upper);
assert_eq!(RangeBound::Absolute(40), range.lower);
assert_eq!(RangeBound::Absolute(usize::MAX), range.upper);
}
#[test]
fn test_parse_single() {
let range = LineRange::from("40").expect("Shouldn't fail on test!");
assert_eq!(40, range.lower);
assert_eq!(40, range.upper);
assert_eq!(RangeBound::Absolute(40), range.lower);
assert_eq!(RangeBound::Absolute(40), range.upper);
}
#[test]
@ -117,6 +214,8 @@ fn test_parse_fail() {
assert!(range.is_err());
let range = LineRange::from("40::80");
assert!(range.is_err());
let range = LineRange::from("-2:5");
assert!(range.is_err());
let range = LineRange::from(":40:");
assert!(range.is_err());
}
@ -124,15 +223,15 @@ fn test_parse_fail() {
#[test]
fn test_parse_plus() {
let range = LineRange::from("40:+10").expect("Shouldn't fail on test!");
assert_eq!(40, range.lower);
assert_eq!(50, range.upper);
assert_eq!(RangeBound::Absolute(40), range.lower);
assert_eq!(RangeBound::Absolute(50), range.upper);
}
#[test]
fn test_parse_plus_overflow() {
let range = LineRange::from(&format!("{}:+1", usize::MAX)).expect("Shouldn't fail on test!");
assert_eq!(usize::MAX, range.lower);
assert_eq!(usize::MAX, range.upper);
assert_eq!(RangeBound::Absolute(usize::MAX), range.lower);
assert_eq!(RangeBound::Absolute(usize::MAX), range.upper);
}
#[test]
@ -148,21 +247,21 @@ fn test_parse_plus_fail() {
#[test]
fn test_parse_minus_success() {
let range = LineRange::from("40:-10").expect("Shouldn't fail on test!");
assert_eq!(30, range.lower);
assert_eq!(40, range.upper);
assert_eq!(RangeBound::Absolute(30), range.lower);
assert_eq!(RangeBound::Absolute(40), range.upper);
}
#[test]
fn test_parse_minus_edge_cases_success() {
let range = LineRange::from("5:-4").expect("Shouldn't fail on test!");
assert_eq!(1, range.lower);
assert_eq!(5, range.upper);
assert_eq!(RangeBound::Absolute(1), range.lower);
assert_eq!(RangeBound::Absolute(5), range.upper);
let range = LineRange::from("5:-5").expect("Shouldn't fail on test!");
assert_eq!(0, range.lower);
assert_eq!(5, range.upper);
assert_eq!(RangeBound::Absolute(0), range.lower);
assert_eq!(RangeBound::Absolute(5), range.upper);
let range = LineRange::from("5:-100").expect("Shouldn't fail on test!");
assert_eq!(0, range.lower);
assert_eq!(5, range.upper);
assert_eq!(RangeBound::Absolute(0), range.lower);
assert_eq!(RangeBound::Absolute(5), range.upper);
}
#[test]
@ -187,10 +286,24 @@ pub enum RangeCheckResult {
AfterLastRange,
}
/// Represents the maximum line number in the buffer when reading a file.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub(crate) enum MaxBufferedLineNumber {
// The currently known maximum line number, may not be the final line number
Tentative(usize),
// The final line number, when EOF has been reached
Final(usize),
}
#[derive(Debug, Clone)]
pub struct LineRanges {
ranges: Vec<LineRange>,
largest_upper_bound: usize,
// The largest absolute upper line number of all ranges
largest_absolute_upper_bound: usize,
// The smallest relative offset from the end of all ranges
smallest_offset_from_end: usize,
// The largest relative offset from the end of all ranges
largest_offset_from_end: usize,
}
impl LineRanges {
@ -203,26 +316,62 @@ impl LineRanges {
}
pub fn from(ranges: Vec<LineRange>) -> LineRanges {
let largest_upper_bound = ranges
let largest_absolute_upper_bound = ranges
.iter()
.map(|r| r.upper)
.filter_map(|r| match r.upper {
RangeBound::Absolute(upper) => Some(upper),
_ => None,
})
.max()
.unwrap_or(usize::max_value());
.unwrap_or(usize::MAX);
let offsets_min_max = ranges
.iter()
.flat_map(|r| [r.lower, r.upper])
.filter_map(|r| match r {
RangeBound::OffsetFromEnd(offset) => Some(offset),
_ => None,
})
.minmax();
let (smallest_offset_from_end, largest_offset_from_end) = match offsets_min_max {
MinMaxResult::NoElements => (usize::MIN, usize::MIN),
MinMaxResult::OneElement(offset) => (offset, offset),
MinMaxResult::MinMax(min, max) => (min, max),
};
LineRanges {
ranges,
largest_upper_bound,
largest_absolute_upper_bound,
smallest_offset_from_end,
largest_offset_from_end,
}
}
pub(crate) fn check(&self, line: usize) -> RangeCheckResult {
if self.ranges.iter().any(|r| r.is_inside(line)) {
pub(crate) fn check(
&self,
line: usize,
max_buffered_line_number: MaxBufferedLineNumber,
) -> RangeCheckResult {
if self
.ranges
.iter()
.any(|r| r.is_inside(line, max_buffered_line_number))
{
RangeCheckResult::InRange
} else if line < self.largest_upper_bound {
} else if matches!(max_buffered_line_number, MaxBufferedLineNumber::Final(final_line_number) if line > final_line_number.saturating_sub(self.smallest_offset_from_end))
{
RangeCheckResult::AfterLastRange
} else if line < self.largest_absolute_upper_bound {
RangeCheckResult::BeforeOrBetweenRanges
} else {
RangeCheckResult::AfterLastRange
}
}
pub(crate) fn largest_offset_from_end(&self) -> usize {
self.largest_offset_from_end
}
}
impl Default for LineRanges {
@ -249,54 +398,292 @@ fn ranges(rs: &[&str]) -> LineRanges {
fn test_ranges_simple() {
let ranges = ranges(&["3:8"]);
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(2));
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(9));
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(2, MaxBufferedLineNumber::Tentative(2))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(5))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(9, MaxBufferedLineNumber::Tentative(9))
);
}
#[test]
fn test_ranges_advanced() {
let ranges = ranges(&["3:8", "11:20", "25:30"]);
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(2));
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(9));
assert_eq!(RangeCheckResult::InRange, ranges.check(11));
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(22));
assert_eq!(RangeCheckResult::InRange, ranges.check(28));
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(31));
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(2, MaxBufferedLineNumber::Tentative(2))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(5))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(9, MaxBufferedLineNumber::Tentative(9))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(11, MaxBufferedLineNumber::Tentative(11))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(22, MaxBufferedLineNumber::Tentative(22))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(28, MaxBufferedLineNumber::Tentative(28))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(31, MaxBufferedLineNumber::Tentative(31))
);
}
#[test]
fn test_ranges_open_low() {
let ranges = ranges(&["3:8", ":5"]);
assert_eq!(RangeCheckResult::InRange, ranges.check(1));
assert_eq!(RangeCheckResult::InRange, ranges.check(3));
assert_eq!(RangeCheckResult::InRange, ranges.check(7));
assert_eq!(RangeCheckResult::AfterLastRange, ranges.check(9));
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Tentative(3))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(7, MaxBufferedLineNumber::Tentative(7))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(9, MaxBufferedLineNumber::Tentative(9))
);
}
#[test]
fn test_ranges_open_high() {
let ranges = ranges(&["3:", "2:5"]);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
assert_eq!(RangeCheckResult::BeforeOrBetweenRanges, ranges.check(1));
assert_eq!(RangeCheckResult::InRange, ranges.check(3));
assert_eq!(RangeCheckResult::InRange, ranges.check(5));
assert_eq!(RangeCheckResult::InRange, ranges.check(9));
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(1, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(2, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(9, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(10, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Tentative(3))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(5))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(9, MaxBufferedLineNumber::Tentative(9))
);
}
#[test]
fn test_ranges_open_up_to_3_from_end() {
let ranges = ranges(&[":-3"]);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Tentative(3))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(8))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Final(6))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(2, MaxBufferedLineNumber::Final(6))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Final(6))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(4, MaxBufferedLineNumber::Final(6))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(5, MaxBufferedLineNumber::Final(6))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(6, MaxBufferedLineNumber::Final(6))
);
}
#[test]
fn test_ranges_multiple_negative_from_back() {
let ranges = ranges(&[":-3", ":-9"]);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Tentative(3))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(14))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Final(16))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(7, MaxBufferedLineNumber::Final(16))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(13, MaxBufferedLineNumber::Final(16))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(14, MaxBufferedLineNumber::Final(16))
);
assert_eq!(
RangeCheckResult::AfterLastRange,
ranges.check(16, MaxBufferedLineNumber::Final(16))
);
}
#[test]
fn test_ranges_3_from_back_up_to_end() {
let ranges = ranges(&["-3:"]);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(3, MaxBufferedLineNumber::Tentative(3))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(5, MaxBufferedLineNumber::Tentative(8))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(1, MaxBufferedLineNumber::Final(5))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(2, MaxBufferedLineNumber::Final(5))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(3, MaxBufferedLineNumber::Final(5))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(4, MaxBufferedLineNumber::Final(5))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Final(5))
);
}
#[test]
fn test_ranges_multiple_negative_offsets_to_end() {
let ranges = ranges(&["-3:", "-12:"]);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(5, MaxBufferedLineNumber::Tentative(8))
);
assert_eq!(
RangeCheckResult::BeforeOrBetweenRanges,
ranges.check(5, MaxBufferedLineNumber::Tentative(17))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(8, MaxBufferedLineNumber::Final(20))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(9, MaxBufferedLineNumber::Final(20))
);
}
#[test]
fn test_ranges_absolute_bound_and_offset() {
let ranges = ranges(&["5:", ":-2"]);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(4, MaxBufferedLineNumber::Tentative(6))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(5, MaxBufferedLineNumber::Tentative(7))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(8, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(9, MaxBufferedLineNumber::Final(10))
);
assert_eq!(
RangeCheckResult::InRange,
ranges.check(10, MaxBufferedLineNumber::Final(10))
);
}
#[test]
fn test_ranges_all() {
let ranges = LineRanges::all();
assert_eq!(RangeCheckResult::InRange, ranges.check(1));
assert_eq!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
}
#[test]
fn test_ranges_none() {
let ranges = LineRanges::none();
assert_ne!(RangeCheckResult::InRange, ranges.check(1));
assert_ne!(
RangeCheckResult::InRange,
ranges.check(1, MaxBufferedLineNumber::Tentative(1))
);
}

@ -1,3 +1,4 @@
use std::fmt;
use std::io::{self, Write};
#[cfg(feature = "paging")]
use std::process::Child;
@ -162,3 +163,17 @@ impl Drop for OutputType {
}
}
}
pub enum OutputHandle<'a> {
IoWrite(&'a mut dyn io::Write),
FmtWrite(&'a mut dyn fmt::Write),
}
impl OutputHandle<'_> {
pub fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> Result<()> {
match self {
Self::IoWrite(handle) => handle.write_fmt(args).map_err(Into::into),
Self::FmtWrite(handle) => handle.write_fmt(args).map_err(Into::into),
}
}
}

@ -10,6 +10,7 @@ use crate::{
error::Result,
input,
line_range::{HighlightedLineRanges, LineRange, LineRanges},
output::OutputHandle,
style::StyleComponent,
StripAnsiMode, SyntaxMapping, WrappingMode,
};
@ -325,7 +326,10 @@ impl<'a> PrettyPrinter<'a> {
// If writer is provided, pass it to the controller, otherwise pass None
if let Some(mut w) = writer {
controller.run(inputs.into_iter().map(|i| i.into()).collect(), Some(&mut w))
controller.run(
inputs.into_iter().map(|i| i.into()).collect(),
Some(OutputHandle::FmtWrite(&mut w)),
)
} else {
controller.run(inputs.into_iter().map(|i| i.into()).collect(), None)
}

@ -1,5 +1,3 @@
use std::fmt;
use std::io;
use std::vec::Vec;
use nu_ansi_term::Color::{Fixed, Green, Red, Yellow};
@ -17,6 +15,7 @@ use content_inspector::ContentType;
use encoding_rs::{UTF_16BE, UTF_16LE};
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthChar;
use crate::assets::{HighlightingAssets, SyntaxReferenceInSet};
@ -28,7 +27,8 @@ use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration}
use crate::diff::LineChanges;
use crate::error::*;
use crate::input::OpenedInput;
use crate::line_range::RangeCheckResult;
use crate::line_range::{MaxBufferedLineNumber, RangeCheckResult};
use crate::output::OutputHandle;
use crate::preprocessor::strip_ansi;
use crate::preprocessor::{expand_tabs, replace_nonprintable};
use crate::style::StyleComponent;
@ -68,20 +68,6 @@ const EMPTY_SYNTECT_STYLE: syntect::highlighting::Style = syntect::highlighting:
font_style: FontStyle::empty(),
};
pub enum OutputHandle<'a> {
IoWrite(&'a mut dyn io::Write),
FmtWrite(&'a mut dyn fmt::Write),
}
impl<'a> OutputHandle<'a> {
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> Result<()> {
match self {
Self::IoWrite(handle) => handle.write_fmt(args).map_err(Into::into),
Self::FmtWrite(handle) => handle.write_fmt(args).map_err(Into::into),
}
}
}
pub(crate) trait Printer {
fn print_header(
&mut self,
@ -99,6 +85,7 @@ pub(crate) trait Printer {
handle: &mut OutputHandle,
line_number: usize,
line_buffer: &[u8],
max_buffered_line_number: MaxBufferedLineNumber,
) -> Result<()>;
}
@ -116,7 +103,7 @@ impl<'a> SimplePrinter<'a> {
}
}
impl<'a> Printer for SimplePrinter<'a> {
impl Printer for SimplePrinter<'_> {
fn print_header(
&mut self,
_handle: &mut OutputHandle,
@ -140,11 +127,12 @@ impl<'a> Printer for SimplePrinter<'a> {
handle: &mut OutputHandle,
_line_number: usize,
line_buffer: &[u8],
_max_buffered_line_number: MaxBufferedLineNumber,
) -> Result<()> {
// Skip squeezed lines.
if let Some(squeeze_limit) = self.config.squeeze_lines {
if String::from_utf8_lossy(line_buffer)
.trim_end_matches(|c| c == '\r' || c == '\n')
.trim_end_matches(['\r', '\n'])
.is_empty()
{
self.consecutive_empty_lines += 1;
@ -267,7 +255,7 @@ impl<'a> InteractivePrinter<'a> {
let is_printing_binary = input
.reader
.content_type
.map_or(false, |c| c.is_binary() && !config.show_nonprintable);
.is_some_and(|c| c.is_binary() && !config.show_nonprintable);
let needs_to_match_syntax = (!is_printing_binary
|| matches!(config.binary, BinaryBehavior::AsText))
@ -403,14 +391,18 @@ impl<'a> InteractivePrinter<'a> {
handle: &mut OutputHandle,
content: &str,
) -> Result<()> {
let mut content = content;
let content_width = self.config.term_width - self.get_header_component_indent_length();
while content.len() > content_width {
let (content_line, remaining) = content.split_at(content_width);
self.print_header_component_with_indent(handle, content_line)?;
content = remaining;
if content.chars().count() <= content_width {
return self.print_header_component_with_indent(handle, content);
}
self.print_header_component_with_indent(handle, content)
let mut content_graphemes: Vec<&str> = content.graphemes(true).collect();
while content_graphemes.len() > content_width {
let (content_line, remaining) = content_graphemes.split_at(content_width);
self.print_header_component_with_indent(handle, content_line.join("").as_str())?;
content_graphemes = remaining.iter().cloned().collect();
}
self.print_header_component_with_indent(handle, content_graphemes.join("").as_str())
}
fn highlight_regions_for_line<'b>(
@ -432,7 +424,7 @@ impl<'a> InteractivePrinter<'a> {
.highlight_line(for_highlighting, highlighter_from_set.syntax_set)?;
if too_long {
highlighted_line[0].1 = &line;
highlighted_line[0].1 = line;
}
Ok(highlighted_line)
@ -448,7 +440,7 @@ impl<'a> InteractivePrinter<'a> {
}
}
impl<'a> Printer for InteractivePrinter<'a> {
impl Printer for InteractivePrinter<'_> {
fn print_header(
&mut self,
handle: &mut OutputHandle,
@ -544,7 +536,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
})?;
if self.config.style_components.grid() {
if self.content_type.map_or(false, |c| c.is_text())
if self.content_type.is_some_and(|c| c.is_text())
|| self.config.show_nonprintable
|| matches!(self.config.binary, BinaryBehavior::AsText)
{
@ -559,7 +551,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
fn print_footer(&mut self, handle: &mut OutputHandle, _input: &OpenedInput) -> Result<()> {
if self.config.style_components.grid()
&& (self.content_type.map_or(false, |c| c.is_text())
&& (self.content_type.is_some_and(|c| c.is_text())
|| self.config.show_nonprintable
|| matches!(self.config.binary, BinaryBehavior::AsText))
{
@ -599,6 +591,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
handle: &mut OutputHandle,
line_number: usize,
line_buffer: &[u8],
max_buffered_line_number: MaxBufferedLineNumber,
) -> Result<()> {
let line = if self.config.show_nonprintable {
replace_nonprintable(
@ -644,7 +637,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
// Skip squeezed lines.
if let Some(squeeze_limit) = self.config.squeeze_lines {
if line.trim_end_matches(|c| c == '\r' || c == '\n').is_empty() {
if line.trim_end_matches(['\r', '\n']).is_empty() {
self.consecutive_empty_lines += 1;
if self.consecutive_empty_lines > squeeze_limit {
return Ok(());
@ -660,8 +653,12 @@ impl<'a> Printer for InteractivePrinter<'a> {
let mut panel_wrap: Option<String> = None;
// Line highlighting
let highlight_this_line =
self.config.highlighted_lines.0.check(line_number) == RangeCheckResult::InRange;
let highlight_this_line = self
.config
.highlighted_lines
.0
.check(line_number, max_buffered_line_number)
== RangeCheckResult::InRange;
if highlight_this_line && self.config.theme == "ansi" {
self.ansi_style.update(ANSI_UNDERLINE_ENABLE);
@ -697,7 +694,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
// Regular text.
EscapeSequence::Text(text) => {
let text = self.preprocess(text, &mut cursor_total);
let text_trimmed = text.trim_end_matches(|c| c == '\r' || c == '\n');
let text_trimmed = text.trim_end_matches(['\r', '\n']);
write!(
handle,
@ -751,10 +748,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
match chunk {
// Regular text.
EscapeSequence::Text(text) => {
let text = self.preprocess(
text.trim_end_matches(|c| c == '\r' || c == '\n'),
&mut cursor_total,
);
let text = self
.preprocess(text.trim_end_matches(['\r', '\n']), &mut cursor_total);
let mut max_width = cursor_max - cursor;

@ -225,7 +225,7 @@ impl FromStr for StyleComponentList {
fn from_str(s: &str) -> Result<Self> {
Ok(StyleComponentList(
s.split(",")
.map(|s| ComponentAction::extract_from_str(s)) // If the component starts with "-", it's meant to be removed
.map(ComponentAction::extract_from_str) // If the component starts with "-", it's meant to be removed
.map(|(a, s)| Ok((a, StyleComponent::from_str(s)?)))
.collect::<Result<Vec<(ComponentAction, StyleComponent)>>>()?,
))

@ -61,7 +61,7 @@ pub struct SyntaxMapping<'a> {
halt_glob_build: Arc<AtomicBool>,
}
impl<'a> Drop for SyntaxMapping<'a> {
impl Drop for SyntaxMapping<'_> {
fn drop(&mut self) {
// signal the offload thread to halt early
self.halt_glob_build.store(true, Ordering::Relaxed);
@ -153,7 +153,7 @@ impl<'a> SyntaxMapping<'a> {
if glob.is_match_candidate(&candidate)
|| candidate_filename
.as_ref()
.map_or(false, |filename| glob.is_match_candidate(filename))
.is_some_and(|filename| glob.is_match_candidate(filename))
{
return Some(*syntax);
}

@ -0,0 +1,2 @@
[mappings]
"XML" = ["*.csproj", "*.vbproj", "*.props", "*.targets"]

@ -1,3 +1,3 @@
# JSON Lines is a simple variation of JSON #2535
[mappings]
"JSON" = ["*.jsonl", "*.jsonc", "*.jsonld", "*.geojson"]
"JSON" = ["*.jsonl", "*.jsonc", "*.jsonld", "*.geojson", "*.ndjson"]

@ -0,0 +1,2 @@
[mappings]
"JSON" = ["flake.lock"]

@ -0,0 +1,6 @@
# See https://github.com/Morganamilo/paru/blob/master/man/paru.conf.5
[mappings]
"INI" = [
"${PARU_CONF}",
"paru.conf",
]

@ -2,4 +2,24 @@
"Bourne Again Shell (bash)" = [
# used by lots of shells
"/etc/profile",
"bashrc",
"*.bashrc",
"bash_profile",
"*.bash_profile",
"bash_login",
"*.bash_login",
"bash_logout",
"*.bash_logout",
"zshrc",
"*.zshrc",
"zprofile",
"*.zprofile",
"zlogin",
"*.zlogin",
"zlogout",
"*.zlogout",
"zshenv",
"*.zshenv"
]

@ -10,9 +10,9 @@ pub mod env {
/// See [`crate::theme::ThemeOptions::theme`].
pub const BAT_THEME: &str = "BAT_THEME";
/// See [`crate::theme::ThemeOptions::theme_dark`].
pub const BAT_THEME_DARK: &str = "BAT_THEME";
pub const BAT_THEME_DARK: &str = "BAT_THEME_DARK";
/// See [`crate::theme::ThemeOptions::theme_light`].
pub const BAT_THEME_LIGHT: &str = "BAT_THEME";
pub const BAT_THEME_LIGHT: &str = "BAT_THEME_LIGHT";
}
/// Chooses an appropriate theme or falls back to a default theme
@ -383,7 +383,6 @@ mod tests {
theme: ThemePreference::Fixed(ThemeName::Named("Theme".to_string())),
theme_dark: Some(ThemeName::Named("Dark Theme".to_string())),
theme_light: Some(ThemeName::Named("Light Theme".to_string())),
..Default::default()
},
] {
let detector = ConstantDetector(color_scheme);
@ -509,7 +508,7 @@ mod tests {
ThemePreference::Light,
];
for pref in prefs {
assert_eq!(pref, ThemePreference::new(&pref.to_string()));
assert_eq!(pref, ThemePreference::new(pref.to_string()));
}
}
}

@ -360,10 +360,10 @@ pub struct EscapeSequenceOffsetsIterator<'a> {
impl<'a> EscapeSequenceOffsetsIterator<'a> {
pub fn new(text: &'a str) -> EscapeSequenceOffsetsIterator<'a> {
return EscapeSequenceOffsetsIterator {
EscapeSequenceOffsetsIterator {
text,
chars: text.char_indices().peekable(),
};
}
}
/// Takes values from the iterator while the predicate returns true.
@ -539,7 +539,7 @@ impl<'a> EscapeSequenceOffsetsIterator<'a> {
}
}
impl<'a> Iterator for EscapeSequenceOffsetsIterator<'a> {
impl Iterator for EscapeSequenceOffsetsIterator<'_> {
type Item = EscapeSequenceOffsets;
fn next(&mut self) -> Option<Self::Item> {
match self.chars.peek() {
@ -564,10 +564,10 @@ pub struct EscapeSequenceIterator<'a> {
impl<'a> EscapeSequenceIterator<'a> {
pub fn new(text: &'a str) -> EscapeSequenceIterator<'a> {
return EscapeSequenceIterator {
EscapeSequenceIterator {
text,
offset_iter: EscapeSequenceOffsetsIterator::new(text),
};
}
}
}

0
tests/examples/test.A—B가 vendored Normal file

@ -35,13 +35,7 @@ fn all_jobs_not_missing_any_jobs() {
.as_mapping()
.unwrap()
.keys()
.filter_map(|k| {
if exceptions.contains(&k.as_str().unwrap_or_default()) {
None
} else {
Some(k)
}
})
.filter(|k| !exceptions.contains(&k.as_str().unwrap_or_default()))
.map(ToOwned::to_owned)
.collect::<Vec<_>>();

@ -176,6 +176,46 @@ fn line_range_2_3() {
.stdout("line 2\nline 3\n");
}
#[test]
fn line_range_up_to_2_from_back() {
bat()
.arg("multiline.txt")
.arg("--line-range=:-2")
.assert()
.success()
.stdout("line 1\nline 2\n");
}
#[test]
fn line_range_up_to_2_from_back_single_line_is_empty() {
bat()
.arg("single-line.txt")
.arg("--line-range=:-2")
.assert()
.success()
.stdout("");
}
#[test]
fn line_range_from_back_last_two() {
bat()
.arg("multiline.txt")
.arg("--line-range=-2:")
.assert()
.success()
.stdout("line 3\nline 4\n");
}
#[test]
fn line_range_from_back_last_two_single_line() {
bat()
.arg("single-line.txt")
.arg("--line-range=-2:")
.assert()
.success()
.stdout("Single Line");
}
#[test]
fn line_range_first_two() {
bat()
@ -305,11 +345,12 @@ fn list_themes_without_colors() {
#[test]
fn list_themes_to_piped_output() {
bat()
.arg("--list-themes")
.assert()
.success()
.stdout(predicate::str::contains("(default)").not());
bat().arg("--list-themes").assert().success().stdout(
predicate::str::contains("(default)")
.not()
.and(predicate::str::contains("(default light)").not())
.and(predicate::str::contains("(default dark)").not()),
);
}
#[test]
@ -1599,6 +1640,17 @@ oken
.stderr("");
}
#[test]
fn header_narrow_terminal_with_multibyte_chars() {
bat()
.arg("--terminal-width=30")
.arg("--decorations=always")
.arg("test.A—B가")
.assert()
.success()
.stderr("");
}
#[test]
#[cfg(feature = "git")] // Expected output assumes git is enabled
fn header_default() {
@ -1831,7 +1883,7 @@ fn do_not_panic_regression_tests() {
] {
bat()
.arg("--color=always")
.arg(&format!("regression_tests/{filename}"))
.arg(format!("regression_tests/{filename}"))
.assert()
.success();
}
@ -1844,7 +1896,7 @@ fn do_not_detect_different_syntax_for_stdin_and_files() {
let cmd_for_file = bat()
.arg("--color=always")
.arg("--map-syntax=*.js:Markdown")
.arg(&format!("--file-name={file}"))
.arg(format!("--file-name={file}"))
.arg("--style=plain")
.arg(file)
.assert()
@ -1854,7 +1906,7 @@ fn do_not_detect_different_syntax_for_stdin_and_files() {
.arg("--color=always")
.arg("--map-syntax=*.js:Markdown")
.arg("--style=plain")
.arg(&format!("--file-name={file}"))
.arg(format!("--file-name={file}"))
.pipe_stdin(Path::new(EXAMPLES_DIR).join(file))
.unwrap()
.assert()
@ -1873,7 +1925,7 @@ fn no_first_line_fallback_when_mapping_to_invalid_syntax() {
bat()
.arg("--color=always")
.arg("--map-syntax=*.invalid-syntax:InvalidSyntax")
.arg(&format!("--file-name={file}"))
.arg(format!("--file-name={file}"))
.arg("--style=plain")
.arg(file)
.assert()
@ -2265,6 +2317,46 @@ fn theme_arg_overrides_env_withconfig() {
.stderr("");
}
#[test]
fn theme_light_env_var_is_respected() {
bat()
.env("BAT_THEME_LIGHT", "Coldark-Cold")
.env("COLORTERM", "truecolor")
.arg("--theme=light")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Lorem Ipsum")
.assert()
.success()
.stdout("\x1B[48;2;208;218;231mLorem Ipsum\x1B[0m")
.stderr("");
}
#[test]
fn theme_dark_env_var_is_respected() {
bat()
.env("BAT_THEME_DARK", "Coldark-Dark")
.env("COLORTERM", "truecolor")
.arg("--theme=dark")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Lorem Ipsum")
.assert()
.success()
.stdout("\x1B[48;2;33;48;67mLorem Ipsum\x1B[0m")
.stderr("");
}
#[test]
fn theme_env_overrides_config() {
bat_with_config()

@ -12,13 +12,15 @@ def compare_highlighted_versions(root_old, root_new):
print(" -", root_old)
print(" -", root_new)
has_changes = False
# Used to check for newly added files that don't have a test
unknown_files = {strip_root(p) for p in glob.glob(path.join(root_new, "*", "*"))}
for path_old in glob.glob(path.join(root_old, "*", "*")):
filename = path.basename(path_old)
dirname = path.basename(path.dirname(path_old))
rel_path = strip_root(path_old)
unknown_files.discard(rel_path)
path_new = path.join(root_new, rel_path)
path_new = path.join(root_new, dirname, filename)
print("\n========== {}/{}".format(dirname, filename))
print("\n========== {}".format(rel_path))
with open(path_old) as file_old:
lines_old = file_old.readlines()
@ -39,11 +41,21 @@ def compare_highlighted_versions(root_old, root_new):
has_changes = True
else:
print("No changes")
print()
for f in unknown_files:
print("\n========== {}: No fixture for this language, run update.sh".format(f))
has_changes = True
print()
return has_changes
def strip_root(p: str) -> str:
filename = path.basename(p)
dirname = path.basename(path.dirname(p))
return path.join(dirname, filename)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="This script compares two directories that were created "

@ -0,0 +1,3 @@
foo,bar,baz,this|that,test,colors,cycle
1.2,1.7,2.5,blah;cool,test,colors,cycle
1 foo bar baz this|that test colors cycle
2 1.2 1.7 2.5 blah;cool test colors cycle

@ -1,7 +1,7 @@
first,last,address,city,zip
John,Doe,120 any st.,"Anytown, WW",08123
a,b
1,"ha 
first,last,address,city,zip
John,Doe,120 any st.,"Anytown, WW",08123
a,b
1,"ha 
""ha"" 
ha",120 any st.,"Anytown, WW",08123
3,4,120 any st.,"Anytown, WW",08123
ha",120 any st.,"Anytown, WW",08123
3,4,120 any st.,"Anytown, WW",08123

Can't render this file because it contains an unexpected character in line 2 and column 177.

@ -0,0 +1,3 @@
foo|bar|baz
1,2|1,7|2,7
1,5|8,5|-5,5
1 [3 38 2 253 151 31mfoo[38 2 253 151 31m|[38 2 102 217 239mbar[38 2 253 151 31m|[38 2 190 132 255mbaz
2 [3 38 2 253 151 31m1,2[38 2 253 151 31m|[38 2 102 217 239m1,7[38 2 253 151 31m|[38 2 190 132 255m2,7
3 [3 38 2 253 151 31m1,5[38 2 253 151 31m|[38 2 102 217 239m8,5[38 2 253 151 31m|[38 2 190 132 255m-5,5

@ -0,0 +1,3 @@
foo;bar;baz
1,2;1,7;2,7
1,5;8,5;-5,5
1 [3 38 2 253 151 31mfoo[38 2 253 151 31m [38 2 102 217 239mbar[38 2 253 151 31m [38 2 190 132 255mbaz
2 [3 38 2 253 151 31m1,2[38 2 253 151 31m [38 2 102 217 239m1,7[38 2 253 151 31m [38 2 190 132 255m2,7
3 [3 38 2 253 151 31m1,5[38 2 253 151 31m [38 2 102 217 239m8,5[38 2 253 151 31m [38 2 190 132 255m-5,5

@ -0,0 +1,3 @@
foo bar baz|;, test hello world tsv
1,2 1,7 2,7 a b c "hello again" tsv
";|," ;|, baz test "hello world" tsv
Can't render this file because it contains an unexpected character in line 2 and column 218.

@ -0,0 +1,71 @@
extends Node
signal custom_signal(param)
const PI = 3.14159
var untyped_var = "Hello, World!"
var typed_int: int = 42
var typed_float: float = 3.14
var typed_string: String = "GDScript Test"
var typed_array: Array = [1, 2, 3, 4]
var typed_dict: Dictionary = {"key": "value", "number": 100}
onready var label = $Label
func say_hello() -> void:
 print("Hello from GDScript!")
func add_numbers(a: int, b: int = 10) -> int:
 return a + b
func process_value(value: int) -> String:
 if value < 0:
 return "Negative"
 elif value == 0:
 return "Zero"
 else:
 return "Positive"
func sum_array(arr: Array) -> int:
 var total: int = 0
 for num in arr:
 total += num
 return total
func describe_number(num: int) -> String:
 match num:
 0:
 return "Zero"
 1, 2, 3:
 return "Small number"
 _:
 return "Large number"
func long_description() -> String:
 return """This is a test file for GDScript.
It covers variables, functions, control structures, loops, signals, inner classes,
multiline strings, arrays, and dictionaries."""
class InnerExample:
 var inner_value: int = 99
 func show_value() -> void:
 print("Inner value is:", inner_value)
func test_inner_class() -> void:
 var inner = InnerExample.new()
 inner.show_value()
func trigger_signal() -> void:
 emit_signal("custom_signal", "TestParam")
func _ready() -> void:
 say_hello()
 var result_add = add_numbers(5)
 print("Add result:", result_add)
 print("Process value for -5:", process_value(-5))
 print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30]))
 print("Description for 2:", describe_number(2))
 print("Long description:\n", long_description())
 test_inner_class()
 trigger_signal()

@ -0,0 +1,107 @@
-- some code in Idris
module XX.X'''
import Data.Nat
data X = A | B
namespace X
 ||| Documentation
 record Y where
 [noHints]
 constructor MkY'
 field1 : Nat
 {auto x : Nat}
namespace X' {
 parameters (x : A (Maybe b))
 x : Nat
}
u : ()
u = ()
k, w, u : Char
k = '\NUL'
w = 'w'
x = [1, 0, 3, "sdf\{d}", 0xFF, 0o77, 0b10_1, 100_100]
f : Int -> Int
f = if x > 0 then x else 0 () SS `elem` S $ do
 x <- a [1, 2, 3]
 let ukuk = akak
 rewrite $ Wow Wow Wow Wow.Wow b W (W)
 pure $ f A B c D (EE) E
(&&&) : Nat -> Nat -> Nat
z &&& y = d + ?foo
(&&&) x y = ?asfda
public export covering
(.fun) : X a Y b => Nat -> Nat
Z .fun = haha.fun haha .N
(.fun) Z = ahah $ \case
 x@(x, y) => Prelude.Types.ahahah
(.N) : Nat -> Nat
Z .N = Z
(.N) (S n) = (.N) n
xx : Name
xx = `{Full.Name}
infixr 0 ^^^, &&&
xxx : ?
xxx = case x of
 Z => lalalaCamelCase
 z => alalalCamelCase
ff : Nat -> TTImp
ff 0 = let x = 0 in val
ff _ = `(let x = 0 in ~val ^~^ ~(abc))
ff _ = f `(let x = 0 in ~val ^~^ ~(abc)) x
%language ElabReflection
%runElab X.sf ads
%macro %inline
fff : List Decl
fff = `[
 f : Nat -> Nat
 f Z = haha %runElab %search @{%World}
]
private infixr 4 ^--^
(^--^) : Nat -> Nat -> Nat
(^--^) Z Z = Z
x ^--^ y = x + y
x : (y : Vect n (Maybe (Maybe (&&&) Nat))) ->
 {x : Nat} -> {auto _ : Monoid a} ->
 {default 4 xx : Nat} ->
 {default (f x Y) xx' : Nat} ->
 String
x Z S = ?foo
x y _ = "a b \{show $ let x = 0 in y} y >>= z"
multiline : String
multiline = """
 A multiline string\NUL
 """
f' : Nat -> Nat
f' = x' 4
x : Char
x = '\BEL'
x = '\\'
x = '\''
x = '\o755'
x = 'a'
xx : Int
xx = 0o7_5_5

@ -0,0 +1,3 @@
{"some":"thing"}
{"foo":17,"bar":false,"quux":true}
{"may":{"include":"nested","objects":["and","arrays"]}}

@ -1,3 +1,3 @@
2021-03-06 23:22:21.392 https://[2001:db8:4006:812::200e]:8080/path/the%20page.html
2021-03-06 23:22:21 https://example.com:8080/path/the%20page(with_parens).html
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }

@ -0,0 +1,27 @@
package main
import "core:fmt"
import "core:math"
Vector :: struct {
 components: []f64,
}
euclidean_distance :: proc(v1: Vector, v2: Vector) -> f64 {
 if len(v1.components) != len(v2.components) {
 panic("Vectors must be same dimension")
 }
 sum: f64 = 0.0;
 for i, comp in v1.components {
 diff := comp - v2.components[i];
 sum += diff * diff;
 }
 return math.sqrt(sum);
}
main :: proc() {
 v1: Vector = Vector{components = []f64{1.0, 2.0, 3.0}};
 v2: Vector = Vector{components = []f64{4.0, 6.0, 8.0}};
 dist: f64 = euclidean_distance(v1, v2);
 fmt.println("Distance:", dist);
}

@ -1,16 +1,17 @@
Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded.
Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files.
Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available
Apr 4 00:00:21 hostname-here kernel: [55604.908232] audit: type=1400 audit(1617483621.094:28): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=59311 comm="cups-browsed" capability=23 capname="sys_nice"
Apr 4 00:01:38 hostname-here systemd-resolved[721]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37
Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 -> <null>
Apr 4 00:06:29 hostname-here ntpd[952]: receive: Unexpected origin timestamp 0xe414a8d1.82e825f5 does not match aorg 0xe414a8d5.82c50d8c from server@127.0.0.1 xmt 0xe414a8d1.e671d7c4
Apr 4 09:30:01 hostname-here CRON[89278]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Apr 4 16:32:07 hostname-here NetworkManager[740]: <info> [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL
Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid'
Aug 11 13:29:06 hostname-here insomnia_insomnia.desktop[142666]: 13:29:06.316 [updater] Updater not running platform=linux dev=false
Aug 11 13:36:34 192.168.220.5 nginx: 2021/08/11 13:36:34 [debug] 2031#2031: epoll add event: fd:6 op:1 ev:00002001
Aug 11 21:31:08 ::1 nginx: 2021/08/11 21:31:08 [debug] 760831#760831: epoll add event: fd:6 op:1 ev:10000001
Aug 11 21:40:31 hostname-here scop hello
Aug 16 21:38:21 hostname-here systemd[1]: Finished Cleanup of Temporary Directories.
Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded.
Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files.
Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available
Apr 4 00:00:21 hostname-here kernel: [55604.908232] audit: type=1400 audit(1617483621.094:28): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=59311 comm="cups-browsed" capability=23 capname="sys_nice"
Apr 4 00:01:38 hostname-here systemd-resolved[721]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37
Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 -> <null>
Apr 4 00:06:29 hostname-here ntpd[952]: receive: Unexpected origin timestamp 0xe414a8d1.82e825f5 does not match aorg 0xe414a8d5.82c50d8c from server@127.0.0.1 xmt 0xe414a8d1.e671d7c4
Apr 4 09:30:01 hostname-here CRON[89278]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Apr 4 16:32:07 hostname-here NetworkManager[740]: <info> [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL
Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid'
Aug 11 13:29:06 hostname-here insomnia_insomnia.desktop[142666]: 13:29:06.316 [updater] Updater not running platform=linux dev=false
Aug 11 13:36:34 192.168.220.5 nginx: 2021/08/11 13:36:34 [debug] 2031#2031: epoll add event: fd:6 op:1 ev:00002001
Aug 11 21:31:08 ::1 nginx: 2021/08/11 21:31:08 [debug] 760831#760831: epoll add event: fd:6 op:1 ev:10000001
Aug 11 21:40:31 hostname-here scop hello
Aug 16 21:38:21 hostname-here systemd[1]: Finished Cleanup of Temporary Directories.
2025-02-08 20:52:11.039 - setfont: ERROR kdfontop.c:183 put_font_kdfontop: Unable to load such font with such kernel version

@ -0,0 +1,5 @@
<Project>
 <PropertyGroup>
 <OutDir>C:\output\$(MSBuildProjectName)</OutDir>
 </PropertyGroup>
</Project>

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <OutputType>Exe</OutputType>
 <TargetFramework>net9.0</TargetFramework>
 <RootNamespace>SomeNamespace</RootNamespace>
 <ImplicitUsings>enable</ImplicitUsings>
 <Nullable>enable</Nullable>
 </PropertyGroup>
</Project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Target Name="TestTarget" AfterTargets="Build">
 <Message Importance="High" Text="-------------MHM----------------" />
 </Target>
</Project>

@ -0,0 +1,15 @@
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://deb.debian.org/debian bookworm main non-free-firmware
#deb-src https://deb.debian.org/debian bookworm main non-free-firmware
## Major bug fix updates produced after the final release of the
## distribution.
# deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb https://security.debian.org/debian-security bookworm-security main non-free-firmware
deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware
deb https://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware

@ -0,0 +1,3 @@
foo,bar,baz,this|that,test,colors,cycle
1.2,1.7,2.5,blah;cool,test,colors,cycle
1 foo bar baz this|that test colors cycle
2 1.2 1.7 2.5 blah;cool test colors cycle

@ -0,0 +1,3 @@
foo|bar|baz
1,2|1,7|2,7
1,5|8,5|-5,5
1 foo bar baz
2 1,2 1,7 2,7
3 1,5 8,5 -5,5

@ -0,0 +1,3 @@
foo;bar;baz
1,2;1,7;2,7
1,5;8,5;-5,5
1 foo bar baz
2 1,2 1,7 2,7
3 1,5 8,5 -5,5

@ -0,0 +1,3 @@
foo bar baz|;, test hello world tsv
1,2 1,7 2,7 a b c "hello again" tsv
";|," ;|, baz test "hello world" tsv
1 foo bar baz|;, test hello world tsv
2 1,2 1,7 2,7 a b c hello again tsv
3 ;|, ;|, baz test hello world tsv

@ -0,0 +1,71 @@
extends Node
signal custom_signal(param)
const PI = 3.14159
var untyped_var = "Hello, World!"
var typed_int: int = 42
var typed_float: float = 3.14
var typed_string: String = "GDScript Test"
var typed_array: Array = [1, 2, 3, 4]
var typed_dict: Dictionary = {"key": "value", "number": 100}
onready var label = $Label
func say_hello() -> void:
print("Hello from GDScript!")
func add_numbers(a: int, b: int = 10) -> int:
return a + b
func process_value(value: int) -> String:
if value < 0:
return "Negative"
elif value == 0:
return "Zero"
else:
return "Positive"
func sum_array(arr: Array) -> int:
var total: int = 0
for num in arr:
total += num
return total
func describe_number(num: int) -> String:
match num:
0:
return "Zero"
1, 2, 3:
return "Small number"
_:
return "Large number"
func long_description() -> String:
return """This is a test file for GDScript.
It covers variables, functions, control structures, loops, signals, inner classes,
multiline strings, arrays, and dictionaries."""
class InnerExample:
var inner_value: int = 99
func show_value() -> void:
print("Inner value is:", inner_value)
func test_inner_class() -> void:
var inner = InnerExample.new()
inner.show_value()
func trigger_signal() -> void:
emit_signal("custom_signal", "TestParam")
func _ready() -> void:
say_hello()
var result_add = add_numbers(5)
print("Add result:", result_add)
print("Process value for -5:", process_value(-5))
print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30]))
print("Description for 2:", describe_number(2))
print("Long description:\n", long_description())
test_inner_class()
trigger_signal()

@ -0,0 +1,7 @@
The `test.idr` file has been added from https://github.com/buzden/sublime-syntax-idris2 under the following license:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

@ -0,0 +1,107 @@
-- some code in Idris
module XX.X'''
import Data.Nat
data X = A | B
namespace X
||| Documentation
record Y where
[noHints]
constructor MkY'
field1 : Nat
{auto x : Nat}
namespace X' {
parameters (x : A (Maybe b))
x : Nat
}
u : ()
u = ()
k, w, u : Char
k = '\NUL'
w = 'w'
x = [1, 0, 3, "sdf\{d}", 0xFF, 0o77, 0b10_1, 100_100]
f : Int -> Int
f = if x > 0 then x else 0 () SS `elem` S $ do
x <- a [1, 2, 3]
let ukuk = akak
rewrite $ Wow Wow Wow Wow.Wow b W (W)
pure $ f A B c D (EE) E
(&&&) : Nat -> Nat -> Nat
z &&& y = d + ?foo
(&&&) x y = ?asfda
public export covering
(.fun) : X a Y b => Nat -> Nat
Z .fun = haha.fun haha .N
(.fun) Z = ahah $ \case
x@(x, y) => Prelude.Types.ahahah
(.N) : Nat -> Nat
Z .N = Z
(.N) (S n) = (.N) n
xx : Name
xx = `{Full.Name}
infixr 0 ^^^, &&&
xxx : ?
xxx = case x of
Z => lalalaCamelCase
z => alalalCamelCase
ff : Nat -> TTImp
ff 0 = let x = 0 in val
ff _ = `(let x = 0 in ~val ^~^ ~(abc))
ff _ = f `(let x = 0 in ~val ^~^ ~(abc)) x
%language ElabReflection
%runElab X.sf ads
%macro %inline
fff : List Decl
fff = `[
f : Nat -> Nat
f Z = haha %runElab %search @{%World}
]
private infixr 4 ^--^
(^--^) : Nat -> Nat -> Nat
(^--^) Z Z = Z
x ^--^ y = x + y
x : (y : Vect n (Maybe (Maybe (&&&) Nat))) ->
{x : Nat} -> {auto _ : Monoid a} ->
{default 4 xx : Nat} ->
{default (f x Y) xx' : Nat} ->
String
x Z S = ?foo
x y _ = "a b \{show $ let x = 0 in y} y >>= z"
multiline : String
multiline = """
A multiline string\NUL
"""
f' : Nat -> Nat
f' = x' 4
x : Char
x = '\BEL'
x = '\\'
x = '\''
x = '\o755'
x = 'a'
xx : Int
xx = 0o7_5_5

@ -0,0 +1,3 @@
{"some":"thing"}
{"foo":17,"bar":false,"quux":true}
{"may":{"include":"nested","objects":["and","arrays"]}}

@ -0,0 +1,27 @@
package main
import "core:fmt"
import "core:math"
Vector :: struct {
components: []f64,
}
euclidean_distance :: proc(v1: Vector, v2: Vector) -> f64 {
if len(v1.components) != len(v2.components) {
panic("Vectors must be same dimension")
}
sum: f64 = 0.0;
for i, comp in v1.components {
diff := comp - v2.components[i];
sum += diff * diff;
}
return math.sqrt(sum);
}
main :: proc() {
v1: Vector = Vector{components = []f64{1.0, 2.0, 3.0}};
v2: Vector = Vector{components = []f64{4.0, 6.0, 8.0}};
dist: f64 = euclidean_distance(v1, v2);
fmt.println("Distance:", dist);
}

@ -14,3 +14,4 @@ Aug 11 13:36:34 192.168.220.5 nginx: 2021/08/11 13:36:34 [debug] 2031#2031: epol
Aug 11 21:31:08 ::1 nginx: 2021/08/11 21:31:08 [debug] 760831#760831: epoll add event: fd:6 op:1 ev:10000001
Aug 11 21:40:31 hostname-here scop hello
Aug 16 21:38:21 hostname-here systemd[1]: Finished Cleanup of Temporary Directories.
2025-02-08 20:52:11.039 - setfont: ERROR kdfontop.c:183 put_font_kdfontop: Unable to load such font with such kernel version

@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<OutDir>C:\output\$(MSBuildProjectName)</OutDir>
</PropertyGroup>
</Project>

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>SomeNamespace</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="TestTarget" AfterTargets="Build">
<Message Importance="High" Text="-------------MHM----------------" />
</Target>
</Project>

@ -0,0 +1,15 @@
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://deb.debian.org/debian bookworm main non-free-firmware
#deb-src https://deb.debian.org/debian bookworm main non-free-firmware
## Major bug fix updates produced after the final release of the
## distribution.
# deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb https://security.debian.org/debian-security bookworm-security main non-free-firmware
deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware
deb https://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware