Merge branch 'master' into master

This commit is contained in:
David Peter 2022-10-30 21:08:04 +01:00 committed by GitHub
commit 14742a82bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1706 additions and 197 deletions

4
.gitmodules vendored
View file

@ -247,3 +247,7 @@
[submodule "assets/syntaxes/02_Extra/TodoTxt"] [submodule "assets/syntaxes/02_Extra/TodoTxt"]
path = assets/syntaxes/02_Extra/TodoTxt path = assets/syntaxes/02_Extra/TodoTxt
url = https://github.com/dertuxmalwieder/SublimeTodoTxt url = https://github.com/dertuxmalwieder/SublimeTodoTxt
[submodule "assets/syntaxes/02_Extra/Ada"]
path = assets/syntaxes/02_Extra/Ada
url = https://github.com/wiremoons/ada-sublime-syntax

View file

@ -2,12 +2,19 @@
## Features ## Features
- Implemented `-S` and `--chop-long-lines` flags as aliases for `--wrap=never`. See #2309 (@johnmatthiggins)
## Bugfixes ## Bugfixes
## Other ## Other
- Various bash completion improvements, see #2310 (@scop)
## Syntaxes ## Syntaxes
- Added support for Ada, see #1300 and #2316 (@dkm)
- Improve Manpage.sublime-syntax. See #2364 (@Freed-Wu)
## Themes ## Themes
## `bat` as a library ## `bat` as a library
@ -18,8 +25,6 @@
## Bugfixes ## Bugfixes
- Bring back pre-processing of ANSI escape characters to so that some common `bat` use cases starts working again. See #2308 (@Enselic) - Bring back pre-processing of ANSI escape characters to so that some common `bat` use cases starts working again. See #2308 (@Enselic)
- Improve Manpage.sublime-syntax. See #2364 (@Freed-Wu)
# v0.22.0 # v0.22.0

View file

@ -33,7 +33,7 @@ section in the README.
Please consider opening a Please consider opening a
[feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md) [feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md)
first in order to give us a chance to discuss the feature first. first in order to give us a chance to discuss the details and specifics of the potential new feature before you go and build it.
## Adding new syntaxes/languages or themes ## Adding new syntaxes/languages or themes
@ -50,12 +50,12 @@ first.
## Regression tests ## Regression tests
You are strongly encouraged to add regression tests. Regression tests are great, You are **strongly encouraged** to add regression tests. Regression tests are great,
not least because they: not least because they:
* ensure that your contribution will never completely stop working, * ensure that your contribution will never completely stop working.
* makes code review easier, because it becomes very clear what the code is * makes code reviews easier, because it becomes very clear what the code is
supposed to do. supposed to do.
For functional changes, you most likely want to add a test to For functional changes, you most likely want to add a test to

356
Cargo.lock generated
View file

@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.18" version = "0.7.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -62,9 +62,9 @@ dependencies = [
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.1" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "base64" name = "base64"
@ -123,9 +123,9 @@ dependencies = [
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [ dependencies = [
"bit-vec", "bit-vec",
] ]
@ -166,9 +166,9 @@ dependencies = [
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.7.3" version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439989e6b8c38d1b6570a384ef1e49c8848128f5a97f3914baef02920842712f" checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da"
[[package]] [[package]]
name = "bytesize" name = "bytesize"
@ -178,9 +178,9 @@ checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.72" version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
dependencies = [ dependencies = [
"jobserver", "jobserver",
] ]
@ -193,26 +193,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.20" version = "4.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_lex", "clap_lex",
"indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
"termcolor", "termcolor",
"terminal_size", "terminal_size 0.2.1",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@ -238,7 +236,7 @@ dependencies = [
"encode_unicode", "encode_unicode",
"lazy_static", "lazy_static",
"libc", "libc",
"terminal_size", "terminal_size 0.1.17",
"unicode-width", "unicode-width",
"winapi", "winapi",
] ]
@ -254,9 +252,9 @@ dependencies = [
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.0" version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -296,9 +294,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]] [[package]]
name = "either" name = "either"
version = "1.6.1" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]] [[package]]
name = "encode_unicode" name = "encode_unicode"
@ -370,6 +368,27 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "fancy-regex" name = "fancy-regex"
version = "0.7.1" version = "0.7.1"
@ -382,9 +401,9 @@ dependencies = [
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.7.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [ dependencies = [
"instant", "instant",
] ]
@ -416,19 +435,18 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.0.1" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
dependencies = [ dependencies = [
"matches",
"percent-encoding", "percent-encoding",
] ]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -508,9 +526,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.11.2" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
@ -523,20 +541,19 @@ dependencies = [
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.2.3" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
dependencies = [ dependencies = [
"matches",
"unicode-bidi", "unicode-bidi",
"unicode-normalization", "unicode-normalization",
] ]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.7.0" version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -552,31 +569,31 @@ dependencies = [
] ]
[[package]] [[package]]
name = "itertools" name = "io-lifetimes"
version = "0.10.3" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [ dependencies = [
"either", "either",
] ]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "0.4.8" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
[[package]]
name = "itoa"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.24" version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -589,9 +606,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.125" version = "0.2.134"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
@ -607,9 +624,9 @@ dependencies = [
[[package]] [[package]]
name = "libz-sys" name = "libz-sys"
version = "1.1.3" version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -628,45 +645,46 @@ dependencies = [
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
version = "0.5.4" version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.5" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
dependencies = [ dependencies = [
"autocfg",
"scopeguard", "scopeguard",
] ]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.14" version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.4.1" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.5.1" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
dependencies = [ dependencies = [
"adler", "adler",
] ]
@ -690,13 +708,22 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.14" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "num_threads"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.15.0" version = "1.15.0"
@ -705,21 +732,21 @@ checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]] [[package]]
name = "onig" name = "onig"
version = "6.3.1" version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ddfe2c93bb389eea6e6d713306880c7f6dcc99a75b659ce145d962c861b225" checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"lazy_static",
"libc", "libc",
"once_cell",
"onig_sys", "onig_sys",
] ]
[[package]] [[package]]
name = "onig_sys" name = "onig_sys"
version = "69.7.1" version = "69.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dd3eee045c84695b53b20255bb7317063df090b68e18bfac0abb6c39cf7f33e" checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7"
dependencies = [ dependencies = [
"cc", "cc",
"pkg-config", "pkg-config",
@ -767,15 +794,15 @@ dependencies = [
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.24" version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]] [[package]]
name = "plist" name = "plist"
@ -807,15 +834,15 @@ dependencies = [
[[package]] [[package]]
name = "predicates-core" name = "predicates-core"
version = "1.0.2" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb"
[[package]] [[package]]
name = "predicates-tree" name = "predicates-tree"
version = "1.0.4" version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032"
dependencies = [ dependencies = [
"predicates-core", "predicates-core",
"termtree", "termtree",
@ -853,39 +880,40 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.39" version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.14" version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.10" version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
[[package]] [[package]]
name = "redox_users" name = "redox_users"
version = "0.4.0" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"redox_syscall", "redox_syscall",
"thiserror",
] ]
[[package]] [[package]]
@ -922,24 +950,38 @@ dependencies = [
[[package]] [[package]]
name = "rgb" name = "rgb"
version = "0.8.31" version = "0.8.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a374af9a0e5fdcdd98c1c7b64f05004f9ea2555b6c75f211daa81268a3c50f1" checksum = "3603b7d71ca82644f79b5a06d1220e9a58ede60bd32255f698cb1af8838b8db3"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
[[package]] [[package]]
name = "rustversion" name = "rustix"
version = "1.0.6" version = "0.35.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef"
dependencies = [
"bitflags",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "rustversion"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.9" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]] [[package]]
name = "safemem" name = "safemem"
@ -990,20 +1032,20 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.74" version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa",
"ryu", "ryu",
"serde", "serde",
] ]
[[package]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.8.24" version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"ryu", "ryu",
@ -1049,9 +1091,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.7.0" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]] [[package]]
name = "std_prelude" name = "std_prelude"
@ -1067,9 +1109,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.95" version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1126,9 +1168,9 @@ dependencies = [
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.1.2" version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [ dependencies = [
"winapi-util", "winapi-util",
] ]
@ -1144,19 +1186,20 @@ dependencies = [
] ]
[[package]] [[package]]
name = "termtree" name = "terminal_size"
version = "0.2.3" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1"
dependencies = [
"rustix",
"windows-sys",
]
[[package]] [[package]]
name = "textwrap" name = "termtree"
version = "0.15.0" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b"
dependencies = [
"terminal_size",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
@ -1180,19 +1223,20 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.5" version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b"
dependencies = [ dependencies = [
"itoa 0.4.8", "itoa",
"libc", "libc",
"num_threads",
] ]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.5.1" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [ dependencies = [
"tinyvec_macros", "tinyvec_macros",
] ]
@ -1205,21 +1249,21 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.7" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.0" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.19" version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
] ]
@ -1232,13 +1276,12 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]] [[package]]
name = "url" name = "url"
version = "2.2.2" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
"matches",
"percent-encoding", "percent-encoding",
] ]
@ -1276,9 +1319,9 @@ dependencies = [
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.10.2+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wild" name = "wild"
@ -1320,6 +1363,49 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.4" version = "0.8.4"

View file

@ -77,10 +77,9 @@ default-features = false
features = ["parsing"] features = ["parsing"]
[dependencies.clap] [dependencies.clap]
version = "3.2.20" version = "4.0.2"
optional = true optional = true
default-features = false features = ["wrap_help", "cargo"]
features = ["std", "suggestions", "color", "wrap_help", "cargo"]
[dev-dependencies] [dev-dependencies]
assert_cmd = "2.0.4" assert_cmd = "2.0.4"
@ -92,8 +91,10 @@ tempfile = "3.3.0"
[target.'cfg(unix)'.dev-dependencies] [target.'cfg(unix)'.dev-dependencies]
nix = { version = "0.24.2", default-features = false, features = ["term"] } nix = { version = "0.24.2", default-features = false, features = ["term"] }
[build-dependencies] [build-dependencies.clap]
clap = { version = "3.2.20", optional = true } version = "4.0.2"
optional = true
features = ["wrap_help", "cargo"]
[profile.release] [profile.release]
lto = true lto = true

1
assets/syntaxes/02_Extra/Ada vendored Submodule

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

View file

@ -8,6 +8,7 @@ file_extensions:
- .env.local - .env.local
- .env.sample - .env.sample
- .env.example - .env.example
- .env.template
- .env.test - .env.test
- .env.test.local - .env.test.local
- .env.testing - .env.testing
@ -23,6 +24,10 @@ file_extensions:
- .env.defaults - .env.defaults
- .envrc - .envrc
- .flaskenv - .flaskenv
- env
- env.example
- env.sample
- env.template
scope: source.env scope: source.env
contexts: contexts:
main: main:

View file

@ -16,6 +16,9 @@ file_extensions:
- url - url
- URL - URL
- .editorconfig - .editorconfig
- .coveragerc
- .pylintrc
- .gitlint
- .hgrc - .hgrc
- hgrc - hgrc
scope: source.ini scope: source.ini

View file

@ -79,7 +79,8 @@ The following files have been manually modified after converting from a `.tmLang
* `Apache.sublime_syntax`=> removed `conf` and `CONF` file types. * `Apache.sublime_syntax`=> removed `conf` and `CONF` file types.
* `Dart.sublime-syntax` => removed `#regex.dart` include. * `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers. * `DotENV.sublime-syntax` => added `.env.template`, `env` and `env.*` file types ([upstream PR](https://github.com/zaynali53/DotENV/pull/17)).
* `INI.sublime-syntax` => added `.coveragerc`, `.pylintrc`, `.gitlint`, `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers.
* `Org mode.sublime-syntax` => removed `task` file type. * `Org mode.sublime-syntax` => removed `task` file type.
* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension. * `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension.
* `SML.sublime_syntax` => removed `ml` file type. * `SML.sublime_syntax` => removed `ml` file type.

View file

@ -161,17 +161,21 @@ impl App {
}), }),
show_nonprintable: self.matches.get_flag("show-all"), show_nonprintable: self.matches.get_flag("show-all"),
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() { wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
match self.matches.get_one::<String>("wrap").map(|s| s.as_str()) { if !self.matches.get_flag("chop-long-lines") {
Some("character") => WrappingMode::Character, match self.matches.get_one::<String>("wrap").map(|s| s.as_str()) {
Some("never") => WrappingMode::NoWrapping(true), Some("character") => WrappingMode::Character,
Some("auto") | None => { Some("never") => WrappingMode::NoWrapping(true),
if style_components.plain() { Some("auto") | None => {
WrappingMode::NoWrapping(false) if style_components.plain() {
} else { WrappingMode::NoWrapping(false)
WrappingMode::Character } else {
WrappingMode::Character
}
} }
_ => unreachable!("other values for --wrap are not allowed"),
} }
_ => unreachable!("other values for --wrap are not allowed"), } else {
WrappingMode::NoWrapping(true)
} }
} else { } else {
// We don't have the tty width when piping to another program. // We don't have the tty width when piping to another program.
@ -221,7 +225,9 @@ impl App {
} }
}) })
.unwrap_or_else(|| String::from(HighlightingAssets::default_theme())), .unwrap_or_else(|| String::from(HighlightingAssets::default_theme())),
visible_lines: match self.matches.contains_id("diff") && self.matches.get_flag("diff") { visible_lines: match self.matches.try_contains_id("diff").unwrap_or_default()
&& self.matches.get_flag("diff")
{
#[cfg(feature = "git")] #[cfg(feature = "git")]
true => VisibleLines::DiffContext( true => VisibleLines::DiffContext(
self.matches self.matches

View file

@ -1,6 +1,5 @@
use clap::{ use clap::{
crate_name, crate_version, value_parser, AppSettings, Arg, ArgAction, ArgGroup, ColorChoice, crate_name, crate_version, value_parser, Arg, ArgAction, ArgGroup, ColorChoice, Command,
Command,
}; };
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::env; use std::env;
@ -19,7 +18,7 @@ static VERSION: Lazy<String> = Lazy::new(|| {
} }
}); });
pub fn build_app(interactive_output: bool) -> Command<'static> { pub fn build_app(interactive_output: bool) -> Command {
let color_when = if interactive_output && env::var_os("NO_COLOR").is_none() { let color_when = if interactive_output && env::var_os("NO_COLOR").is_none() {
ColorChoice::Auto ColorChoice::Auto
} else { } else {
@ -29,20 +28,12 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
let mut app = Command::new(crate_name!()) let mut app = Command::new(crate_name!())
.version(VERSION.as_str()) .version(VERSION.as_str())
.color(color_when) .color(color_when)
.global_setting(AppSettings::DeriveDisplayOrder)
.hide_possible_values(true) .hide_possible_values(true)
.args_conflicts_with_subcommands(true) .args_conflicts_with_subcommands(true)
.allow_external_subcommands(true) .allow_external_subcommands(true)
.disable_help_subcommand(true) .disable_help_subcommand(true)
.max_term_width(100) .max_term_width(100)
.about( .about("A cat(1) clone with wings.")
"A cat(1) clone with wings.\n\n\
Use '--help' instead of '-h' to see a more detailed version of the help text.",
)
.after_help(
"Note: `bat -h` prints a short and concise overview while `bat --help` gives all \
details.",
)
.long_about("A cat(1) clone with syntax highlighting and Git integration.") .long_about("A cat(1) clone with syntax highlighting and Git integration.")
.arg( .arg(
Arg::new("FILE") Arg::new("FILE")
@ -51,8 +42,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
"File(s) to print / concatenate. Use a dash ('-') or no argument at all \ "File(s) to print / concatenate. Use a dash ('-') or no argument at all \
to read from standard input.", to read from standard input.",
) )
.takes_value(true) .num_args(1..)
.multiple_values(true)
.value_parser(value_parser!(PathBuf)), .value_parser(value_parser!(PathBuf)),
) )
.arg( .arg(
@ -94,14 +84,12 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
specified as a name (like 'C++' or 'LaTeX') or possible file extension \ specified as a name (like 'C++' or 'LaTeX') or possible file extension \
(like 'cpp', 'hpp' or 'md'). Use '--list-languages' to show all supported \ (like 'cpp', 'hpp' or 'md'). Use '--list-languages' to show all supported \
language names and file extensions.", language names and file extensions.",
) ),
.takes_value(true),
) )
.arg( .arg(
Arg::new("highlight-line") Arg::new("highlight-line")
.long("highlight-line") .long("highlight-line")
.short('H') .short('H')
.takes_value(true)
.action(ArgAction::Append) .action(ArgAction::Append)
.value_name("N:M") .value_name("N:M")
.help("Highlight lines N through M.") .help("Highlight lines N through M.")
@ -118,7 +106,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.arg( .arg(
Arg::new("file-name") Arg::new("file-name")
.long("file-name") .long("file-name")
.takes_value(true)
.action(ArgAction::Append) .action(ArgAction::Append)
.value_name("name") .value_name("name")
.value_parser(value_parser!(PathBuf)) .value_parser(value_parser!(PathBuf))
@ -150,7 +137,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("diff-context") Arg::new("diff-context")
.long("diff-context") .long("diff-context")
.overrides_with("diff-context") .overrides_with("diff-context")
.takes_value(true)
.value_name("N") .value_name("N")
.value_parser( .value_parser(
|n: &str| { |n: &str| {
@ -171,7 +157,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("tabs") Arg::new("tabs")
.long("tabs") .long("tabs")
.overrides_with("tabs") .overrides_with("tabs")
.takes_value(true)
.value_name("T") .value_name("T")
.value_parser( .value_parser(
|t: &str| { |t: &str| {
@ -191,7 +176,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("wrap") Arg::new("wrap")
.long("wrap") .long("wrap")
.overrides_with("wrap") .overrides_with("wrap")
.takes_value(true)
.value_name("mode") .value_name("mode")
.value_parser(["auto", "never", "character"]) .value_parser(["auto", "never", "character"])
.default_value("auto") .default_value("auto")
@ -201,10 +185,16 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
The '--terminal-width' option can be used in addition to \ The '--terminal-width' option can be used in addition to \
control the output width."), control the output width."),
) )
.arg(
Arg::new("chop-long-lines")
.long("chop-long-lines")
.short('S')
.action(ArgAction::SetTrue)
.help("Truncate all lines longer than screen width. Alias for '--wrap=never'."),
)
.arg( .arg(
Arg::new("terminal-width") Arg::new("terminal-width")
.long("terminal-width") .long("terminal-width")
.takes_value(true)
.value_name("width") .value_name("width")
.hide_short_help(true) .hide_short_help(true)
.allow_hyphen_values(true) .allow_hyphen_values(true)
@ -242,7 +232,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("color") Arg::new("color")
.long("color") .long("color")
.overrides_with("color") .overrides_with("color")
.takes_value(true)
.value_name("when") .value_name("when")
.value_parser(["auto", "never", "always"]) .value_parser(["auto", "never", "always"])
.hide_default_value(true) .hide_default_value(true)
@ -258,7 +247,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.arg( .arg(
Arg::new("italic-text") Arg::new("italic-text")
.long("italic-text") .long("italic-text")
.takes_value(true)
.value_name("when") .value_name("when")
.value_parser(["always", "never"]) .value_parser(["always", "never"])
.default_value("never") .default_value("never")
@ -270,7 +258,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("decorations") Arg::new("decorations")
.long("decorations") .long("decorations")
.overrides_with("decorations") .overrides_with("decorations")
.takes_value(true)
.value_name("when") .value_name("when")
.value_parser(["auto", "never", "always"]) .value_parser(["auto", "never", "always"])
.default_value("auto") .default_value("auto")
@ -300,7 +287,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.long("paging") .long("paging")
.overrides_with("paging") .overrides_with("paging")
.overrides_with("no-paging") .overrides_with("no-paging")
.takes_value(true)
.value_name("when") .value_name("when")
.value_parser(["auto", "never", "always"]) .value_parser(["auto", "never", "always"])
.default_value("auto") .default_value("auto")
@ -328,7 +314,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("pager") Arg::new("pager")
.long("pager") .long("pager")
.overrides_with("pager") .overrides_with("pager")
.takes_value(true)
.value_name("command") .value_name("command")
.hide_short_help(true) .hide_short_help(true)
.help("Determine which pager to use.") .help("Determine which pager to use.")
@ -344,7 +329,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.short('m') .short('m')
.long("map-syntax") .long("map-syntax")
.action(ArgAction::Append) .action(ArgAction::Append)
.takes_value(true)
.value_name("glob:syntax") .value_name("glob:syntax")
.help("Use the specified syntax for files matching the glob pattern ('*.cpp:C++').") .help("Use the specified syntax for files matching the glob pattern ('*.cpp:C++').")
.long_help( .long_help(
@ -354,12 +338,10 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
'.myignore' with the Git Ignore syntax, use -m '.myignore:Git Ignore'. Note \ '.myignore' with the Git Ignore syntax, use -m '.myignore:Git Ignore'. Note \
that the right-hand side is the *name* of the syntax, not a file extension.", that the right-hand side is the *name* of the syntax, not a file extension.",
) )
.takes_value(true),
) )
.arg( .arg(
Arg::new("ignored-suffix") Arg::new("ignored-suffix")
.action(ArgAction::Append) .action(ArgAction::Append)
.takes_value(true)
.long("ignored-suffix") .long("ignored-suffix")
.hide_short_help(true) .hide_short_help(true)
.help( .help(
@ -371,7 +353,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("theme") Arg::new("theme")
.long("theme") .long("theme")
.overrides_with("theme") .overrides_with("theme")
.takes_value(true)
.help("Set the color theme for syntax highlighting.") .help("Set the color theme for syntax highlighting.")
.long_help( .long_help(
"Set the theme for syntax highlighting. Use '--list-themes' to \ "Set the theme for syntax highlighting. Use '--list-themes' to \
@ -392,10 +373,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("style") Arg::new("style")
.long("style") .long("style")
.value_name("components") .value_name("components")
// Need to turn this off for overrides_with to work as we want. See the bottom most
// example at https://docs.rs/clap/2.32.0/clap/struct.Arg.html#method.overrides_with
.use_value_delimiter(false)
.takes_value(true)
.overrides_with("style") .overrides_with("style")
.overrides_with("plain") .overrides_with("plain")
.overrides_with("number") .overrides_with("number")
@ -458,7 +435,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.long("line-range") .long("line-range")
.short('r') .short('r')
.action(ArgAction::Append) .action(ArgAction::Append)
.takes_value(true)
.value_name("N:M") .value_name("N:M")
.help("Only print the lines from N to M.") .help("Only print the lines from N to M.")
.long_help( .long_help(
@ -484,6 +460,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("unbuffered") Arg::new("unbuffered")
.short('u') .short('u')
.long("unbuffered") .long("unbuffered")
.action(ArgAction::SetTrue)
.hide_short_help(true) .hide_short_help(true)
.long_help( .long_help(
"This option exists for POSIX-compliance reasons ('u' is for \ "This option exists for POSIX-compliance reasons ('u' is for \
@ -494,6 +471,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.arg( .arg(
Arg::new("no-config") Arg::new("no-config")
.long("no-config") .long("no-config")
.action(ArgAction::SetTrue)
.hide(true) .hide(true)
.help("Do not use the configuration file"), .help("Do not use the configuration file"),
) )
@ -550,8 +528,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.hide_short_help(true) .hide_short_help(true)
.help("Show acknowledgements."), .help("Show acknowledgements."),
) );
.mut_arg("help", |arg| arg.help("Print this help message."));
// Check if the current directory contains a file name cache. Otherwise, // Check if the current directory contains a file name cache. Otherwise,
// enable the 'bat cache' subcommand. // enable the 'bat cache' subcommand.
@ -560,6 +537,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
} else { } else {
app.subcommand( app.subcommand(
Command::new("cache") Command::new("cache")
.hide(true)
.about("Modify the syntax-definition and theme cache") .about("Modify the syntax-definition and theme cache")
.arg( .arg(
Arg::new("build") Arg::new("build")
@ -588,7 +566,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("source") Arg::new("source")
.long("source") .long("source")
.requires("build") .requires("build")
.takes_value(true)
.value_name("dir") .value_name("dir")
.help("Use a different directory to load syntaxes and themes from."), .help("Use a different directory to load syntaxes and themes from."),
) )
@ -596,7 +573,6 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
Arg::new("target") Arg::new("target")
.long("target") .long("target")
.requires("build") .requires("build")
.takes_value(true)
.value_name("dir") .value_name("dir")
.help( .help(
"Use a different directory to store the cached syntax and theme set.", "Use a different directory to store the cached syntax and theme set.",
@ -620,6 +596,10 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
.help("Build acknowledgements.bin."), .help("Build acknowledgements.bin."),
), ),
) )
.after_long_help(
"You can use 'bat cache' to customize syntaxes and themes. \
See 'bat cache --help' for more information",
)
} }
} }

1
tests/examples/long-single-line.txt vendored Normal file
View file

@ -0,0 +1 @@
abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz

View file

@ -1499,6 +1499,47 @@ fn ignored_suffix_arg() {
.stderr(""); .stderr("");
} }
fn wrapping_test(wrap_flag: &str, expect_wrap: bool) {
let expected = match expect_wrap {
true =>
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde\nfghigklmnopqrstuvxyz\n",
false =>
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n",
};
bat()
.arg(wrap_flag)
.arg("--style=rule")
.arg("--color=never")
.arg("--decorations=always")
.arg("--terminal-width=80")
.arg("long-single-line.txt")
.assert()
.success()
.stdout(expected.to_owned())
.stderr("");
}
#[test]
fn no_line_wrapping_when_set_to_never() {
wrapping_test("--wrap=never", false);
}
#[test]
fn line_wrapping_when_auto() {
wrapping_test("--wrap=auto", true);
}
#[test]
fn no_line_wrapping_with_s_flag() {
wrapping_test("-S", false);
}
#[test]
fn no_wrapping_with_chop_long_lines() {
wrapping_test("--chop-long-lines", false);
}
#[test] #[test]
fn highlighting_is_skipped_on_long_lines() { fn highlighting_is_skipped_on_long_lines() {
let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() + let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() +

View file

@ -0,0 +1,308 @@
with Chests.Ring_Buffers;
with USB.Device.HID.Keyboard;
package body Click is
 ----------------
 -- DEBOUNCE --
 ----------------
 -- Ideally, in a separate package.
 -- should be [], but not fixed yet in GCC 11.
 Current_Status : Key_Matrix := [others => [others => False]];
 New_Status : Key_Matrix := [others => [others => False]];
 Since : Natural := 0;
 -- Nb_Bounce : Natural := 5;
 function Update (NewS : Key_Matrix) return Boolean is
 begin
 -- The new state is the same as the current stable state => Do nothing.
 if Current_Status = NewS then
 Since := 0;
 return False;
 end if;
 if New_Status /= NewS then
 -- The new state differs from the previous
 -- new state (bouncing) => reset
 New_Status := NewS;
 Since := 1;
 else
 -- The new state hasn't changed since last
 -- update => towards stabilization.
 Since := Since + 1;
 end if;
 if Since > Nb_Bounce then
 declare
 Tmp : constant Key_Matrix := Current_Status;
 begin
 -- New state has been stable enough.
 -- Latch it and notifies caller.
 Current_Status := New_Status;
 New_Status := Tmp;
 Since := 0;
 end;
 return True;
 else
 -- Not there yet
 return False;
 end if;
 end Update;
 procedure Get_Matrix;
 -- Could use := []; but GNAT 12 has a bug (fixed in upcoming 13)
 Read_Status : Key_Matrix := [others => [others => False]];
 function Get_Events return Events is
 Num_Evt : Natural := 0;
 New_S : Key_Matrix renames Read_Status;
 begin
 Get_Matrix;
 if Update (New_S) then
 for I in Current_Status'Range (1) loop
 for J in Current_Status'Range (2) loop
 if (not New_Status (I, J) and then Current_Status (I, J))
 or else (New_Status (I, J) and then not Current_Status (I, J))
 then
 Num_Evt := Num_Evt + 1;
 end if;
 end loop;
 end loop;
 declare
 Evts : Events (Natural range 1 .. Num_Evt);
 Cursor : Natural range 1 .. Num_Evt + 1 := 1;
 begin
 for I in Current_Status'Range (1) loop
 for J in Current_Status'Range (2) loop
 if not New_Status (I, J)
 and then Current_Status (I, J)
 then
 -- Pressing I, J
 Evts (Cursor) := [
 Evt => Press,
 Col => I,
 Row => J
 ];
 Cursor := Cursor + 1;
 elsif New_Status (I, J)
 and then not Current_Status (I, J)
 then
 -- Release I, J
 Evts (Cursor) := [
 Evt => Release,
 Col => I,
 Row => J
 ];
 Cursor := Cursor + 1;
 end if;
 end loop;
 end loop;
 return Evts;
 end;
 end if;
 return [];
 end Get_Events;
 procedure Get_Matrix is -- return Key_Matrix is
 begin
 for Row in Keys.Rows'Range loop
 Keys.Rows (Row).Clear;
 for Col in Keys.Cols'Range loop
 Read_Status (Col, Row) := not Keys.Cols (Col).Set;
 end loop;
 Keys.Rows (Row).Set;
 end loop;
 end Get_Matrix;
 -- End of DEBOUNCE
 --------------
 -- Layout --
 --------------
 package Events_Ring_Buffers is new Chests.Ring_Buffers
 (Element_Type => Event,
 Capacity => 16);
 Queued_Events : Events_Ring_Buffers.Ring_Buffer;
 type Statet is (Normal_Key, Layer_Mod, None);
 type State is record
 Typ : Statet;
 Code : Key_Code_T;
 Layer_Value : Natural;
 -- Col : ColR;
 -- Row : RowR;
 end record;
 type State_Array is array (ColR, RowR) of State;
 States : State_Array := [others => [others => (Typ => None, Code => No, Layer_Value => 0)]];
 function Kw (Code : Key_Code_T) return Action is
 begin
 return (T => Key, C => Code, L => 0);
 end Kw;
 function Lw (V : Natural) return Action is
 begin
 return (T => Layer, C => No, L => V);
 end Lw;
 -- FIXME: hardcoded max number of events
 subtype Events_Range is Natural range 0 .. 60;
 type Array_Of_Reg_Events is array (Events_Range) of Event;
 Stamp : Natural := 0;
 procedure Register_Events (L : Layout; Es : Events) is
 begin
 Stamp := Stamp + 1;
 Log ("Reg events: " & Stamp'Image);
 Log (Es'Length'Image);
 for E of Es loop
 declare
 begin
 if Events_Ring_Buffers.Is_Full (Queued_Events) then
 raise Program_Error;
 end if;
 Events_Ring_Buffers.Append (Queued_Events, E);
 end;
 -- Log ("Reg'ed events:" & Events_Mark'Image);
 Log ("Reg'ed events:" & Events_Ring_Buffers.Length (Queued_Events)'Image);
 end loop;
 end Register_Events;
 procedure Release (Col: Colr; Row: Rowr) is
 begin
 if States (Col, Row).Typ = None then
 raise Program_Error;
 end if;
 States (Col, Row) := (Typ => None, Code => No, Layer_Value => 0);
 end Release;
 function Get_Current_Layer return Natural is
 L : Natural := 0;
 begin
 for S of States loop
 if S.Typ = Layer_Mod then
 L := L + S.Layer_Value;
 end if;
 end loop;
 return L;
 end Get_Current_Layer;
 -- Tick the event.
 -- Returns TRUE if it needs to stay in the queued events
 -- FALSE if the event has been consumed.
 function Tick (L: Layout; E : in out Event) return Boolean is
 Current_Layer : Natural := Get_Current_Layer;
 A : Action renames L (Current_Layer, E.Row, E.Col);
 begin
 case E.Evt is
 when Press =>
 case A.T is
 when Key =>
 States (E.Col, E.Row) :=
 (Typ => Normal_Key,
 Code => A.C,
 Layer_Value => 0);
 when Layer =>
 States (E.Col, E.Row) := (Typ => Layer_Mod, Layer_Value => A.L, Code => No);
 when others =>
 raise Program_Error;
 end case;
 when Release =>
 Release (E.Col, E.Row);
 end case;
 return False;
 end Tick;
 Last_Was_Empty_Log : Boolean := False;
 procedure Tick (L : Layout) is
 begin
 for I in 1 .. Events_Ring_Buffers.Length(Queued_Events) loop
 declare
 E : Event := Events_Ring_Buffers.Last_Element (Queued_Events);
 begin
 Events_Ring_Buffers.Delete_Last (Queued_Events);
 if Tick (L, E) then
 Events_Ring_Buffers.Prepend (Queued_Events, E);
 end if;
 end;
 end loop;
 if not Last_Was_Empty_Log or else Events_Ring_Buffers.Length(Queued_Events) /= 0 then
 Log ("End Tick layout, events: " & Events_Ring_Buffers.Length(Queued_Events)'Image);
 Last_Was_Empty_Log := Events_Ring_Buffers.Length(Queued_Events) = 0;
 end if;
 end Tick;
 function Get_Key_Codes return Key_Codes_T is
 Codes : Key_Codes_T (0 .. 10);
 Wm: Natural := 0;
 begin
 for S of States loop
 if S.Typ = Normal_Key and then
 (S.Code < LCtrl or else S.Code > RGui)
 then
 Codes (Wm) := S.Code;
 Wm := Wm + 1;
 end if;
 end loop;
 if Wm = 0 then
 return [];
 else
 return Codes (0 .. Wm - 1);
 end if;
 end Get_Key_Codes;
 function Get_Modifiers return Key_Modifiers is
 use USB.Device.HID.Keyboard;
 KM : Key_Modifiers (1..8);
 I : Natural := 0;
 begin
 for S of States loop
 if S.Typ = Normal_Key then
 I := I + 1;
 case S.Code is
 when LCtrl =>
 KM(I) := Ctrl_Left;
 when RCtrl =>
 KM(I) := Ctrl_Right;
 when LShift =>
 KM(I) := Shift_Left;
 when RShift =>
 KM(I) := Shift_Right;
 when LAlt =>
 KM(I) := Alt_Left;
 when RAlt =>
 KM(I) := Alt_Right;
 when LGui =>
 KM(I) := Meta_Left;
 when RGui =>
 KM(I) := Meta_Right;
 when others =>
 I := I - 1;
 end case;
 end if;
 end loop;
 return KM (1..I);
 end Get_Modifiers;
 procedure Init is
 begin
 Events_Ring_Buffers.Clear (Queued_Events);
 end Init;
end Click;

View file

@ -0,0 +1,339 @@
with HAL.GPIO;
with USB.Device.HID.Keyboard;
generic
 Nb_Bounce : Natural;
 type ColR is (<>);
 type RowR is (<>);
 type GPIOP is new HAL.GPIO.GPIO_Point with private;
 type Cols_T is array (ColR) of GPIOP;
 type Rows_T is array (RowR) of GPIOP;
 Cols : Cols_T;
 Rows : Rows_T;
 Num_Layers : Natural;
 with procedure Log (S : String; L : Integer := 1; Deindent : Integer := 0);
package Click is
 type Keys_T is record
 Cols : Cols_T;
 Rows : Rows_T;
 end record;
 Keys : Keys_T :=
 (Rows => Rows, Cols => Cols);
 type Key_Matrix is array (ColR, RowR) of Boolean;
 --------------------------
 -- Events & Debouncing --
 --------------------------
 MaxEvents : constant Positive := 20;
 type EventT is (Press, Release);
 type Event is record
 Evt : EventT;
 Col : ColR;
 Row : RowR;
 end record;
 type Events is array (Natural range <>) of Event;
 function Get_Events return Events;
 function Update (NewS : Key_Matrix) return Boolean;
 -------------
 -- Layout --
 -------------
 ---------------
 -- Keycodes --
 ---------------
 -- Keycodes copy/pasted from the excelent Keyberon Rust firmware:
 -- https://github.com/TeXitoi/keyberon/
 type Key_Code_T is
 (
 -- The "no" key, a placeholder to express nothing.
 No, -- = 0x00,
 -- / Error if too much keys are pressed at
 -- the same time.
 ErrorRollOver,
 -- / The POST fail error.
 PostFail,
 -- / An undefined error occured.
 ErrorUndefined,
 -- / `a` and `A`.
 A,
 B,
 C,
 D,
 E,
 F,
 G,
 H,
 I,
 J,
 K,
 L,
 M, -- 0x10
 N,
 O,
 P,
 Q,
 R,
 S,
 T,
 U,
 V,
 W,
 X,
 Y,
 Z,
 -- `1` and `!`.
 Kb1,
 -- `2` and `@`.
 Kb2,
 -- `3` and `#`.
 Kb3, -- 0x20
 -- / `4` and `$`.
 Kb4,
 -- `5` and `%`.
 Kb5,
 -- `6` and `^`.
 Kb6,
 -- `7` and `&`.
 Kb7,
 -- `8` and `*`.
 Kb8,
 -- `9` and `(`.
 Kb9,
 -- `0` and `)`.
 Kb0,
 Enter,
 Escape,
 BSpace,
 Tab,
 Space,
 -- `-` and `_`.
 Minus,
 -- `=` and `+`.
 Equal,
 -- `[` and `{`.
 LBracket,
 -- `]` and `}`.
 RBracket, -- 0x30
 -- / `\` and `|`.
 Bslash,
 -- Non-US `#` and `~` (Typically near the Enter key).
 NonUsHash,
 -- `;` and `:`.
 SColon,
 -- `'` and `"`.
 Quote,
 -- How to have ` as code?
 -- \` and `~`.
 Grave,
 -- `,` and `<`.
 Comma,
 -- `.` and `>`.
 Dot,
 -- `/` and `?`.
 Slash,
 CapsLock,
 F1,
 F2,
 F3,
 F4,
 F5,
 F6,
 F7, -- 0x40
 F8,
 F9,
 F10,
 F11,
 F12,
 PScreen,
 ScrollLock,
 Pause,
 Insert,
 Home,
 PgUp,
 Delete,
 Endd,
 PgDown,
 Right,
 Left, -- 0x50
 Down,
 Up,
 NumLock,
 -- Keypad `/`
 KpSlash,
 -- Keypad `*`
 KpAsterisk,
 -- Keypad `-`.
 KpMinus,
 -- Keypad `+`.
 KpPlus,
 -- Keypad enter.
 KpEnter,
 -- Keypad 1.
 Kp1,
 Kp2,
 Kp3,
 Kp4,
 Kp5,
 Kp6,
 Kp7,
 Kp8, -- 0x60
 Kp9,
 Kp0,
 KpDot,
 -- Non-US `\` and `|` (Typically near the Left-Shift key)
 NonUsBslash,
 Application, -- 0x65
 -- / not a key, used for errors
 Power,
 -- Keypad `=`.
 KpEqual,
 F13,
 F14,
 F15,
 F16,
 F17,
 F18,
 F19,
 F20,
 F21, -- 0x70
 F22,
 F23,
 F24,
 Execute,
 Help,
 Menu,
 Selectt,
 Stop,
 Again,
 Undo,
 Cut,
 Copy,
 Paste,
 Find,
 Mute,
 VolUp, -- 0x80
 VolDown,
 -- Deprecated.
 LockingCapsLock,
 -- Deprecated.
 LockingNumLock,
 -- Deprecated.
 LockingScrollLock,
 -- / Keypad `,`, also used for the
 -- brazilian keypad period (.) key.
 KpComma,
 -- Used on AS/400 keyboard
 KpEqualSign,
 Intl1,
 Intl2,
 Intl3,
 Intl4,
 Intl5,
 Intl6,
 Intl7,
 Intl8,
 Intl9,
 Lang1, -- 0x90
 Lang2,
 Lang3,
 Lang4,
 Lang5,
 Lang6,
 Lang7,
 Lang8,
 Lang9,
 AltErase,
 SysReq,
 Cancel,
 Clear,
 Prior,
 Returnn,
 Separator,
 Outt, -- 0xA0
 Oper,
 ClearAgain,
 CrSel,
 ExSel,
 -- According to QMK, 0xA5-0xDF are not
 -- usable on modern keyboards
 -- Modifiers
 -- Left Control.
 LCtrl, -- = 0xE0,
 -- / Left Shift.
 LShift,
 -- Left Alt.
 LAlt,
 -- Left GUI (the Windows key).
 LGui,
 -- Right Control.
 RCtrl,
 -- Right Shift.
 RShift,
 -- Right Alt (or Alt Gr). 
 RAlt,
 -- Right GUI (the Windows key).
 RGui, -- 0xE7
 -- Unofficial
 MediaPlayPause, -- 0xE8,
 MediaStopCD,
 MediaPreviousSong,
 MediaNextSong,
 MediaEjectCD,
 MediaVolUp,
 MediaVolDown,
 MediaMute,
 MediaWWW, -- 0xF0
 MediaBack,
 MediaForward,
 MediaStop,
 MediaFind,
 MediaScrollUp,
 MediaScrollDown,
 MediaEdit,
 MediaSleep,
 MediaCoffee,
 MediaRefresh,
 MediaCalc -- 0xFB
 );
 type Action_Type is (Key, No_Op, Trans, Layer, Multiple_Actions);
 -- Should be a discriminated type
 type Action is record
 T : Action_Type; -- hould be the discriminant
 C : Key_Code_T;
 L : Natural;
 end record;
 function Kw (Code : Key_Code_T) return Action;
 function Lw (V : Natural) return Action;
 type Key_Modifiers is array (Natural range <>) of USB.Device.HID.Keyboard.Modifiers;
 type Key_Codes_T is array (Natural range <>) of Key_Code_T;
 subtype Ac is Action;
 type Layout is array (0 .. Num_Layers - 1, RowR, ColR) of Action;
 procedure Register_Events (L : Layout; Es : Events);
 procedure Tick (L : Layout);
 function Get_Key_Codes return Key_Codes_T;
 function Get_Modifiers return Key_Modifiers;
 procedure Init;
end Click;

View file

@ -0,0 +1,29 @@
with "config/click_config.gpr";
project Click is
 for Library_Name use "Click";
 for Library_Version use Project'Library_Name & ".so." & Click_Config.Crate_Version;
 for Source_Dirs use ("src/", "config/");
 for Object_Dir use "obj/" & Click_Config.Build_Profile;
 for Create_Missing_Dirs use "True";
 for Library_Dir use "lib";
 type Library_Type_Type is ("relocatable", "static", "static-pic");
 Library_Type : Library_Type_Type :=
 external ("CLICK_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
 for Library_Kind use Library_Type;
 package Compiler is
 for Default_Switches ("Ada") use Click_Config.Ada_Compiler_Switches & ("-gnatX", "-gnat2022");
 end Compiler;
 package Binder is
 for Switches ("Ada") use ("-Es"); -- Symbolic traceback
 end Binder;
 package Install is
 for Artifacts (".") use ("share");
 end Install;
end Click;

View file

@ -0,0 +1,23 @@
The files `click.adb`, `click.ads` and `click.gpr` have been added from https://github.com/dkm/click under the following license:
MIT License
Copyright (c) 2022 Marc Poulhiès <dkm@kataplop.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

308
tests/syntax-tests/source/Ada/click.adb vendored Normal file
View file

@ -0,0 +1,308 @@
with Chests.Ring_Buffers;
with USB.Device.HID.Keyboard;
package body Click is
----------------
-- DEBOUNCE --
----------------
-- Ideally, in a separate package.
-- should be [], but not fixed yet in GCC 11.
Current_Status : Key_Matrix := [others => [others => False]];
New_Status : Key_Matrix := [others => [others => False]];
Since : Natural := 0;
-- Nb_Bounce : Natural := 5;
function Update (NewS : Key_Matrix) return Boolean is
begin
-- The new state is the same as the current stable state => Do nothing.
if Current_Status = NewS then
Since := 0;
return False;
end if;
if New_Status /= NewS then
-- The new state differs from the previous
-- new state (bouncing) => reset
New_Status := NewS;
Since := 1;
else
-- The new state hasn't changed since last
-- update => towards stabilization.
Since := Since + 1;
end if;
if Since > Nb_Bounce then
declare
Tmp : constant Key_Matrix := Current_Status;
begin
-- New state has been stable enough.
-- Latch it and notifies caller.
Current_Status := New_Status;
New_Status := Tmp;
Since := 0;
end;
return True;
else
-- Not there yet
return False;
end if;
end Update;
procedure Get_Matrix;
-- Could use := []; but GNAT 12 has a bug (fixed in upcoming 13)
Read_Status : Key_Matrix := [others => [others => False]];
function Get_Events return Events is
Num_Evt : Natural := 0;
New_S : Key_Matrix renames Read_Status;
begin
Get_Matrix;
if Update (New_S) then
for I in Current_Status'Range (1) loop
for J in Current_Status'Range (2) loop
if (not New_Status (I, J) and then Current_Status (I, J))
or else (New_Status (I, J) and then not Current_Status (I, J))
then
Num_Evt := Num_Evt + 1;
end if;
end loop;
end loop;
declare
Evts : Events (Natural range 1 .. Num_Evt);
Cursor : Natural range 1 .. Num_Evt + 1 := 1;
begin
for I in Current_Status'Range (1) loop
for J in Current_Status'Range (2) loop
if not New_Status (I, J)
and then Current_Status (I, J)
then
-- Pressing I, J
Evts (Cursor) := [
Evt => Press,
Col => I,
Row => J
];
Cursor := Cursor + 1;
elsif New_Status (I, J)
and then not Current_Status (I, J)
then
-- Release I, J
Evts (Cursor) := [
Evt => Release,
Col => I,
Row => J
];
Cursor := Cursor + 1;
end if;
end loop;
end loop;
return Evts;
end;
end if;
return [];
end Get_Events;
procedure Get_Matrix is -- return Key_Matrix is
begin
for Row in Keys.Rows'Range loop
Keys.Rows (Row).Clear;
for Col in Keys.Cols'Range loop
Read_Status (Col, Row) := not Keys.Cols (Col).Set;
end loop;
Keys.Rows (Row).Set;
end loop;
end Get_Matrix;
-- End of DEBOUNCE
--------------
-- Layout --
--------------
package Events_Ring_Buffers is new Chests.Ring_Buffers
(Element_Type => Event,
Capacity => 16);
Queued_Events : Events_Ring_Buffers.Ring_Buffer;
type Statet is (Normal_Key, Layer_Mod, None);
type State is record
Typ : Statet;
Code : Key_Code_T;
Layer_Value : Natural;
-- Col : ColR;
-- Row : RowR;
end record;
type State_Array is array (ColR, RowR) of State;
States : State_Array := [others => [others => (Typ => None, Code => No, Layer_Value => 0)]];
function Kw (Code : Key_Code_T) return Action is
begin
return (T => Key, C => Code, L => 0);
end Kw;
function Lw (V : Natural) return Action is
begin
return (T => Layer, C => No, L => V);
end Lw;
-- FIXME: hardcoded max number of events
subtype Events_Range is Natural range 0 .. 60;
type Array_Of_Reg_Events is array (Events_Range) of Event;
Stamp : Natural := 0;
procedure Register_Events (L : Layout; Es : Events) is
begin
Stamp := Stamp + 1;
Log ("Reg events: " & Stamp'Image);
Log (Es'Length'Image);
for E of Es loop
declare
begin
if Events_Ring_Buffers.Is_Full (Queued_Events) then
raise Program_Error;
end if;
Events_Ring_Buffers.Append (Queued_Events, E);
end;
-- Log ("Reg'ed events:" & Events_Mark'Image);
Log ("Reg'ed events:" & Events_Ring_Buffers.Length (Queued_Events)'Image);
end loop;
end Register_Events;
procedure Release (Col: Colr; Row: Rowr) is
begin
if States (Col, Row).Typ = None then
raise Program_Error;
end if;
States (Col, Row) := (Typ => None, Code => No, Layer_Value => 0);
end Release;
function Get_Current_Layer return Natural is
L : Natural := 0;
begin
for S of States loop
if S.Typ = Layer_Mod then
L := L + S.Layer_Value;
end if;
end loop;
return L;
end Get_Current_Layer;
-- Tick the event.
-- Returns TRUE if it needs to stay in the queued events
-- FALSE if the event has been consumed.
function Tick (L: Layout; E : in out Event) return Boolean is
Current_Layer : Natural := Get_Current_Layer;
A : Action renames L (Current_Layer, E.Row, E.Col);
begin
case E.Evt is
when Press =>
case A.T is
when Key =>
States (E.Col, E.Row) :=
(Typ => Normal_Key,
Code => A.C,
Layer_Value => 0);
when Layer =>
States (E.Col, E.Row) := (Typ => Layer_Mod, Layer_Value => A.L, Code => No);
when others =>
raise Program_Error;
end case;
when Release =>
Release (E.Col, E.Row);
end case;
return False;
end Tick;
Last_Was_Empty_Log : Boolean := False;
procedure Tick (L : Layout) is
begin
for I in 1 .. Events_Ring_Buffers.Length(Queued_Events) loop
declare
E : Event := Events_Ring_Buffers.Last_Element (Queued_Events);
begin
Events_Ring_Buffers.Delete_Last (Queued_Events);
if Tick (L, E) then
Events_Ring_Buffers.Prepend (Queued_Events, E);
end if;
end;
end loop;
if not Last_Was_Empty_Log or else Events_Ring_Buffers.Length(Queued_Events) /= 0 then
Log ("End Tick layout, events: " & Events_Ring_Buffers.Length(Queued_Events)'Image);
Last_Was_Empty_Log := Events_Ring_Buffers.Length(Queued_Events) = 0;
end if;
end Tick;
function Get_Key_Codes return Key_Codes_T is
Codes : Key_Codes_T (0 .. 10);
Wm: Natural := 0;
begin
for S of States loop
if S.Typ = Normal_Key and then
(S.Code < LCtrl or else S.Code > RGui)
then
Codes (Wm) := S.Code;
Wm := Wm + 1;
end if;
end loop;
if Wm = 0 then
return [];
else
return Codes (0 .. Wm - 1);
end if;
end Get_Key_Codes;
function Get_Modifiers return Key_Modifiers is
use USB.Device.HID.Keyboard;
KM : Key_Modifiers (1..8);
I : Natural := 0;
begin
for S of States loop
if S.Typ = Normal_Key then
I := I + 1;
case S.Code is
when LCtrl =>
KM(I) := Ctrl_Left;
when RCtrl =>
KM(I) := Ctrl_Right;
when LShift =>
KM(I) := Shift_Left;
when RShift =>
KM(I) := Shift_Right;
when LAlt =>
KM(I) := Alt_Left;
when RAlt =>
KM(I) := Alt_Right;
when LGui =>
KM(I) := Meta_Left;
when RGui =>
KM(I) := Meta_Right;
when others =>
I := I - 1;
end case;
end if;
end loop;
return KM (1..I);
end Get_Modifiers;
procedure Init is
begin
Events_Ring_Buffers.Clear (Queued_Events);
end Init;
end Click;

339
tests/syntax-tests/source/Ada/click.ads vendored Normal file
View file

@ -0,0 +1,339 @@
with HAL.GPIO;
with USB.Device.HID.Keyboard;
generic
Nb_Bounce : Natural;
type ColR is (<>);
type RowR is (<>);
type GPIOP is new HAL.GPIO.GPIO_Point with private;
type Cols_T is array (ColR) of GPIOP;
type Rows_T is array (RowR) of GPIOP;
Cols : Cols_T;
Rows : Rows_T;
Num_Layers : Natural;
with procedure Log (S : String; L : Integer := 1; Deindent : Integer := 0);
package Click is
type Keys_T is record
Cols : Cols_T;
Rows : Rows_T;
end record;
Keys : Keys_T :=
(Rows => Rows, Cols => Cols);
type Key_Matrix is array (ColR, RowR) of Boolean;
--------------------------
-- Events & Debouncing --
--------------------------
MaxEvents : constant Positive := 20;
type EventT is (Press, Release);
type Event is record
Evt : EventT;
Col : ColR;
Row : RowR;
end record;
type Events is array (Natural range <>) of Event;
function Get_Events return Events;
function Update (NewS : Key_Matrix) return Boolean;
-------------
-- Layout --
-------------
---------------
-- Keycodes --
---------------
-- Keycodes copy/pasted from the excelent Keyberon Rust firmware:
-- https://github.com/TeXitoi/keyberon/
type Key_Code_T is
(
-- The "no" key, a placeholder to express nothing.
No, -- = 0x00,
-- / Error if too much keys are pressed at
-- the same time.
ErrorRollOver,
-- / The POST fail error.
PostFail,
-- / An undefined error occured.
ErrorUndefined,
-- / `a` and `A`.
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M, -- 0x10
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
-- `1` and `!`.
Kb1,
-- `2` and `@`.
Kb2,
-- `3` and `#`.
Kb3, -- 0x20
-- / `4` and `$`.
Kb4,
-- `5` and `%`.
Kb5,
-- `6` and `^`.
Kb6,
-- `7` and `&`.
Kb7,
-- `8` and `*`.
Kb8,
-- `9` and `(`.
Kb9,
-- `0` and `)`.
Kb0,
Enter,
Escape,
BSpace,
Tab,
Space,
-- `-` and `_`.
Minus,
-- `=` and `+`.
Equal,
-- `[` and `{`.
LBracket,
-- `]` and `}`.
RBracket, -- 0x30
-- / `\` and `|`.
Bslash,
-- Non-US `#` and `~` (Typically near the Enter key).
NonUsHash,
-- `;` and `:`.
SColon,
-- `'` and `"`.
Quote,
-- How to have ` as code?
-- \` and `~`.
Grave,
-- `,` and `<`.
Comma,
-- `.` and `>`.
Dot,
-- `/` and `?`.
Slash,
CapsLock,
F1,
F2,
F3,
F4,
F5,
F6,
F7, -- 0x40
F8,
F9,
F10,
F11,
F12,
PScreen,
ScrollLock,
Pause,
Insert,
Home,
PgUp,
Delete,
Endd,
PgDown,
Right,
Left, -- 0x50
Down,
Up,
NumLock,
-- Keypad `/`
KpSlash,
-- Keypad `*`
KpAsterisk,
-- Keypad `-`.
KpMinus,
-- Keypad `+`.
KpPlus,
-- Keypad enter.
KpEnter,
-- Keypad 1.
Kp1,
Kp2,
Kp3,
Kp4,
Kp5,
Kp6,
Kp7,
Kp8, -- 0x60
Kp9,
Kp0,
KpDot,
-- Non-US `\` and `|` (Typically near the Left-Shift key)
NonUsBslash,
Application, -- 0x65
-- / not a key, used for errors
Power,
-- Keypad `=`.
KpEqual,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21, -- 0x70
F22,
F23,
F24,
Execute,
Help,
Menu,
Selectt,
Stop,
Again,
Undo,
Cut,
Copy,
Paste,
Find,
Mute,
VolUp, -- 0x80
VolDown,
-- Deprecated.
LockingCapsLock,
-- Deprecated.
LockingNumLock,
-- Deprecated.
LockingScrollLock,
-- / Keypad `,`, also used for the
-- brazilian keypad period (.) key.
KpComma,
-- Used on AS/400 keyboard
KpEqualSign,
Intl1,
Intl2,
Intl3,
Intl4,
Intl5,
Intl6,
Intl7,
Intl8,
Intl9,
Lang1, -- 0x90
Lang2,
Lang3,
Lang4,
Lang5,
Lang6,
Lang7,
Lang8,
Lang9,
AltErase,
SysReq,
Cancel,
Clear,
Prior,
Returnn,
Separator,
Outt, -- 0xA0
Oper,
ClearAgain,
CrSel,
ExSel,
-- According to QMK, 0xA5-0xDF are not
-- usable on modern keyboards
-- Modifiers
-- Left Control.
LCtrl, -- = 0xE0,
-- / Left Shift.
LShift,
-- Left Alt.
LAlt,
-- Left GUI (the Windows key).
LGui,
-- Right Control.
RCtrl,
-- Right Shift.
RShift,
-- Right Alt (or Alt Gr). 
RAlt,
-- Right GUI (the Windows key).
RGui, -- 0xE7
-- Unofficial
MediaPlayPause, -- 0xE8,
MediaStopCD,
MediaPreviousSong,
MediaNextSong,
MediaEjectCD,
MediaVolUp,
MediaVolDown,
MediaMute,
MediaWWW, -- 0xF0
MediaBack,
MediaForward,
MediaStop,
MediaFind,
MediaScrollUp,
MediaScrollDown,
MediaEdit,
MediaSleep,
MediaCoffee,
MediaRefresh,
MediaCalc -- 0xFB
);
type Action_Type is (Key, No_Op, Trans, Layer, Multiple_Actions);
-- Should be a discriminated type
type Action is record
T : Action_Type; -- hould be the discriminant
C : Key_Code_T;
L : Natural;
end record;
function Kw (Code : Key_Code_T) return Action;
function Lw (V : Natural) return Action;
type Key_Modifiers is array (Natural range <>) of USB.Device.HID.Keyboard.Modifiers;
type Key_Codes_T is array (Natural range <>) of Key_Code_T;
subtype Ac is Action;
type Layout is array (0 .. Num_Layers - 1, RowR, ColR) of Action;
procedure Register_Events (L : Layout; Es : Events);
procedure Tick (L : Layout);
function Get_Key_Codes return Key_Codes_T;
function Get_Modifiers return Key_Modifiers;
procedure Init;
end Click;

29
tests/syntax-tests/source/Ada/click.gpr vendored Normal file
View file

@ -0,0 +1,29 @@
with "config/click_config.gpr";
project Click is
for Library_Name use "Click";
for Library_Version use Project'Library_Name & ".so." & Click_Config.Crate_Version;
for Source_Dirs use ("src/", "config/");
for Object_Dir use "obj/" & Click_Config.Build_Profile;
for Create_Missing_Dirs use "True";
for Library_Dir use "lib";
type Library_Type_Type is ("relocatable", "static", "static-pic");
Library_Type : Library_Type_Type :=
external ("CLICK_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
for Library_Kind use Library_Type;
package Compiler is
for Default_Switches ("Ada") use Click_Config.Ada_Compiler_Switches & ("-gnatX", "-gnat2022");
end Compiler;
package Binder is
for Switches ("Ada") use ("-Es"); -- Symbolic traceback
end Binder;
package Install is
for Artifacts (".") use ("share");
end Install;
end Click;