mirror of
https://github.com/sharkdp/bat.git
synced 2025-05-08 02:15:10 +01:00
Compare commits
133 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b7f9662097 | ||
|
79ecb11ce2 | ||
|
4e9bb610b3 | ||
|
c88faf8cfa | ||
|
0b48eab7a6 | ||
|
ccfbd1ee31 | ||
|
98c9a5d948 | ||
|
96ea42e5f4 | ||
|
2ff2a818ef | ||
|
dd694c266e | ||
|
c4461f7d78 | ||
|
77de5160ac | ||
|
b9fcc5ae2d | ||
|
e42883bf2c | ||
|
5c41a45931 | ||
|
ba49ba0acd | ||
|
5d75632c8e | ||
|
e202a33ea1 | ||
|
93be82ebc9 | ||
|
0bf4753ff1 | ||
|
fbb07a1494 | ||
|
debb66f8b0 | ||
|
45185b36fb | ||
|
e761d79512 | ||
|
14064dd987 | ||
|
3eef8590f4 | ||
|
3e7ad18fe3 | ||
|
80a38590b8 | ||
|
44a6e29da7 | ||
|
a6e847e267 | ||
|
2f70906665 | ||
|
c4c919aa31 | ||
|
51491c3c08 | ||
|
ea17f6ad28 | ||
|
3691c9945a | ||
|
57629bcaca | ||
|
b38ee77628 | ||
|
b5413cc015 | ||
|
5edaa96164 | ||
|
12a2a451b4 | ||
|
fc7dff50b0 | ||
|
9272e09058 | ||
|
b13c4d5f8d | ||
|
d7b10b4352 | ||
|
05cddff72d | ||
|
a55d23aaa4 | ||
|
18b71743c8 | ||
|
f761ff6824 | ||
|
8e2d233445 | ||
|
59b1f362f6 | ||
|
a73c641a0f | ||
|
3d4c72da0b | ||
|
71547b3fb3 | ||
|
ad8da94d2a | ||
|
5ea762a46c | ||
|
bbb5829ad9 | ||
|
c00b382f13 | ||
|
964e2bdac3 | ||
|
2e7ab99099 | ||
|
4175f28979 | ||
|
207f90f01b | ||
|
5c43ddb56c | ||
|
3838766dd4 | ||
|
a006457a72 | ||
|
0449107230 | ||
|
75313d886b | ||
|
4998f58847 | ||
|
ffc094bd91 | ||
|
343326eacf | ||
|
d31bc4347a | ||
|
adfb951e51 | ||
|
2843a2c0e8 | ||
|
94d3dc254e | ||
|
915eb55779 | ||
|
547bc38118 | ||
|
93fd013aa1 | ||
|
512bfde7ce | ||
|
27ba45ded7 | ||
|
c0898dedb1 | ||
|
b82b920420 | ||
|
ac40f7cfd8 | ||
|
330c51de9f | ||
|
0ed527f0d1 | ||
|
7df1dec65c | ||
|
61d42ee87b | ||
|
a95e65eea1 | ||
|
71dce0e7f3 | ||
|
53af1dc32d | ||
|
52252b15d6 | ||
|
bc24ce9ad4 | ||
|
625e986552 | ||
|
095442191c | ||
|
cc46282866 | ||
|
cbc9c3629d | ||
|
2c49d905e4 | ||
|
f0e2f642e0 | ||
|
3d0f0c0565 | ||
|
3d442cdf98 | ||
|
b009fee5ea | ||
|
6cf747678c | ||
|
db812e1179 | ||
|
995f23b58f | ||
|
ef3830234d | ||
|
4fc55cfcec | ||
|
487ac3bc48 | ||
|
d6cb3ba747 | ||
|
a9a2dceb72 | ||
|
bee08e48ae | ||
|
b14fb9db24 | ||
|
91acb0d16f | ||
|
4f161705a3 | ||
|
f8c6e90647 | ||
|
dd9dc4f76b | ||
|
94f49fd99b | ||
|
498df11a50 | ||
|
db7da314e7 | ||
|
33aabc696a | ||
|
648bedf290 | ||
|
dd3d1b8cdb | ||
|
b39a156d57 | ||
|
b6158c09b4 | ||
|
8a11a46f66 | ||
|
4d73c1e511 | ||
|
280f3eeb4e | ||
|
1321160203 | ||
|
01680e444b | ||
|
2435453c33 | ||
|
6e466e5ab4 | ||
|
004d2d5122 | ||
|
60b3428ad7 | ||
|
571970f8ff | ||
|
18a0653ce8 | ||
|
569286055c |
.github/workflows
.gitmodulesCHANGELOG.mdCargo.lockCargo.tomlREADME.mdassets
manual
patches
syntaxes/02_Extra
ApacheAssembly_(ARM)
CSV
CSV-comma.sublime-syntaxCSV-pipe.sublime-syntaxCSV-semi-colon.sublime-syntaxCSV.sublime-syntaxTSV.sublime-syntax
DockerGDScript-sublimeHTML_(Twig)Idris2JavaScript_(Babel)LiveScriptNixOrg modeOrg_modePowerShellZigapt-source-list.sublime-syntaxcmd-helplog.sublime-syntaxsublime-odinsyslog.sublime-syntaxthemes
build
doc
examples
src
assets.rs
assets/build_assets
bin/bat
config.rscontroller.rsinput.rslessopen.rslib.rsline_range.rsoutput.rspretty_printer.rsprinter.rsstyle.rssyntax_mapping.rssyntax_mapping/builtins
theme.rsvscreen.rstests
examples
github-actions.rsintegration_tests.rssyntax-tests
compare_highlighted_versions.py
highlighted
CSV
comma-delimited.csvcomma_in_quotes.csvdecimals_comma_decimal_point_pipe_delimited.csvdecimals_comma_decimal_point_semicolon_delimited.csvsimple.tsv
GDScript
Idris2
JSON
Log
Odin
Syslog
XML
debsources
source
CSV
comma-delimited.csvdecimals_comma_decimal_point_pipe_delimited.csvdecimals_comma_decimal_point_semicolon_delimited.csvsimple.tsv
GDScript
Idris2
JSON
Odin
Syslog
XML
debsources
29
.github/workflows/CICD.yml
vendored
29
.github/workflows/CICD.yml
vendored
@ -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
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
|
||||
|
38
CHANGELOG.md
38
CHANGELOG.md
@ -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
1044
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
17
Cargo.toml
17
Cargo.toml
@ -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"
|
||||
|
42
README.md
42
README.md
@ -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 team’s</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"
|
||||
```
|
||||
|
||||
|
||||
|
4
assets/manual/bat.1.in
vendored
4
assets/manual/bat.1.in
vendored
@ -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
|
||||
|
19
assets/patches/Monokai-Extended.tmTheme.patch
vendored
19
assets/patches/Monokai-Extended.tmTheme.patch
vendored
@ -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>
|
||||
|
2
assets/syntaxes/02_Extra/Apache
vendored
2
assets/syntaxes/02_Extra/Apache
vendored
@ -1 +1 @@
|
||||
Subproject commit 163bc03ae8998a237dfb4be353d0aea198ea17f5
|
||||
Subproject commit cf6cefc51ebb46b1b54906433edbae0fe9c71cad
|
66
assets/syntaxes/02_Extra/CSV.sublime-syntax → assets/syntaxes/02_Extra/CSV/CSV-comma.sublime-syntax
vendored
66
assets/syntaxes/02_Extra/CSV.sublime-syntax → assets/syntaxes/02_Extra/CSV/CSV-comma.sublime-syntax
vendored
@ -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
|
80
assets/syntaxes/02_Extra/CSV/CSV-pipe.sublime-syntax
vendored
Normal file
80
assets/syntaxes/02_Extra/CSV/CSV-pipe.sublime-syntax
vendored
Normal file
@ -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
|
79
assets/syntaxes/02_Extra/CSV/CSV-semi-colon.sublime-syntax
vendored
Normal file
79
assets/syntaxes/02_Extra/CSV/CSV-semi-colon.sublime-syntax
vendored
Normal file
@ -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
|
113
assets/syntaxes/02_Extra/CSV/CSV.sublime-syntax
vendored
Normal file
113
assets/syntaxes/02_Extra/CSV/CSV.sublime-syntax
vendored
Normal file
@ -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
|
83
assets/syntaxes/02_Extra/CSV/TSV.sublime-syntax
vendored
Normal file
83
assets/syntaxes/02_Extra/CSV/TSV.sublime-syntax
vendored
Normal file
@ -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
|
2
assets/syntaxes/02_Extra/Docker
vendored
2
assets/syntaxes/02_Extra/Docker
vendored
@ -1 +1 @@
|
||||
Subproject commit 0f6b7bc87acf684f7b0790fd480731ffb4615b87
|
||||
Subproject commit c001fb280561d7c16f0f2837d76af493cf6c3bf8
|
1
assets/syntaxes/02_Extra/GDScript-sublime
vendored
Submodule
1
assets/syntaxes/02_Extra/GDScript-sublime
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 96f5dcf29728aa987123321e2544330eed991a3e
|
1
assets/syntaxes/02_Extra/Idris2
vendored
Submodule
1
assets/syntaxes/02_Extra/Idris2
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7c1bf44c4f9092b7b1e274b1332cf32a089b2b99
|
0
assets/syntaxes/02_Extra/JavaScript (Babel) → assets/syntaxes/02_Extra/JavaScript_(Babel)
vendored
0
assets/syntaxes/02_Extra/JavaScript (Babel) → assets/syntaxes/02_Extra/JavaScript_(Babel)
vendored
1
assets/syntaxes/02_Extra/LiveScript
vendored
1
assets/syntaxes/02_Extra/LiveScript
vendored
@ -1 +0,0 @@
|
||||
Subproject commit d82aeb737d4883d1a74aba7a07053f90211d427b
|
2
assets/syntaxes/02_Extra/Nix
vendored
2
assets/syntaxes/02_Extra/Nix
vendored
@ -1 +1 @@
|
||||
Subproject commit 9032bd613746b9c135223fd6f26a5fa555f18946
|
||||
Subproject commit 48c497c709c66a2fb118c534a8de8e4e1c4c401d
|
1
assets/syntaxes/02_Extra/Org mode
vendored
1
assets/syntaxes/02_Extra/Org mode
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 4976d8f84eeecd94df7da872bf404c125df04c73
|
1
assets/syntaxes/02_Extra/Org_mode
vendored
Submodule
1
assets/syntaxes/02_Extra/Org_mode
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit bb6e5d848151135ab8f87bdcb997437b2308718a
|
2
assets/syntaxes/02_Extra/PowerShell
vendored
2
assets/syntaxes/02_Extra/PowerShell
vendored
@ -1 +1 @@
|
||||
Subproject commit c0372a1d2df136ca6b3d1a9f7b85031dedf117f9
|
||||
Subproject commit a08b55bf1146c210f58e844be53c2aa78fd5e610
|
2
assets/syntaxes/02_Extra/Zig
vendored
2
assets/syntaxes/02_Extra/Zig
vendored
@ -1 +1 @@
|
||||
Subproject commit 1a4a38445fec495817625bafbeb01e79c44abcba
|
||||
Subproject commit 8a4a3fe4a051f85c4752b82f586d395cab843c06
|
42
assets/syntaxes/02_Extra/apt-source-list.sublime-syntax
vendored
Normal file
42
assets/syntaxes/02_Extra/apt-source-list.sublime-syntax
vendored
Normal file
@ -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
|
2
assets/syntaxes/02_Extra/cmd-help
vendored
2
assets/syntaxes/02_Extra/cmd-help
vendored
@ -1 +1 @@
|
||||
Subproject commit 209559b72f7e8848c988828088231b3a4d8b6838
|
||||
Subproject commit c71ba410bdfcc8f627df3219f14e3f2be4fe68ba
|
24
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
24
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
@ -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:
|
||||
|
1
assets/syntaxes/02_Extra/sublime-odin
vendored
Submodule
1
assets/syntaxes/02_Extra/sublime-odin
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5d6a0ed41e41ec3709ec74f40686dc3761d6596e
|
36
assets/syntaxes/02_Extra/syslog.sublime-syntax
vendored
36
assets/syntaxes/02_Extra/syslog.sublime-syntax
vendored
@ -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
|
||||
|
2
assets/themes/zenburn
vendored
2
assets/themes/zenburn
vendored
@ -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| {
|
||||
|
179
doc/README-ru.md
179
doc/README-ru.md
@ -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` поддерживает подсветку синтаксиса для огромного количества языков программирования и разметки:
|
||||
|
||||

|
||||

|
||||
|
||||
### Интеграция с Git
|
||||
`bat` использует `git`, чтобы показать изменения в коде
|
||||
@ -31,15 +31,17 @@
|
||||
|
||||

|
||||
|
||||
### Показать непечатаемые символы
|
||||
### Показ непечатных символов
|
||||
|
||||
Вы можете использовать `-A` / `--show-all` флаг, чтобы показать символы, которые невозможно напечатать:
|
||||
Вы можете использовать флаг `-A` / `--show-all`, чтобы показать непечатные символы:
|
||||
|
||||

|
||||
|
||||
### Автоматическое разделение текста
|
||||
### Автоматический пейджинг терминала
|
||||
|
||||
`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.
|
||||
|
||||
|
BIN
doc/sponsors/graphite-logo.jpeg
Normal file
BIN
doc/sponsors/graphite-logo.jpeg
Normal file
Binary file not shown.
After ![]() (image error) Size: 28 KiB |
BIN
doc/sponsors/warp-pack-header.png
Normal file
BIN
doc/sponsors/warp-pack-header.png
Normal file
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);
|
||||
}
|
||||
|
2
src/syntax_mapping/builtins/common/50-dotnet-xml.toml
Normal file
2
src/syntax_mapping/builtins/common/50-dotnet-xml.toml
Normal file
@ -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"]
|
||||
|
2
src/syntax_mapping/builtins/common/50-nix.toml
Normal file
2
src/syntax_mapping/builtins/common/50-nix.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"JSON" = ["flake.lock"]
|
6
src/syntax_mapping/builtins/linux/50-paru.toml
Normal file
6
src/syntax_mapping/builtins/linux/50-paru.toml
Normal file
@ -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
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 "
|
||||
|
3
tests/syntax-tests/highlighted/CSV/comma-delimited.csv
vendored
Normal file
3
tests/syntax-tests/highlighted/CSV/comma-delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[3;38;2;253;151;31mfoo[0m[38;2;253;151;31m,[0m[38;2;102;217;239mbar[0m[38;2;253;151;31m,[0m[38;2;190;132;255mbaz[0m[38;2;253;151;31m,[0m[38;2;249;38;114mthis|that[0m[38;2;253;151;31m,[0m[38;2;230;219;116mtest[0m[38;2;253;151;31m,[0m[3;38;2;253;151;31mcolors[0m[38;2;253;151;31m,[0m[38;2;102;217;239mcycle[0m
|
||||
[3;38;2;253;151;31m1.2[0m[38;2;253;151;31m,[0m[38;2;102;217;239m1.7[0m[38;2;253;151;31m,[0m[38;2;190;132;255m2.5[0m[38;2;253;151;31m,[0m[38;2;249;38;114mblah;cool[0m[38;2;253;151;31m,[0m[38;2;230;219;116mtest[0m[38;2;253;151;31m,[0m[3;38;2;253;151;31mcolors[0m[38;2;253;151;31m,[0m[38;2;102;217;239mcycle[0m
|
||||
|
|
@ -1,7 +1,7 @@
|
||||
[3;38;2;166;226;46mfirst[0m[38;2;253;151;31m,[0m[38;2;102;217;239mlast[0m[38;2;253;151;31m,[0m[38;2;190;132;255maddress[0m[38;2;253;151;31m,[0m[38;2;249;38;114mcity[0m[38;2;253;151;31m,[0m[3;38;2;166;226;46mzip[0m
|
||||
[3;38;2;166;226;46mJohn[0m[38;2;253;151;31m,[0m[38;2;102;217;239mDoe[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[3;38;2;166;226;46m08123[0m
|
||||
[3;38;2;166;226;46ma[0m[38;2;253;151;31m,[0m[38;2;102;217;239mb[0m
|
||||
[3;38;2;166;226;46m1[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mha [0m
|
||||
[3;38;2;253;151;31mfirst[0m[38;2;253;151;31m,[0m[38;2;102;217;239mlast[0m[38;2;253;151;31m,[0m[38;2;190;132;255maddress[0m[38;2;253;151;31m,[0m[38;2;249;38;114mcity[0m[38;2;253;151;31m,[0m[38;2;230;219;116mzip[0m
|
||||
[3;38;2;253;151;31mJohn[0m[38;2;253;151;31m,[0m[38;2;102;217;239mDoe[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[38;2;230;219;116m08123[0m
|
||||
[3;38;2;253;151;31ma[0m[38;2;253;151;31m,[0m[38;2;102;217;239mb[0m
|
||||
[3;38;2;253;151;31m1[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mha [0m
|
||||
[38;2;190;132;255m""[0m[38;2;230;219;116mha[0m[38;2;190;132;255m""[0m[38;2;230;219;116m [0m
|
||||
[38;2;230;219;116mha[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[3;38;2;166;226;46m08123[0m
|
||||
[3;38;2;166;226;46m3[0m[38;2;253;151;31m,[0m[38;2;102;217;239m4[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[3;38;2;166;226;46m08123[0m
|
||||
[38;2;230;219;116mha[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[38;2;230;219;116m08123[0m
|
||||
[3;38;2;253;151;31m3[0m[38;2;253;151;31m,[0m[38;2;102;217;239m4[0m[38;2;253;151;31m,[0m[38;2;190;132;255m120 any st.[0m[38;2;253;151;31m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mAnytown, WW[0m[38;2;230;219;116m"[0m[38;2;253;151;31m,[0m[38;2;230;219;116m08123[0m
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 177.
|
3
tests/syntax-tests/highlighted/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
3
tests/syntax-tests/highlighted/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[3;38;2;253;151;31mfoo[0m[38;2;253;151;31m|[0m[38;2;102;217;239mbar[0m[38;2;253;151;31m|[0m[38;2;190;132;255mbaz[0m
|
||||
[3;38;2;253;151;31m1,2[0m[38;2;253;151;31m|[0m[38;2;102;217;239m1,7[0m[38;2;253;151;31m|[0m[38;2;190;132;255m2,7[0m
|
||||
[3;38;2;253;151;31m1,5[0m[38;2;253;151;31m|[0m[38;2;102;217;239m8,5[0m[38;2;253;151;31m|[0m[38;2;190;132;255m-5,5[0m
|
|
3
tests/syntax-tests/highlighted/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
3
tests/syntax-tests/highlighted/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[3;38;2;253;151;31mfoo[0m[38;2;253;151;31m;[0m[38;2;102;217;239mbar[0m[38;2;253;151;31m;[0m[38;2;190;132;255mbaz[0m
|
||||
[3;38;2;253;151;31m1,2[0m[38;2;253;151;31m;[0m[38;2;102;217;239m1,7[0m[38;2;253;151;31m;[0m[38;2;190;132;255m2,7[0m
|
||||
[3;38;2;253;151;31m1,5[0m[38;2;253;151;31m;[0m[38;2;102;217;239m8,5[0m[38;2;253;151;31m;[0m[38;2;190;132;255m-5,5[0m
|
|
3
tests/syntax-tests/highlighted/CSV/simple.tsv
vendored
Normal file
3
tests/syntax-tests/highlighted/CSV/simple.tsv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[3;38;2;253;151;31mfoo[0m[38;2;253;151;31m [0m[38;2;102;217;239mbar[0m[38;2;253;151;31m [0m[38;2;190;132;255mbaz|;,[0m[38;2;253;151;31m [0m[38;2;249;38;114mtest[0m[38;2;253;151;31m [0m[38;2;230;219;116mhello world[0m[38;2;253;151;31m [0m[3;38;2;253;151;31mtsv[0m
|
||||
[3;38;2;253;151;31m1,2[0m[38;2;253;151;31m [0m[38;2;102;217;239m1,7[0m[38;2;253;151;31m [0m[38;2;190;132;255m2,7[0m[38;2;253;151;31m [0m[38;2;249;38;114ma b c[0m[38;2;253;151;31m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mhello again[0m[38;2;230;219;116m"[0m[38;2;253;151;31m [0m[3;38;2;253;151;31mtsv[0m
|
||||
[3;38;2;230;219;116m"[0m[3;38;2;230;219;116m;|,[0m[3;38;2;230;219;116m"[0m[38;2;253;151;31m [0m[38;2;102;217;239m;|,[0m[38;2;253;151;31m [0m[38;2;190;132;255mbaz[0m[38;2;253;151;31m [0m[38;2;249;38;114mtest[0m[38;2;253;151;31m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mhello world[0m[38;2;230;219;116m"[0m[38;2;253;151;31m [0m[3;38;2;253;151;31mtsv[0m
|
Can't render this file because it contains an unexpected character in line 2 and column 218.
|
71
tests/syntax-tests/highlighted/GDScript/test.gd
vendored
Normal file
71
tests/syntax-tests/highlighted/GDScript/test.gd
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
[38;2;249;38;114mextends[0m[3;4;38;2;166;226;46m Node[0m
|
||||
|
||||
[3;38;2;102;217;239msignal[0m[38;2;248;248;242m [0m[38;2;166;226;46mcustom_signal[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mparam[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;255;255;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m3.14159[0m
|
||||
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255muntyped_var[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello, World![0m[38;2;230;219;116m"[0m
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_int[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m42[0m
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_float[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mfloat[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m3.14[0m
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_string[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mGDScript Test[0m[38;2;230;219;116m"[0m
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_array[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mArray[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [[0m[38;2;190;132;255m1[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3[0m[38;2;248;248;242m, [0m[38;2;190;132;255m4[0m[38;2;248;248;242m][0m
|
||||
[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_dict[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mDictionary[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;230;219;116m"[0m[38;2;230;219;116mkey[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mvalue[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mnumber[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m100[0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114monready[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mlabel[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m $Label[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46msay_hello[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello from GDScript![0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46madd_numbers[0m[38;2;248;248;242m([0m[3;38;2;253;151;31ma[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mb[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m = 10[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m a [0m[38;2;249;38;114m+[0m[38;2;248;248;242m b[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mprocess_value[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mvalue[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m value [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mNegative[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114melif[0m[38;2;248;248;242m value [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mZero[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mPositive[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46msum_array[0m[38;2;248;248;242m([0m[3;38;2;253;151;31marr[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mArray[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtotal[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m num [0m[38;2;249;38;114min[0m[38;2;248;248;242m arr:[0m
|
||||
[38;2;248;248;242m total [0m[38;2;249;38;114m+=[0m[38;2;248;248;242m num[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m total[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mdescribe_number[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mnum[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m num:[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mZero[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSmall number[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m _:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mLarge number[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mlong_description[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m[38;2;230;219;116mThis is a test file for GDScript.[0m
|
||||
[38;2;230;219;116mIt covers variables, functions, control structures, loops, signals, inner classes,[0m
|
||||
[38;2;230;219;116mmultiline strings, arrays, and dictionaries.[0m[38;2;230;219;116m"""[0m
|
||||
|
||||
[3;38;2;102;217;239mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mInnerExample[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255minner_value[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m99[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mshow_value[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mInner value is:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m inner_value[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mtest_inner_class[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255minner[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m InnerExample.[0m[38;2;248;248;242mnew[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m inner.[0m[38;2;248;248;242mshow_value[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mtrigger_signal[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242memit_signal[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mcustom_signal[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mTestParam[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46m_ready[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242msay_hello[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mresult_add[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242madd_numbers[0m[38;2;248;248;242m([0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mAdd result:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m result_add[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mProcess value for -5:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mprocess_value[0m[38;2;248;248;242m([0m[38;2;249;38;114m-[0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mSum of array [10, 20, 30]:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242msum_array[0m[38;2;248;248;242m([0m[38;2;248;248;242m[[0m[38;2;190;132;255m10[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m20[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m30[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mDescription for 2:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mdescribe_number[0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mLong description:\n[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mlong_description[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mtest_inner_class[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mtrigger_signal[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
107
tests/syntax-tests/highlighted/Idris2/test.idr
vendored
Normal file
107
tests/syntax-tests/highlighted/Idris2/test.idr
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
[38;2;117;113;94m-- some code in Idris[0m
|
||||
[38;2;249;38;114mmodule[0m[38;2;248;248;242m [0m[38;2;166;226;46mXX.X'''[0m
|
||||
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;166;226;46mData.Nat[0m
|
||||
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mX[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mA[0m[38;2;248;248;242m [0m[38;2;249;38;114m|[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mB[0m
|
||||
|
||||
[38;2;249;38;114mnamespace[0m[38;2;248;248;242m [0m[38;2;166;226;46mX[0m
|
||||
[38;2;248;248;242m [0m[38;2;117;113;94m||| Documentation[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mrecord[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mY[0m[38;2;248;248;242m [0m[38;2;249;38;114mwhere[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m[[0m[38;2;248;248;242mnoHints[0m[38;2;249;38;114m][0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mconstructor[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mMkY'[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mfield1[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;249;38;114mauto[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mnamespace[0m[38;2;248;248;242m [0m[38;2;166;226;46mX'[0m[38;2;248;248;242m [0m[38;2;249;38;114m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mparameters[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mA[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mMaybe[0m[38;2;248;248;242m b[0m[38;2;249;38;114m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[38;2;249;38;114m}[0m
|
||||
|
||||
[38;2;166;226;46mu[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m()[0m
|
||||
[38;2;248;248;242mu [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m()[0m
|
||||
|
||||
[38;2;166;226;46mk[0m[38;2;248;248;242m, [0m[38;2;166;226;46mw[0m[38;2;248;248;242m, [0m[38;2;166;226;46mu[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mChar[0m
|
||||
[38;2;248;248;242mk [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255m\NUL[0m[38;2;190;132;255m'[0m
|
||||
[38;2;248;248;242mw [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255mw[0m[38;2;190;132;255m'[0m
|
||||
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m[[0m[38;2;190;132;255m1[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m3[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msdf[0m[38;2;248;248;242m\{[0m[38;2;248;248;242md[0m[38;2;248;248;242m}[0m[38;2;230;219;116m"[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m0xFF[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m0o77[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m0b10_1[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m100_100[0m[38;2;249;38;114m][0m
|
||||
|
||||
[38;2;166;226;46mf[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mInt[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mInt[0m
|
||||
[38;2;248;248;242mf [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m x [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114mthen[0m[38;2;248;248;242m x [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m()[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mSS[0m[38;2;248;248;242m [0m[38;2;249;38;114m`[0m[38;2;249;38;114melem[0m[38;2;249;38;114m`[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mS[0m[38;2;248;248;242m [0m[38;2;249;38;114m$[0m[38;2;248;248;242m [0m[38;2;249;38;114mdo[0m
|
||||
[38;2;248;248;242m x [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m a [0m[38;2;249;38;114m[[0m[38;2;190;132;255m1[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m2[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m3[0m[38;2;249;38;114m][0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mlet[0m[38;2;248;248;242m ukuk [0m[38;2;249;38;114m=[0m[38;2;248;248;242m akak[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mrewrite[0m[38;2;248;248;242m [0m[38;2;249;38;114m$[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mWow[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mWow[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mWow[0m[38;2;248;248;242m [0m[38;2;166;226;46mWow.[0m[3;38;2;102;217;239mWow[0m[38;2;248;248;242m b [0m[3;38;2;102;217;239mW[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mW[0m[38;2;249;38;114m)[0m
|
||||
[38;2;248;248;242m pure [0m[38;2;249;38;114m$[0m[38;2;248;248;242m f [0m[3;38;2;102;217;239mA[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mB[0m[38;2;248;248;242m c [0m[3;38;2;102;217;239mD[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mEE[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mE[0m
|
||||
|
||||
[38;2;166;226;46m(&&&)[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[38;2;248;248;242mz [0m[38;2;249;38;114m&&&[0m[38;2;248;248;242m y [0m[38;2;249;38;114m=[0m[38;2;248;248;242m d [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;248;248;242m?foo[0m
|
||||
[38;2;249;38;114m([0m[38;2;248;248;242m&&&[0m[38;2;249;38;114m)[0m[38;2;248;248;242m x y [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m?asfda[0m
|
||||
|
||||
[38;2;249;38;114mpublic[0m[38;2;248;248;242m [0m[38;2;249;38;114mexport[0m[38;2;248;248;242m [0m[38;2;249;38;114mcovering[0m
|
||||
[38;2;166;226;46m(.fun)[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mX[0m[38;2;248;248;242m a [0m[3;38;2;102;217;239mY[0m[38;2;248;248;242m b [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mfun [0m[38;2;249;38;114m=[0m[38;2;248;248;242m haha[0m[38;2;249;38;114m.[0m[38;2;248;248;242mfun haha [0m[38;2;249;38;114m.[0m[38;2;248;248;242mN[0m
|
||||
[38;2;249;38;114m([0m[38;2;249;38;114m.[0m[38;2;248;248;242mfun[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m ahah [0m[38;2;249;38;114m$[0m[38;2;248;248;242m [0m[38;2;249;38;114m\case[0m
|
||||
[38;2;248;248;242m x[0m[38;2;249;38;114m@[0m[38;2;249;38;114m([0m[38;2;248;248;242mx[0m[38;2;249;38;114m,[0m[38;2;248;248;242m y[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;166;226;46mPrelude.Types.[0m[38;2;248;248;242mahahah[0m
|
||||
|
||||
[38;2;166;226;46m(.N)[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mN [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m
|
||||
[38;2;249;38;114m([0m[38;2;249;38;114m.[0m[38;2;248;248;242mN[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mS[0m[38;2;248;248;242m n[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[38;2;249;38;114m.[0m[38;2;248;248;242mN[0m[38;2;249;38;114m)[0m[38;2;248;248;242m n[0m
|
||||
|
||||
[38;2;166;226;46mxx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mName[0m
|
||||
[38;2;248;248;242mxx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m`{[0m[38;2;166;226;46mFull.[0m[3;38;2;102;217;239mName[0m[38;2;249;38;114m}[0m
|
||||
|
||||
[38;2;249;38;114minfixr[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114m^^^[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;249;38;114m&&&[0m
|
||||
|
||||
[38;2;166;226;46mxxx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m?[0m
|
||||
[38;2;248;248;242mxxx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114mcase[0m[38;2;248;248;242m x [0m[38;2;249;38;114mof[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m lalalaCamelCase[0m
|
||||
[38;2;248;248;242m z [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m alalalCamelCase[0m
|
||||
|
||||
[38;2;166;226;46mff[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mTTImp[0m
|
||||
[38;2;248;248;242mff [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114mlet[0m[38;2;248;248;242m x [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114min[0m[38;2;248;248;242m val[0m
|
||||
[38;2;248;248;242mff [0m[38;2;190;132;255m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m`([0m[38;2;249;38;114mlet[0m[38;2;248;248;242m x [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114min[0m[38;2;248;248;242m [0m[38;2;249;38;114m~[0m[38;2;248;248;242mval [0m[38;2;249;38;114m^~^[0m[38;2;248;248;242m [0m[38;2;249;38;114m~[0m[38;2;249;38;114m([0m[38;2;248;248;242mabc[0m[38;2;249;38;114m)[0m[38;2;249;38;114m)[0m
|
||||
[38;2;248;248;242mff [0m[38;2;190;132;255m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m f [0m[38;2;249;38;114m`([0m[38;2;249;38;114mlet[0m[38;2;248;248;242m x [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114min[0m[38;2;248;248;242m [0m[38;2;249;38;114m~[0m[38;2;248;248;242mval [0m[38;2;249;38;114m^~^[0m[38;2;248;248;242m [0m[38;2;249;38;114m~[0m[38;2;249;38;114m([0m[38;2;248;248;242mabc[0m[38;2;249;38;114m)[0m[38;2;249;38;114m)[0m[38;2;248;248;242m x[0m
|
||||
|
||||
[38;2;249;38;114m%language[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mElabReflection[0m
|
||||
[38;2;249;38;114m%runElab[0m[38;2;248;248;242m [0m[38;2;166;226;46mX.[0m[38;2;248;248;242msf ads[0m
|
||||
|
||||
[38;2;249;38;114m%macro[0m[38;2;248;248;242m [0m[38;2;249;38;114m%inline[0m
|
||||
[38;2;166;226;46mfff[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mList[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDecl[0m
|
||||
[38;2;248;248;242mfff [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m`[[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mf[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
|
||||
[38;2;248;248;242m f [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m haha [0m[38;2;249;38;114m%runElab[0m[38;2;248;248;242m [0m[38;2;249;38;114m%search[0m[38;2;248;248;242m [0m[38;2;249;38;114m@[0m[38;2;249;38;114m{[0m[38;2;249;38;114m%World[0m[38;2;249;38;114m}[0m
|
||||
[38;2;249;38;114m][0m
|
||||
|
||||
[38;2;249;38;114mprivate[0m[38;2;248;248;242m [0m[38;2;249;38;114minfixr[0m[38;2;248;248;242m [0m[38;2;190;132;255m4[0m[38;2;248;248;242m [0m[38;2;249;38;114m^--^[0m
|
||||
|
||||
[38;2;249;38;114m([0m[38;2;249;38;114m^--^[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[38;2;249;38;114m([0m[38;2;249;38;114m^--^[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mZ[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m^--^[0m[38;2;248;248;242m y [0m[38;2;249;38;114m=[0m[38;2;248;248;242m x [0m[38;2;249;38;114m+[0m[38;2;248;248;242m y[0m
|
||||
|
||||
[38;2;166;226;46mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[3;38;2;253;151;31my[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mVect[0m[38;2;248;248;242m n [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mMaybe[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[3;38;2;102;217;239mMaybe[0m[38;2;248;248;242m [0m[38;2;249;38;114m([0m[38;2;248;248;242m&&&[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;249;38;114m)[0m[38;2;249;38;114m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;249;38;114mauto[0m[38;2;248;248;242m [0m[3;38;2;253;151;31m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mMonoid[0m[38;2;248;248;242m a[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;249;38;114mdefault [0m[38;2;249;38;114m4[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mxx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;249;38;114mdefault [0m[38;2;249;38;114m(f x Y)[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mxx'[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m
|
||||
[38;2;248;248;242mx [0m[3;38;2;102;217;239mZ[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mS[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m?foo[0m
|
||||
[38;2;248;248;242mx y [0m[38;2;190;132;255m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116ma b [0m[38;2;248;248;242m\{[0m[38;2;248;248;242mshow [0m[38;2;249;38;114m$[0m[38;2;248;248;242m [0m[38;2;249;38;114mlet[0m[38;2;248;248;242m x [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114min[0m[38;2;248;248;242m y[0m[38;2;248;248;242m}[0m[38;2;230;219;116m y >>= z[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;166;226;46mmultiline[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m
|
||||
[38;2;248;248;242mmultiline [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m"[0m[38;2;230;219;116m"[0m
|
||||
[38;2;230;219;116m A multiline string[0m[38;2;190;132;255m\NUL[0m
|
||||
[38;2;230;219;116m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m"[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;166;226;46mf'[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mNat[0m
|
||||
[38;2;248;248;242mf' [0m[38;2;249;38;114m=[0m[38;2;248;248;242m x' [0m[38;2;190;132;255m4[0m
|
||||
|
||||
[38;2;166;226;46mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mChar[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255m\BEL[0m[38;2;190;132;255m'[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255m\\[0m[38;2;190;132;255m'[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255m\'[0m[38;2;190;132;255m'[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255m\o755[0m[38;2;190;132;255m'[0m
|
||||
[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m'[0m[38;2;190;132;255ma[0m[38;2;190;132;255m'[0m
|
||||
|
||||
[38;2;166;226;46mxx[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mInt[0m
|
||||
[38;2;248;248;242mxx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0o7_5_5[0m
|
3
tests/syntax-tests/highlighted/JSON/example.ndjson
vendored
Normal file
3
tests/syntax-tests/highlighted/JSON/example.ndjson
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[38;2;248;248;242m{[0m[38;2;253;151;31m"[0m[38;2;253;151;31msome[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;230;219;116m"[0m[38;2;230;219;116mthing[0m[38;2;230;219;116m"[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m{[0m[38;2;253;151;31m"[0m[38;2;253;151;31mfoo[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;190;132;255m17[0m[38;2;248;248;242m,[0m[38;2;253;151;31m"[0m[38;2;253;151;31mbar[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;190;132;255mfalse[0m[38;2;248;248;242m,[0m[38;2;253;151;31m"[0m[38;2;253;151;31mquux[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;190;132;255mtrue[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m{[0m[38;2;253;151;31m"[0m[38;2;253;151;31mmay[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m{[0m[38;2;253;151;31m"[0m[38;2;253;151;31minclude[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;230;219;116m"[0m[38;2;230;219;116mnested[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;253;151;31m"[0m[38;2;253;151;31mobjects[0m[38;2;253;151;31m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m[[0m[38;2;230;219;116m"[0m[38;2;230;219;116mand[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116marrays[0m[38;2;230;219;116m"[0m[38;2;248;248;242m][0m[38;2;248;248;242m}[0m[38;2;248;248;242m}[0m
|
@ -1,3 +1,3 @@
|
||||
[38;2;190;132;255m2021-03-06[0m[38;2;248;248;242m [0m[38;2;190;132;255m23:22:21[0m[38;2;190;132;255m.[0m[38;2;190;132;255m392[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://[0m[4;38;2;166;226;46m[[0m[4;38;2;190;132;255m2001[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255mdb8[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m4006[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m812[0m[4;38;2;166;226;46m:[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m200e[0m[4;38;2;166;226;46m][0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m8080[0m[4;38;2;166;226;46m/path/the[0m[4;38;2;190;132;255m%[0m[4;38;2;190;132;255m20[0m[4;38;2;166;226;46mpage[0m[4;38;2;166;226;46m.[0m[4;38;2;166;226;46mhtml[0m
|
||||
[38;2;190;132;255m2021-03-06[0m[38;2;248;248;242m [0m[38;2;190;132;255m23:22:21[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://[0m[4;38;2;166;226;46mexample.com[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m8080[0m[4;38;2;166;226;46m/path/the[0m[4;38;2;190;132;255m%[0m[4;38;2;190;132;255m20[0m[4;38;2;166;226;46mpage[0m[4;38;2;166;226;46m(with_parens)[0m[4;38;2;166;226;46m.[0m[4;38;2;166;226;46mhtml[0m
|
||||
[38;2;190;132;255m2022-03-16[0m[38;2;249;38;114mT[0m[38;2;190;132;255m17:41:02[0m[38;2;190;132;255m.[0m[38;2;190;132;255m519[0m[38;2;248;248;242m helix_term::application [[0m[38;2;248;248;240mWARN[0m[38;2;248;248;242m] unhandled window/showMessage: ShowMessageParams { typ: [0m[38;2;248;248;240mError[0m[38;2;248;248;242m, message: [0m[38;2;230;219;116m"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 `[0m[38;2;190;132;255m\"[0m[38;2;230;219;116mcargo[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116mmetadata[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--format-version[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m1[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--manifest-path[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m/home/zeta/dev/raytracer/Cargo.toml[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--filter-platform[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116mwasm32-unknown-unknown[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m`: `cargo metadata` exited with an error: Updating crates.io index[0m[38;2;190;132;255m\n[0m[38;2;230;219;116merror: failed to select a version for `parking_lot`.[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mversions that meet the requirements `^0.12.0` are: 0.12.0[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mfailed to select a version for `parking_lot` which could resolve this conflict[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m"[0m[38;2;248;248;242m }[0m
|
||||
[38;2;190;132;255m2022-03-16[0m[38;2;249;38;114mT[0m[38;2;190;132;255m17:41:02[0m[38;2;190;132;255m.[0m[38;2;190;132;255m519[0m[38;2;248;248;240m helix_term::application [[0m[38;2;248;248;240mWARN[0m[38;2;248;248;240m] unhandled window/showMessage: ShowMessageParams { typ: [0m[38;2;221;32;32mError[0m[38;2;248;248;240m, message: [0m[38;2;230;219;116m"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 `[0m[38;2;190;132;255m\"[0m[38;2;230;219;116mcargo[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116mmetadata[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--format-version[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m1[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--manifest-path[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m/home/zeta/dev/raytracer/Cargo.toml[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116m--filter-platform[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m [0m[38;2;190;132;255m\"[0m[38;2;230;219;116mwasm32-unknown-unknown[0m[38;2;190;132;255m\"[0m[38;2;230;219;116m`: `cargo metadata` exited with an error: Updating crates.io index[0m[38;2;190;132;255m\n[0m[38;2;230;219;116merror: failed to select a version for `parking_lot`.[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mversions that meet the requirements `^0.12.0` are: 0.12.0[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;190;132;255m\n[0m[38;2;230;219;116mfailed to select a version for `parking_lot` which could resolve this conflict[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m"[0m[38;2;248;248;240m }[0m
|
||||
|
27
tests/syntax-tests/highlighted/Odin/test.odin
vendored
Normal file
27
tests/syntax-tests/highlighted/Odin/test.odin
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
[38;2;249;38;114mpackage[0m[38;2;248;248;242m main[0m
|
||||
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcore:fmt[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcore:math[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;166;226;46mVector[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m components: [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;166;226;46meuclidean_distance[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mproc[0m[38;2;248;248;242m(v1: Vector, v2: Vector) -> [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;102;217;239mlen[0m[38;2;248;248;242m(v1.components) != [0m[38;2;102;217;239mlen[0m[38;2;248;248;242m(v2.components) {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mpanic[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mVectors must be same dimension[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m sum: [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m = [0m[38;2;190;132;255m0.0[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m i, comp [0m[38;2;249;38;114min[0m[38;2;248;248;242m v1.components {[0m
|
||||
[38;2;248;248;242m diff := comp - v2.components[i];[0m
|
||||
[38;2;248;248;242m sum += diff * diff;[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m math.[0m[38;2;102;217;239msqrt[0m[38;2;248;248;242m(sum);[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;166;226;46mmain[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mproc[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m v1: Vector = Vector{components = [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m{[0m[38;2;190;132;255m1.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3.0[0m[38;2;248;248;242m}};[0m
|
||||
[38;2;248;248;242m v2: Vector = Vector{components = [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m{[0m[38;2;190;132;255m4.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m6.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m8.0[0m[38;2;248;248;242m}};[0m
|
||||
[38;2;248;248;242m dist: [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m = [0m[38;2;102;217;239meuclidean_distance[0m[38;2;248;248;242m(v1, v2);[0m
|
||||
[38;2;248;248;242m fmt.[0m[38;2;102;217;239mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mDistance:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m, dist);[0m
|
||||
[38;2;248;248;242m}[0m
|
@ -1,16 +1,17 @@
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m logrotate.service: Succeeded.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Finished Rotate log files.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mcolord[0m[38;2;248;248;242m[[0m[38;2;190;132;255m920[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;240mfailed[0m[38;2;248;248;242m to get session [pid [0m[38;2;190;132;255m137485[0m[38;2;248;248;242m]: No data available[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:00:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mkernel[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[3;38;2;253;151;31m55604[0m[38;2;248;248;242m.[0m[3;38;2;253;151;31m908232[0m[38;2;248;248;242m][0m[38;2;248;248;242m audit: [0m[3;38;2;253;151;31mtype[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1400[0m[38;2;248;248;242m audit([0m[38;2;190;132;255m1617483621[0m[38;2;190;132;255m.[0m[38;2;190;132;255m094[0m[38;2;248;248;242m:[0m[38;2;190;132;255m28[0m[38;2;248;248;242m): [0m[3;38;2;253;151;31mapparmor[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"DENIED[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31moperation[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"capable[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mprofile[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"/usr/sbin/cups-browsed[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mpid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m59311[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcomm[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"cups-browsed[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcapability[0m[38;2;249;38;114m=[0m[38;2;190;132;255m23[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcapname[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"sys_nice[0m[38;2;230;219;116m"[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:01:38[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd-resolved[0m[38;2;248;248;242m[[0m[38;2;190;132;255m721[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Server returned [0m[38;2;248;248;240merror[0m[38;2;248;248;242m NXDOMAIN, mitigating potential DNS violation DVE-[0m[38;2;190;132;255m2018[0m[38;2;248;248;242m-[0m[38;2;190;132;255m0001[0m[38;2;248;248;242m, retrying transaction with reduced feature level UDP.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:04:46[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Soliciting pool server [0m[38;2;190;132;255m255[0m[38;2;248;248;242m.[0m[38;2;190;132;255m76[0m[38;2;248;248;242m.[0m[38;2;190;132;255m59[0m[38;2;248;248;242m.[0m[38;2;190;132;255m37[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:05:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m local addr [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m -> [0m[38;2;190;132;255m<null>[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m00:06:29[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m receive: Unexpected origin timestamp [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d1[0m[38;2;190;132;255m.[0m[38;2;190;132;255m82e825f5[0m[38;2;248;248;242m does not match aorg [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d5[0m[38;2;190;132;255m.[0m[38;2;190;132;255m82c50d8c[0m[38;2;248;248;242m from server@[0m[38;2;190;132;255m127[0m[38;2;248;248;242m.[0m[38;2;190;132;255m0[0m[38;2;248;248;242m.[0m[38;2;190;132;255m0[0m[38;2;248;248;242m.[0m[38;2;190;132;255m1[0m[38;2;248;248;242m xmt [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d1[0m[38;2;190;132;255m.[0m[38;2;190;132;255me671d7c4[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m09:30:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mCRON[0m[38;2;248;248;242m[[0m[38;2;190;132;255m89278[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m (root) [0m[38;2;166;226;46mCMD[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;102;217;239m[[0m[38;2;255;255;255m [0m[3;38;2;253;151;31m-[0m[3;38;2;253;151;31mx[0m[38;2;255;255;255m /etc/init.d/anacron [0m[38;2;102;217;239m][0m[38;2;255;255;255m [0m[38;2;249;38;114m&&[0m[38;2;255;255;255m [0m[38;2;249;38;114mif[0m[38;2;255;255;255m [0m[38;2;102;217;239m[[0m[38;2;255;255;255m [0m[38;2;249;38;114m![0m[38;2;255;255;255m [0m[3;38;2;253;151;31m-[0m[3;38;2;253;151;31md[0m[38;2;255;255;255m /run/systemd/system [0m[38;2;102;217;239m][0m[38;2;249;38;114m;[0m[38;2;255;255;255m [0m[38;2;249;38;114mthen[0m[38;2;255;255;255m [0m[38;2;255;255;255m/usr/sbin/invoke-rc.d[0m[38;2;255;255;255m anacron start [0m[38;2;249;38;114m>[0m[38;2;255;255;255m/dev/null[0m[38;2;249;38;114m;[0m[38;2;255;255;255m [0m[38;2;249;38;114mfi[0m[38;2;248;248;242m)[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m16:32:07[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mNetworkManager[0m[38;2;248;248;242m[[0m[38;2;190;132;255m740[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m<info>[0m[38;2;248;248;242m [[0m[38;2;190;132;255m1617629527[0m[38;2;190;132;255m.[0m[38;2;190;132;255m1101[0m[38;2;248;248;242m] manager: NetworkManager state is now CONNECTED_GLOBAL[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;190;132;255m [0m[38;2;190;132;255m22:00:45[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mdbus-daemon[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1094[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[3;38;2;253;151;31msession[0m[38;2;248;248;242m [0m[3;38;2;253;151;31muid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1000[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mpid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1094[0m[38;2;248;248;242m][0m[38;2;248;248;242m Successfully activated service [0m[38;2;230;219;116m'[0m[38;2;230;219;116mio.github.celluloid_player.Celluloid[0m[38;2;230;219;116m'[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;190;132;255m [0m[38;2;190;132;255m13:29:06[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239minsomnia_insomnia.desktop[0m[38;2;248;248;242m[[0m[38;2;190;132;255m142666[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:29:06[0m[38;2;190;132;255m.[0m[38;2;190;132;255m316[0m[38;2;248;248;242m › [updater] Updater not running [0m[3;38;2;253;151;31mplatform[0m[38;2;249;38;114m=[0m[38;2;248;248;242mlinux [0m[3;38;2;253;151;31mdev[0m[38;2;249;38;114m=[0m[38;2;248;248;242mfalse[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;190;132;255m [0m[38;2;190;132;255m13:36:34[0m[38;2;248;248;242m [0m[38;2;166;226;46m192.168.220.5[0m[38;2;248;248;242m [0m[38;2;102;217;239mnginx[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m2021/08/11[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:36:34[0m[38;2;248;248;242m [[0m[38;2;248;248;242mdebug[0m[38;2;248;248;242m] [0m[38;2;190;132;255m2031[0m[38;2;248;248;242m#[0m[38;2;190;132;255m2031[0m[38;2;248;248;242m: epoll add event: fd:[0m[38;2;190;132;255m6[0m[38;2;248;248;242m op:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m ev:[0m[38;2;190;132;255m00002001[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;190;132;255m [0m[38;2;190;132;255m21:31:08[0m[38;2;248;248;242m [0m[38;2;166;226;46m::1[0m[38;2;248;248;242m [0m[38;2;102;217;239mnginx[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m2021/08/11[0m[38;2;248;248;242m [0m[38;2;190;132;255m21:31:08[0m[38;2;248;248;242m [[0m[38;2;248;248;242mdebug[0m[38;2;248;248;242m] [0m[38;2;190;132;255m760831[0m[38;2;248;248;242m#[0m[38;2;190;132;255m760831[0m[38;2;248;248;242m: epoll add event: fd:[0m[38;2;190;132;255m6[0m[38;2;248;248;242m op:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m ev:[0m[38;2;190;132;255m10000001[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;190;132;255m [0m[38;2;190;132;255m21:40:31[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mscop[0m[38;2;248;248;242m [0m[38;2;248;248;242mhello[0m
|
||||
[38;2;190;132;255mAug 16[0m[38;2;190;132;255m [0m[38;2;190;132;255m21:38:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Finished Cleanup of Temporary Directories.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m logrotate.service: Succeeded.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Finished Rotate log files.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:00:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mcolord[0m[38;2;248;248;242m[[0m[38;2;190;132;255m920[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;221;32;32mfailed[0m[38;2;248;248;240m to get session [pid [0m[38;2;190;132;255m137485[0m[38;2;248;248;240m]: No data available[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:00:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mkernel[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[3;38;2;253;151;31m55604[0m[38;2;248;248;242m.[0m[3;38;2;253;151;31m908232[0m[38;2;248;248;242m][0m[38;2;248;248;242m audit: [0m[3;38;2;253;151;31mtype[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1400[0m[38;2;248;248;242m audit([0m[38;2;190;132;255m1617483621[0m[38;2;190;132;255m.[0m[38;2;190;132;255m094[0m[38;2;248;248;242m:[0m[38;2;190;132;255m28[0m[38;2;248;248;242m): [0m[3;38;2;253;151;31mapparmor[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"DENIED[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31moperation[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"capable[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mprofile[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"/usr/sbin/cups-browsed[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mpid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m59311[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcomm[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"cups-browsed[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcapability[0m[38;2;249;38;114m=[0m[38;2;190;132;255m23[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcapname[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"sys_nice[0m[38;2;230;219;116m"[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:01:38[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd-resolved[0m[38;2;248;248;242m[[0m[38;2;190;132;255m721[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;240mServer returned [0m[38;2;221;32;32merror[0m[38;2;248;248;240m NXDOMAIN, mitigating potential DNS violation DVE-[0m[38;2;190;132;255m2018[0m[38;2;248;248;240m-[0m[38;2;190;132;255m0001[0m[38;2;248;248;240m, retrying transaction with reduced feature level UDP.[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:04:46[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Soliciting pool server [0m[38;2;190;132;255m255[0m[38;2;248;248;242m.[0m[38;2;190;132;255m76[0m[38;2;248;248;242m.[0m[38;2;190;132;255m59[0m[38;2;248;248;242m.[0m[38;2;190;132;255m37[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:05:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m local addr [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m -> [0m[38;2;190;132;255m<null>[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m00:06:29[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mntpd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m952[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m receive: Unexpected origin timestamp [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d1[0m[38;2;190;132;255m.[0m[38;2;190;132;255m82e825f5[0m[38;2;248;248;242m does not match aorg [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d5[0m[38;2;190;132;255m.[0m[38;2;190;132;255m82c50d8c[0m[38;2;248;248;242m from server@[0m[38;2;190;132;255m127[0m[38;2;248;248;242m.[0m[38;2;190;132;255m0[0m[38;2;248;248;242m.[0m[38;2;190;132;255m0[0m[38;2;248;248;242m.[0m[38;2;190;132;255m1[0m[38;2;248;248;242m xmt [0m[38;2;190;132;255m0x[0m[38;2;190;132;255me414a8d1[0m[38;2;190;132;255m.[0m[38;2;190;132;255me671d7c4[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m09:30:01[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mCRON[0m[38;2;248;248;242m[[0m[38;2;190;132;255m89278[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m (root) [0m[38;2;166;226;46mCMD[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;102;217;239m[[0m[38;2;255;255;255m [0m[3;38;2;253;151;31m-[0m[3;38;2;253;151;31mx[0m[38;2;255;255;255m /etc/init.d/anacron [0m[38;2;102;217;239m][0m[38;2;255;255;255m [0m[38;2;249;38;114m&&[0m[38;2;255;255;255m [0m[38;2;249;38;114mif[0m[38;2;255;255;255m [0m[38;2;102;217;239m[[0m[38;2;255;255;255m [0m[38;2;249;38;114m![0m[38;2;255;255;255m [0m[3;38;2;253;151;31m-[0m[3;38;2;253;151;31md[0m[38;2;255;255;255m /run/systemd/system [0m[38;2;102;217;239m][0m[38;2;249;38;114m;[0m[38;2;255;255;255m [0m[38;2;249;38;114mthen[0m[38;2;255;255;255m [0m[38;2;255;255;255m/usr/sbin/invoke-rc.d[0m[38;2;255;255;255m anacron start [0m[38;2;249;38;114m>[0m[38;2;255;255;255m/dev/null[0m[38;2;249;38;114m;[0m[38;2;255;255;255m [0m[38;2;249;38;114mfi[0m[38;2;248;248;242m)[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m16:32:07[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mNetworkManager[0m[38;2;248;248;242m[[0m[38;2;190;132;255m740[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m<info>[0m[38;2;248;248;242m [[0m[38;2;190;132;255m1617629527[0m[38;2;190;132;255m.[0m[38;2;190;132;255m1101[0m[38;2;248;248;242m] manager: NetworkManager state is now CONNECTED_GLOBAL[0m
|
||||
[38;2;190;132;255mApr 4[0m[38;2;248;248;242m [0m[38;2;190;132;255m22:00:45[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mdbus-daemon[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1094[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[3;38;2;253;151;31msession[0m[38;2;248;248;242m [0m[3;38;2;253;151;31muid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1000[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mpid[0m[38;2;249;38;114m=[0m[38;2;190;132;255m1094[0m[38;2;248;248;242m][0m[38;2;248;248;242m Successfully activated service [0m[38;2;230;219;116m'[0m[38;2;230;219;116mio.github.celluloid_player.Celluloid[0m[38;2;230;219;116m'[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:29:06[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239minsomnia_insomnia.desktop[0m[38;2;248;248;242m[[0m[38;2;190;132;255m142666[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:29:06[0m[38;2;190;132;255m.[0m[38;2;190;132;255m316[0m[38;2;248;248;242m › [updater] Updater not running [0m[3;38;2;253;151;31mplatform[0m[38;2;249;38;114m=[0m[38;2;248;248;242mlinux [0m[3;38;2;253;151;31mdev[0m[38;2;249;38;114m=[0m[38;2;248;248;242mfalse[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:36:34[0m[38;2;248;248;242m [0m[38;2;166;226;46m192.168.220.5[0m[38;2;248;248;242m [0m[38;2;102;217;239mnginx[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m2021/08/11[0m[38;2;248;248;242m [0m[38;2;190;132;255m13:36:34[0m[38;2;248;248;242m [[0m[38;2;248;248;242mdebug[0m[38;2;248;248;242m] [0m[38;2;190;132;255m2031[0m[38;2;248;248;242m#[0m[38;2;190;132;255m2031[0m[38;2;248;248;242m: epoll add event: fd:[0m[38;2;190;132;255m6[0m[38;2;248;248;242m op:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m ev:[0m[38;2;190;132;255m00002001[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;248;248;242m [0m[38;2;190;132;255m21:31:08[0m[38;2;248;248;242m [0m[38;2;166;226;46m::1[0m[38;2;248;248;242m [0m[38;2;102;217;239mnginx[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m2021/08/11[0m[38;2;248;248;242m [0m[38;2;190;132;255m21:31:08[0m[38;2;248;248;242m [[0m[38;2;248;248;242mdebug[0m[38;2;248;248;242m] [0m[38;2;190;132;255m760831[0m[38;2;248;248;242m#[0m[38;2;190;132;255m760831[0m[38;2;248;248;242m: epoll add event: fd:[0m[38;2;190;132;255m6[0m[38;2;248;248;242m op:[0m[38;2;190;132;255m1[0m[38;2;248;248;242m ev:[0m[38;2;190;132;255m10000001[0m
|
||||
[38;2;190;132;255mAug 11[0m[38;2;248;248;242m [0m[38;2;190;132;255m21:40:31[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239mscop[0m[38;2;248;248;242m [0m[38;2;248;248;242mhello[0m
|
||||
[38;2;190;132;255mAug 16[0m[38;2;248;248;242m [0m[38;2;190;132;255m21:38:21[0m[38;2;248;248;242m [0m[38;2;166;226;46mhostname-here[0m[38;2;248;248;242m [0m[38;2;102;217;239msystemd[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m:[0m[38;2;248;248;242m Finished Cleanup of Temporary Directories.[0m
|
||||
[38;2;190;132;255m2025-02-08[0m[38;2;248;248;240m [0m[38;2;190;132;255m20:52:11[0m[38;2;190;132;255m.[0m[38;2;190;132;255m039[0m[38;2;248;248;240m - setfont: [0m[38;2;221;32;32mERROR[0m[38;2;248;248;240m kdfontop.c:[0m[38;2;190;132;255m183[0m[38;2;248;248;240m put_font_kdfontop: Unable to load such font with such kernel version[0m
|
||||
|
5
tests/syntax-tests/highlighted/XML/Directory.Build.props
vendored
Normal file
5
tests/syntax-tests/highlighted/XML/Directory.Build.props
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
[38;2;255;255;255m<[0m[38;2;249;38;114mProject[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mPropertyGroup[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mOutDir[0m[38;2;255;255;255m>[0m[38;2;248;248;242mC:\output\$(MSBuildProjectName)[0m[38;2;255;255;255m</[0m[38;2;249;38;114mOutDir[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;249;38;114mPropertyGroup[0m[38;2;255;255;255m>[0m
|
||||
[38;2;255;255;255m</[0m[38;2;249;38;114mProject[0m[38;2;255;255;255m>[0m
|
11
tests/syntax-tests/highlighted/XML/console.csproj
vendored
Normal file
11
tests/syntax-tests/highlighted/XML/console.csproj
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
[38;2;255;255;255m<[0m[38;2;249;38;114mProject[0m[38;2;248;248;242m [0m[38;2;166;226;46mSdk[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mMicrosoft.NET.Sdk[0m[38;2;230;219;116m"[0m[38;2;255;255;255m>[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mPropertyGroup[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mOutputType[0m[38;2;255;255;255m>[0m[38;2;248;248;242mExe[0m[38;2;255;255;255m</[0m[38;2;249;38;114mOutputType[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mTargetFramework[0m[38;2;255;255;255m>[0m[38;2;248;248;242mnet9.0[0m[38;2;255;255;255m</[0m[38;2;249;38;114mTargetFramework[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mRootNamespace[0m[38;2;255;255;255m>[0m[38;2;248;248;242mSomeNamespace[0m[38;2;255;255;255m</[0m[38;2;249;38;114mRootNamespace[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mImplicitUsings[0m[38;2;255;255;255m>[0m[38;2;248;248;242menable[0m[38;2;255;255;255m</[0m[38;2;249;38;114mImplicitUsings[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mNullable[0m[38;2;255;255;255m>[0m[38;2;248;248;242menable[0m[38;2;255;255;255m</[0m[38;2;249;38;114mNullable[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;249;38;114mPropertyGroup[0m[38;2;255;255;255m>[0m
|
||||
|
||||
[38;2;255;255;255m</[0m[38;2;249;38;114mProject[0m[38;2;255;255;255m>[0m
|
8
tests/syntax-tests/highlighted/XML/projectname.targets
vendored
Normal file
8
tests/syntax-tests/highlighted/XML/projectname.targets
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
[38;2;255;255;255m<?[0m[38;2;249;38;114mxml[0m[38;2;248;248;242m [0m[38;2;166;226;46mversion[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116m1.0[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;166;226;46mencoding[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mutf-8[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m?>[0m
|
||||
[38;2;255;255;255m<[0m[38;2;249;38;114mProject[0m[38;2;248;248;242m [0m[38;2;166;226;46mxmlns[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mhttp://schemas.microsoft.com/developer/msbuild/2003[0m[38;2;230;219;116m"[0m[38;2;255;255;255m>[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mTarget[0m[38;2;248;248;242m [0m[38;2;166;226;46mName[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mTestTarget[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;166;226;46mAfterTargets[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mBuild[0m[38;2;230;219;116m"[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mMessage[0m[38;2;248;248;242m [0m[38;2;166;226;46mImportance[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mHigh[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;166;226;46mText[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116m-------------MHM----------------[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;249;38;114mTarget[0m[38;2;255;255;255m>[0m
|
||||
|
||||
[38;2;255;255;255m</[0m[38;2;249;38;114mProject[0m[38;2;255;255;255m>[0m
|
15
tests/syntax-tests/highlighted/debsources/sources.list
vendored
Normal file
15
tests/syntax-tests/highlighted/debsources/sources.list
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m newer versions of the distribution.[0m
|
||||
|
||||
[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94mdeb-src https://deb.debian.org/debian bookworm main non-free-firmware[0m
|
||||
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m# Major bug fix updates produced after the final release of the[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m# distribution.[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m deb-src http://lt.archive.ubuntu.com/ubuntu/ xenial-updates main restricted[0m
|
||||
|
||||
[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://security.debian.org/debian-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
|
||||
[38;2;190;132;255mdeb-src[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://security.debian.org/debian-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-security[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
|
||||
|
||||
[38;2;190;132;255mdeb[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-updates[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
|
||||
[38;2;190;132;255mdeb-src[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://deb.debian.org/debian[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mbookworm-updates[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mmain[0m[38;2;248;248;242m [0m[38;2;190;132;255mnon-free-firmware[0m
|
3
tests/syntax-tests/source/CSV/comma-delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/comma-delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
foo,bar,baz,this|that,test,colors,cycle
|
||||
1.2,1.7,2.5,blah;cool,test,colors,cycle
|
||||
|
|
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
foo|bar|baz
|
||||
1,2|1,7|2,7
|
||||
1,5|8,5|-5,5
|
|
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
foo;bar;baz
|
||||
1,2;1,7;2,7
|
||||
1,5;8,5;-5,5
|
|
3
tests/syntax-tests/source/CSV/simple.tsv
vendored
Normal file
3
tests/syntax-tests/source/CSV/simple.tsv
vendored
Normal file
@ -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
|
|
71
tests/syntax-tests/source/GDScript/test.gd
vendored
Normal file
71
tests/syntax-tests/source/GDScript/test.gd
vendored
Normal file
@ -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()
|
7
tests/syntax-tests/source/Idris2/LICENSE.md
vendored
Normal file
7
tests/syntax-tests/source/Idris2/LICENSE.md
vendored
Normal file
@ -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
|
107
tests/syntax-tests/source/Idris2/test.idr
vendored
Normal file
107
tests/syntax-tests/source/Idris2/test.idr
vendored
Normal file
@ -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
|
3
tests/syntax-tests/source/JSON/example.ndjson
vendored
Normal file
3
tests/syntax-tests/source/JSON/example.ndjson
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{"some":"thing"}
|
||||
{"foo":17,"bar":false,"quux":true}
|
||||
{"may":{"include":"nested","objects":["and","arrays"]}}
|
27
tests/syntax-tests/source/Odin/test.odin
vendored
Normal file
27
tests/syntax-tests/source/Odin/test.odin
vendored
Normal file
@ -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
|
||||
|
5
tests/syntax-tests/source/XML/Directory.Build.props
vendored
Normal file
5
tests/syntax-tests/source/XML/Directory.Build.props
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<OutDir>C:\output\$(MSBuildProjectName)</OutDir>
|
||||
</PropertyGroup>
|
||||
</Project>
|
11
tests/syntax-tests/source/XML/console.csproj
vendored
Normal file
11
tests/syntax-tests/source/XML/console.csproj
vendored
Normal file
@ -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>
|
8
tests/syntax-tests/source/XML/projectname.targets
vendored
Normal file
8
tests/syntax-tests/source/XML/projectname.targets
vendored
Normal file
@ -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>
|
15
tests/syntax-tests/source/debsources/sources.list
vendored
Normal file
15
tests/syntax-tests/source/debsources/sources.list
vendored
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user