Merge branch 'master' into improved-benchmark

This commit is contained in:
Ethan P 2021-01-02 21:35:58 -08:00 committed by GitHub
commit 1b549ecc66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
244 changed files with 13830 additions and 1340 deletions

View File

@ -28,11 +28,11 @@ If you're on Windows:
**Describe the bug you encountered:**
...
**Describe what you expected to happen?**
**What did you expect to happen instead?**
...
**How did you install `bat`?**
apt-get, homebrew, GitHub release, etc.
<!-- apt-get, homebrew, GitHub release, etc. -->
---

View File

@ -22,6 +22,12 @@ jobs:
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
default: true
profile: minimal # minimal component installation (ie, no documentation)
components: clippy
- name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features -- --allow clippy::style
- name: Test
uses: actions-rs/cargo@v1
with:
@ -58,6 +64,11 @@ jobs:
with:
command: test
args: --release
- name: Run ignored-by-default unit tests with new syntaxes and themes
uses: actions-rs/cargo@v1
with:
command: test
args: --release -- --ignored
- name: Syntax highlighting regression test
run: tests/syntax-tests/regression_test.sh
- name: List of languages
@ -147,6 +158,8 @@ jobs:
echo ::set-output name=PKG_NAME::${PKG_NAME}
# deployable tag? (ie, leading "vM" or "M"; M == version number)
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
# unset deploy on ubuntu-18.04 x64 - we will deploy the tarball/deb built on ubuntu-16.04 x64
if [ "${{ matrix.job.os }}" = "ubuntu-18.04" ] && [ "${{ matrix.job.target }}" = "x86_64-unknown-linux-gnu" ]; then unset DEPLOY; fi
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
echo ::set-output name=DEPLOY::${DEPLOY}
# DPKG architecture?
@ -302,18 +315,6 @@ jobs:
install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}"
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
# Work out shared library dependencies
# dpkg-shlibdeps requires debian/control file. Dummy it and clean up
mkdir "./debian"
touch "./debian/control"
case ${{ matrix.job.target }} in
aarch64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -l/usr/aarch64-linux-gnu/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
arm-*-linux-*hf) DEPENDS="$(dpkg-shlibdeps -l/usr/arm-linux-gnueabihf/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
i686-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
x86_64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
esac;
rm -rf "./debian"
# Man page
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
@ -380,7 +381,6 @@ jobs:
Maintainer: ${{ env.PROJECT_MAINTAINER }}
Homepage: ${{ env.PROJECT_HOMEPAGE }}
Architecture: ${{ steps.vars.outputs.DPKG_ARCH }}
Depends: $DEPENDS
Provides: ${{ env.PROJECT_NAME }}
Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}
Description: cat(1) clone with wings.

22
.gitmodules vendored
View File

@ -185,9 +185,6 @@
[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
path = assets/syntaxes/02_Extra/AsciiDoc
url = https://github.com/asciidoctor/sublimetext-asciidoc.git
[submodule "assets/themes/gruvbox"]
path = assets/themes/gruvbox
url = https://github.com/peaceant/gruvbox.git
[submodule "assets/syntaxes/02_Extra/GLSL"]
path = assets/syntaxes/02_Extra/GLSL
url = https://github.com/euler0/sublime-glsl
@ -197,3 +194,22 @@
[submodule "assets/syntaxes/02_Extra/Apache"]
path = assets/syntaxes/02_Extra/Apache
url = https://github.com/colinta/ApacheConf.tmLanguage
[submodule "assets/syntaxes/02_Extra/Ninja"]
path = assets/syntaxes/02_Extra/Ninja
url = https://github.com/pope/SublimeNinja.git
[submodule "assets/syntaxes/02_Extra/Svelte"]
path = assets/syntaxes/02_Extra/Svelte
url = https://github.com/corneliusio/svelte-sublime
[submodule "assets/themes/Coldark"]
path = assets/themes/Coldark
url = https://github.com/ArmandPhilippot/coldark-bat.git
[submodule "assets/themes/gruvbox"]
path = assets/themes/gruvbox
url = https://github.com/subnut/gruvbox-tmTheme.git
branch = bat-source
[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/Zig"]
path = assets/syntaxes/02_Extra/Zig
url = https://github.com/ziglang/sublime-zig-language.git

View File

@ -1,21 +1,75 @@
# unreleased
- Add Note to refer to see detailed help with --help (and vice versa with -h). see #1215 (@henil)
## Features
- Use a pager when `bat --list-languages` is called, see #1394 (@stku1985)
## Bugfixes
- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic)
- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube)
- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
- VimL syntax highlighting fix, see #1450 (@esensar)
- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic)
## Other
- Performance improvements, see #1421 (@LovecraftianHorror)
## Syntaxes
- Added Zig syntax, see #1470 (@paulsmith)
- Added Lean syntax, see #1446 (@Julian)
- Added `.resource` extension for Robot Framework files, see #1386
## New themes
- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously usuing `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead.
## `bat` as a library
## Packaging
- `bat` is now available on snapstore with package name called `batcat`, see #1401 (@purveshpatel511)
# v0.17.1
## Bugfixes
- Running `bat` without arguments fails ("output file is also an input"), see #1396
# v0.17.0
## Features
- Added a new `--style` value, `rule`, which adds a simple horizontal ruled line between files, see #1276 (@tommilligan)
- Pass `-S` ("chop long lines") to `less` if `--wrap=never` is set in `bat`, see #1255 (@gahag)
## Bugfixes
- Detect infinite loop when input and output are the same, see #1193 and #1197 (@niklasmohrin)
- Throw an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera)
- Bash syntax highlighting not selected for `*.ebuild` and `*.eclass` files, see #1292 (@sharkdp)
- Fix `zsh` completion when using `-p`, see #1320 (@xzfc)
## Other
- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil)
- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera)
## Syntaxes
- Manpage syntax highlighting has been improved, see #1315 (@keith-hall)
- Add Svelte file syntax, see #1285 (@kjmph)
## New themes
- Coldark, see #1329 (@armandphilippot)
# v0.16.0
## Features

48
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,48 @@
# Contributing
Thank you for considering to contribute to `bat`!
## Add an entry to the changelog
If your contribution changes the behavior of `bat` (as opposed to a typo-fix
in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
and describe your changes. This makes the release process much easier and
therefore helps to get your changes into a new `bat` release faster.
The top of the `CHANGELOG` contains a *"unreleased"* section with a few
subsections (Features, Bugfixes, …). Please add your entry to the subsection
that best describes your change.
Entries follow this format:
```
- Short description of what has been changed, see #123 (@user)
```
Here, `#123` is the number of the original issue and/or your pull request.
Please replace `@user` by your GitHub username.
## Development
Please check out the [Development](https://github.com/sharkdp/bat#development)
section in the README.
## Adding a new feature
Please consider opening a
[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.
## Adding new syntaxes/languages or themes
Before you make a pull request that adds a new syntax or theme, please read
the [Customization](https://github.com/sharkdp/bat#customization) section
in the README first.
If you really think that a particular syntax or theme should be added for all
users, please read the corresponding
[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
first.

813
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,8 @@ description="A cat(1) clone with wings."
homepage = "https://github.com/sharkdp/bat"
license = "MIT/Apache-2.0"
name = "bat"
readme = "README.md"
repository = "https://github.com/sharkdp/bat"
version = "0.16.0"
version = "0.17.1"
exclude = [
"assets/syntaxes/*",
"assets/themes/*",
@ -38,7 +37,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
atty = { version = "0.2.14", optional = true }
ansi_term = "^0.12.1"
ansi_colours = "^1.0"
console = "0.12.0"
console = "0.14.0"
dirs = { version = "3.0", optional = true }
lazy_static = { version = "1.4", optional = true }
wild = { version = "2.0", optional = true }
@ -58,7 +57,7 @@ optional = true
default-features = false
[dependencies.syntect]
version = "4.4.0"
version = "4.5.0"
default-features = false
features = ["parsing", "yaml-load", "dump-load", "dump-create"]
@ -74,8 +73,8 @@ default-features = false
[dev-dependencies]
tempdir = "0.3"
assert_cmd = "1.0.1"
predicates = "1.0.5"
assert_cmd = "1.0.2"
predicates = "1.0.6"
[build-dependencies]
clap = { version = "2.33", optional = true }

137
README.md
View File

@ -38,14 +38,14 @@ characters:
### Automatic paging
`bat` can pipe its own output to a pager (e.g `less`) if the output is too large for one screen.
By default, `bat` pipes its own output to a pager (e.g `less`) if the output is too large for one screen.
If you would rather `bat` work like `cat` all the time (never page output), you can set `--paging=never` as an option, either on the command line or in your configuration file.
If you intend to alias `cat` to `bat` in your shell configuration, you can use `alias cat='bat --paging=never'` to preserve the default behavior.
### File concatenation
#### File concatenation
Oh.. you can also use it to concatenate files :wink:. Whenever
`bat` detects a non-interactive terminal (i.e. when you pipe into another process
or into a file), `bat` will act as a drop-in replacement for `cat` and
fall back to printing the plain file contents.
Even with a pager set, you can still use `bat` to concatenate files :wink:.
Whenever `bat` detects a non-interactive terminal (i.e. when you pipe into another process or into a file), `bat` will act as a drop-in replacement for `cat` and fall back to printing the plain file contents, regardless of the `--pager` option's value.
## How to use
@ -131,7 +131,18 @@ highlighting:
git show v0.6.0:src/main.rs | bat -l rs
```
Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out [`delta`](https://github.com/dandavison/delta).
#### `git diff`
You can combine `bat` with `git diff` to view lines around code changes with proper syntax
highlighting:
```bash
batdiff() {
git diff --name-only --diff-filter=d | xargs bat --diff
}
```
If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras).
If you are looking for more support for git and diff operations, check out [`delta`](https://github.com/dandavison/delta).
#### `xclip`
@ -169,7 +180,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
## Installation
[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
[![Packaging status](https://repology.org/badge/vertical-allrepos/bat-cat.svg)](https://repology.org/project/bat-cat/versions)
### On Ubuntu (using `apt`)
*... and other Debian-based Linux distributions.*
@ -185,7 +196,7 @@ If your Ubuntu/Debian installation is new enough you can simply run:
apt install bat
```
If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
``` bash
mkdir -p ~/.local/bin
@ -200,7 +211,7 @@ the most recent release of `bat`, download the latest `.deb` package from the
[release page](https://github.com/sharkdp/bat/releases) and install it via:
```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux
@ -245,6 +256,13 @@ You can install `bat` via xbps-install:
xbps-install -S bat
```
### On Termux
You can install `bat` via pkg:
```bash
pkg install bat
```
### On FreeBSD
You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
@ -276,6 +294,15 @@ You can install `bat` with zypper:
zypper install bat
```
### Via snap package
```
sudo snap install batcat
```
[Get it from the Snap Store](https://snapcraft.io/batcat)
### On macOS (or Linux) via Homebrew
You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat):
@ -336,7 +363,7 @@ higher. You can then use `cargo` to build everything:
cargo install --locked bat
```
Note that addition files like the man page or shell completion
Note that additional files like the man page or shell completion
files can not be installed in this way. They will be generated by `cargo` and should be available in the cargo target folder (under `build`).
## Customization
@ -363,12 +390,11 @@ You can also use a custom theme by following the
### 8-bit themes
`bat` has four themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
`bat` has three themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
even when truecolor support is available:
- `ansi-dark` looks decent on any terminal with a dark background. It uses 3-bit colors: black, red,
green, yellow, blue, magenta, cyan, and white.
- `ansi-light` is like `ansi-dark`, but for terminals with a light background.
- `ansi` looks decent on any terminal. It uses 3-bit colors: black, red, green,
yellow, blue, magenta, cyan, and white.
- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
4-bit colors (3-bit colors plus bright variants) in accordance with the
[base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
@ -391,35 +417,45 @@ variable to make these changes permanent or use `bat`s
### Adding new syntaxes / language definitions
Should you find that a particular syntax is not available within `bat`, you can follow these
instructions to easily add new syntaxes to your current `bat` installation.
`bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/)
library for syntax highlighting. `syntect` can read any
[Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html)
and theme. To add new syntax definitions, do the following.
and theme.
Create a folder with syntax definition files:
A good resource for finding Sublime Syntax packages is [Package Control](https://packagecontrol.io/). Once you found a
syntax:
```bash
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
1. Create a folder with syntax definition files:
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
git clone https://github.com/tellnobody1/sublime-purescript-syntax
```
```bash
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
Now use the following command to parse these files into a binary cache:
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
git clone https://github.com/tellnobody1/sublime-purescript-syntax
```
```bash
bat cache --build
```
2. Now use the following command to parse these files into a binary cache:
Finally, use `bat --list-languages` to check if the new languages are available.
```bash
bat cache --build
```
If you ever want to go back to the default settings, call:
3. Finally, use `bat --list-languages` to check if the new languages are available.
```bash
bat cache --clear
```
If you ever want to go back to the default settings, call:
```bash
bat cache --clear
```
4. If you think that a specific syntax should be included in `bat` by default, please
consider opening a "syntax request" ticket after reading the policies and
instructions [here](doc/assets.md): [Open Syntax Request](https://github.com/sharkdp/bat/issues/new?labels=syntax-request&template=syntax_request.md).
### Adding new themes
@ -439,6 +475,33 @@ bat cache --build
Finally, use `bat --list-themes` to check if the new themes are available.
### Adding or changing file type associations
You can add new (or change existing) file name patterns using the `--map-syntax`
command line option. The option takes an argument of the form `pattern:syntax` where
`pattern` is a glob pattern that is matched against the file name and
the absolute file path. The `syntax` part is the full name of a supported language
(use `bat --list-languages` for an overview)full .
Note: You probably want to use this option as an entry in `bat`s configuration file instead
of passing it on the command line (see below).
Example: To use "INI" syntax highlighting for all files with a `.conf` file extension, use
```bash
--map-syntax='*.conf:INI'
```
Example: To open all files called `.ignore` (exact match) with the "Git Ignore" syntax, use:
```bash
--map-syntax='.ignore:Git Ignore'
```
Example: To open all `.conf` files in subfolders of `/etc/apache2` with the "Apache Conf"
syntax, use (this mapping is already built in):
```bash
-map-syntax='/etc/apache2/**/*.conf:Apache Conf'
```
### Using a different pager
`bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not
@ -490,6 +553,7 @@ and the `GitHub` theme when in the _light mode_.
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
```
## Configuration file
`bat` can also be customized with a configuration file. The location of the file is dependent
@ -526,9 +590,6 @@ Example configuration file:
# Use C++ syntax for .ino files
--map-syntax "*.ino:C++"
# Use ".gitignore"-style highlighting for ".ignore" files
--map-syntax ".ignore:Git Ignore"
```
## Using `bat` on Windows
@ -630,6 +691,10 @@ bash assets/create.sh
cargo install --path . --locked --force
```
## Contributing
Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
## Maintainers
- [sharkdp](https://github.com/sharkdp)

52
assets/README.md vendored
View File

@ -1,52 +0,0 @@
## Syntax Highlighting in bat
`bat` uses the [syntect](https://github.com/trishume/syntect) library to highlight source
code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions
in the `.sublime-syntax` format.
In order to add new syntaxes to `bat`, follow these steps:
1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository
which can be included as a submodule (under `assets/syntaxes`).
2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in
Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* ->
*New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
3. Run the `create.sh` script. It calls `bat cache --build` to parse all available
`.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
`bat` binary.
5. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
file. A new binary cache file will be created once before every new release of `bat`.
### Troubleshooting
Make sure that the local cache does not interfere with the internally stored syntaxes and
themes (`bat cache --clear`).
### Manual modifications
The following files have been manually modified after converting from a `.tmLanguage` file:
* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
* `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
* `Org mode.sublime-syntax` => removed `task` file type.
* `SML.sublime_syntax` => removed `ml` file type.
### Non-submodule additions
* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems
* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime
* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax
as it is not kept in a standalone repository. The file is generated from
https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage
* `SML.sublime_syntax` has been added manually from
https://github.com/seanjames777/SML-Language-Definitiona as it is not
kept in a standalone repository. The file generated is from
https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
* `Cabal.sublime_syntax` has been added manually from
https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.

View File

@ -3,8 +3,8 @@
local context state state_descr line
typeset -A opt_args
(( $+functions[_cache_subcommand] )) ||
_cache_subcommand() {
(( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) ||
_{{PROJECT_EXECUTABLE}}_cache_subcommand() {
local -a args
args=(
'(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
@ -19,12 +19,12 @@ _cache_subcommand() {
_arguments -S -s $args
}
(( $+functions[_main] )) ||
_main() {
(( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) ||
_{{PROJECT_EXECUTABLE}}_main() {
local -a args
args=(
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
{-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)'
'*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]'
'(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
'(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
'(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
@ -51,13 +51,13 @@ _main() {
_arguments -S -s $args
case "$state" in
case "$state" in
language)
local IFS=$'\n'
local -a languages
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
_describe 'language' languages
_describe 'language' languages
;;
theme)
@ -79,15 +79,15 @@ if (( ${#words} == 2 )); then
local -a subcommands
subcommands=('cache:Modify the syntax-definition and theme cache')
_describe subcommand subcommands
_main
_{{PROJECT_EXECUTABLE}}_main
else
case $words[2] in
cache)
_cache_subcommand
_{{PROJECT_EXECUTABLE}}_cache_subcommand
;;
*)
_main
_{{PROJECT_EXECUTABLE}}_main
;;
esac
fi

View File

@ -129,7 +129,7 @@ Configure which elements (line numbers, file headers, grid borders, Git modifica
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full').
To set a default style, add the '\-\-style=".."' option to the configuration file or
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
values: *auto*, full, plain, changes, header, grid, numbers, snip.
values: *auto*, full, plain, changes, header, grid, rule, numbers, snip.
.HP
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
.IP

View File

@ -0,0 +1,15 @@
diff --git syntaxes/01_Packages/ShellScript/Bash.sublime-syntax syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
index e973e319..a703cef8 100644
--- syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
+++ syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
@@ -30,8 +30,8 @@ file_extensions:
- .zshenv
- .zshrc
- PKGBUILD # https://jlk.fjfi.cvut.cz/arch/manpages/man/PKGBUILD.5
- - .ebuild
- - .eclass
+ - ebuild
+ - eclass
first_line_match: |
(?x)

BIN
assets/syntaxes.bin vendored

Binary file not shown.

@ -1 +1 @@
Subproject commit e593eb6d42a5f1881ba6c75698bd0fb78a9b8871
Subproject commit e23926eca1b6a0bd0b572b7191aead9f77c748d1

@ -1 +1 @@
Subproject commit aba96a0862369e9f960bb63a38e2d7563ea6475e
Subproject commit 21e96989d604d64f12d518f4f17fc71fa3cdc505

@ -1 +1 @@
Subproject commit 4ee539b43d82388f449535f7316d69f5dfeaabb5
Subproject commit 4fb01891dd17434dde42887bc821917a30f4e010

@ -1 +1 @@
Subproject commit c9d84587eb1a6eb34457a875f21b9b1a29306be3
Subproject commit 59304d6c7b5019091b532a3197251e393e1db7b2

View File

@ -25,12 +25,13 @@ contexts:
scope: comment.line.semicolon.ini
captures:
1: punctuation.definition.comment.ini
- match: '^\s*(\[)(.*?)(\])'
- match: '^\s*(\[)(.*?)(\])\s*(;.*)?$\n?'
scope: meta.tag.section.ini
captures:
1: punctuation.definition.section.ini
2: entity.section.ini
3: punctuation.definition.section.ini
4: comment.definition.section.ini
- match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?'
scope: meta.declaration.ini
captures:

@ -1 +1 @@
Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95
Subproject commit e2b1cb549d57368b7b22e79430a1d5f47555e802

1
assets/syntaxes/02_Extra/Lean vendored Submodule

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

View File

@ -0,0 +1,125 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Lean
file_extensions:
- lean
scope: source.lean
contexts:
main:
- include: comments
- match: '\b(?<!\.)(inductive|coinductive|structure|theorem|axiom|axioms|abbreviation|lemma|definition|def|instance|class|constant)\b\s+(\{[^}]*\})?'
captures:
1: keyword.other.definitioncommand.lean
push:
- meta_scope: meta.definitioncommand.lean
- match: '(?=\bwith\b|\bextends\b|[:\|\(\[\{⦃<>])'
pop: true
- include: comments
- include: definitionName
- match: ","
- match: \b(Prop|Type|Sort)\b
scope: storage.type.lean
- match: '\battribute\b\s*\[[^\]]*\]'
scope: storage.modifier.lean
- match: '@\[[^\]]*\]'
scope: storage.modifier.lean
- match: \b(?<!\.)(private|meta|mutual|protected|noncomputable)\b
scope: keyword.control.definition.modifier.lean
- match: \b(sorry)\b
scope: invalid.illegal.lean
- match: '#print\s+(def|definition|inductive|instance|structure|axiom|axioms|class)\b'
scope: keyword.other.command.lean
- match: '#(print|eval|reduce|check|help|exit|find|where)\b'
scope: keyword.other.command.lean
- match: \b(?<!\.)(import|export|prelude|theory|definition|def|abbreviation|instance|renaming|hiding|exposing|parameter|parameters|begin|constant|constants|lemma|variable|variables|theorem|example|open|axiom|inductive|coinductive|with|structure|universe|universes|alias|precedence|reserve|postfix|prefix|infix|infixl|infixr|notation|end|using|namespace|section|local|set_option|extends|include|omit|class|classes|instances|raw|run_cmd|restate_axiom)(?!\.)\b
scope: keyword.other.lean
- match: \b(?<!\.)(calc|have|this|match|do|suffices|show|by|in|at|let|forall|fun|exists|assume|from|obtain|haveI|λ)(?!\.)\b
scope: keyword.other.lean
- match: «
push:
- meta_content_scope: entity.name.lean
- match: »
pop: true
- match: \b(?<!\.)(if|then|else)\b
scope: keyword.control.lean
- match: '"'
captures:
0: punctuation.definition.string.begin.lean
push:
- meta_scope: string.quoted.double.lean
- match: '"'
captures:
0: punctuation.definition.string.end.lean
pop: true
- match: '\\[\\"nt'']'
scope: constant.character.escape.lean
- match: '\\x[0-9A-Fa-f][0-9A-Fa-f]'
scope: constant.character.escape.lean
- match: '\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'
scope: constant.character.escape.lean
- match: '''[^\\'']'''
scope: string.quoted.single.lean
- match: '''(\\(x..|u....|.))'''
scope: string.quoted.single.lean
captures:
1: constant.character.escape.lean
- match: '`+[^\[(]\S+'
scope: entity.name.lean
- match: '\b([0-9]+|0([xX][0-9a-fA-F]+))\b'
scope: constant.numeric.lean
blockComment:
- match: /-
push:
- meta_scope: comment.block.lean
- match: "-/"
pop: true
- include: scope:source.lean.markdown
- include: blockComment
comments:
- include: dashComment
- include: docComment
- include: stringBlock
- include: modDocComment
- include: blockComment
dashComment:
- match: (--)
captures:
0: punctuation.definition.comment.lean
push:
- meta_scope: comment.line.double-dash.lean
- match: $
pop: true
- include: scope:source.lean.markdown
definitionName:
- match: '\b[^:«»\(\)\{\}[:space:]=→λ∀?][^:«»\(\)\{\}[:space:]]*'
scope: entity.name.function.lean
- match: «
push:
- meta_content_scope: entity.name.function.lean
- match: »
pop: true
docComment:
- match: /--
push:
- meta_scope: comment.block.documentation.lean
- match: "-/"
pop: true
- include: scope:source.lean.markdown
- include: blockComment
modDocComment:
- match: /-!
push:
- meta_scope: comment.block.documentation.lean
- match: "-/"
pop: true
- include: scope:source.lean.markdown
- include: blockComment
stringBlock:
- match: /-"
push:
- meta_scope: comment.block.string.lean
- match: '"-/'
pop: true
- include: scope:source.lean.markdown
- include: blockComment

View File

@ -7,47 +7,157 @@ file_extensions:
scope: source.man
variables:
section_heading: '^\S.*$'
section_heading: '^(?!#)\S.*$'
command_line_option: '(--?[A-Za-z0-9][_A-Za-z0-9-]*)'
contexts:
prototype:
# ignore syntax test lines
- match: '^#'
push:
- meta_scope: comment.syntax-test.man
- match: $\n?
pop: true
main:
- match: ^
push: first_line
first_line:
- match: '([A-Z0-9_\-]+)(\()([^)]+)(\))'
- match: '([A-Z0-9_\-]+)(\()([^)]+)(\))\s*'
captures:
1: meta.preprocessor
2: keyword.operator
3: string.quoted.other
4: keyword.operator
- match: '$'
push: body
body:
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
1: meta.preprocessor.man
2: keyword.operator.man
3: string.quoted.other.man
4: keyword.operator.man
push:
- match: (?:[\w'-]+|\s(?!\s))
scope: markup.heading.title.man
- match: \s\s
pop: true
- match: '(?=\S|$)'
pop: true
- match: '^\S.*$'
scope: markup.heading
- match: '$'
set: body
body:
# English, ..., ..., ..., Russian, ...
- match: '^(?:SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
scope: markup.heading.synopsis.man
embed: synopsis
escape: '(?={{section_heading}})'
- match: '^(?:USAGE)'
scope: markup.heading.synopsis.man
embed: synopsis
escape: '(?={{section_heading}})'
- match: '{{section_heading}}'
scope: markup.heading.other.man
embed: options # some man pages put command line options under the description heading
escape: '(?={{section_heading}})'
function-call:
- match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
captures:
1: entity.name.function
2: keyword.operator
3: constant.numeric
4: keyword.operator
1: entity.name.function.man
2: keyword.operator.man
3: constant.numeric.man
4: keyword.operator.man
options:
# command-line options like --option=value, --some-flag, or -x
- match: '(?:[^a-zA-Z0-9_-]|^|\s)(--?[A-Za-z0-9][A-Za-z0-9-]*)(?:(=)?("?)([A-Za-z0-9]+)("?))?'
- match: '^[ ]{7}(?=-)'
push: expect-command-line-option
- match: '(?:[^a-zA-Z0-9_-]|^|\s){{command_line_option}}'
captures:
1: entity.name
2: keyword.operator
3: punctuation.definition.string.begin
4: variable.parameter
3: punctuation.definition.string.end
1: entity.name.command-line-option
push:
- match: '='
scope: keyword.operator.man
set:
- match: '[^],.() ]+'
scope: variable.parameter.man
pop: true
- match: $
pop: true
- match: ''
pop: true
- include: function-call
- include: c-code
expect-command-line-option:
- match: '[A-Za-z0-9-]+'
scope: entity.name.command-line-option.man
- match: '(\[)(=)'
captures:
1: punctuation.section.brackets.begin.man
2: keyword.operator.man
push: [command-line-option-or-pipe, expect-parameter]
- match: '\['
push:
- meta_scope: entity.name.command-line-option.man
- match: '\]'
pop: true
- match: '='
scope: keyword.operator.man
push: expect-parameter
- match: (?=.*\.)
pop: true
- match: '\s'
push: expect-parameter
- match: '(,)\s*'
captures:
1: punctuation.separator.man
- match: $|(?=\])
pop: true
expect-parameter:
- match: '[A-Za-z0-9-]+'
scope: variable.parameter.man
- match: (?=\s+\|)
pop: true
- match: \|
scope: keyword.operator.logical.man
- match: '\['
scope: punctuation.section.brackets.begin.man
push:
- match: '\]'
scope: punctuation.section.brackets.end.man
pop: true
- include: expect-parameter
- match: '$|(?=[],]|{{command_line_option}})'
pop: true
c-code:
- match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))'
embed: scope:source.c
#embed_scope: source.c.embedded.man
#escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b))
escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z])))
synopsis:
- include: c-code
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe
- include: options
command-line-option-or-pipe:
- match: (\|)\s*
captures:
1: keyword.operator.logical.man
#- match: (?={{command_line_option}})
- match: \w+-\w+
- match: (?=-)
push:
- match: (?=\s*\|)
pop: true
- include: expect-command-line-option
- match: \]
scope: punctuation.section.brackets.end.man
pop: true
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe

1
assets/syntaxes/02_Extra/Ninja vendored Submodule

@ -0,0 +1 @@
Subproject commit 25830aaec9316b7fca6600000535214164525d7a

View File

@ -0,0 +1,52 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Ninja
file_extensions:
- ninja
scope: source.ninja
contexts:
main:
- match: (#).*$\n?
comment: Comment line.
scope: comment.line.number-sign.ninja
captures:
1: punctuation.definition.comment.ninja
- match: ^(rule)\b
comment: Rule keyword and keywords for a rule.
captures:
1: keyword.other.ninja
push:
- match: ^(?=\S)
pop: true
- include: main
- match: \b(?:command|deps|depfile|description|generator|pool|restat|rspfile|rspfile_content)\b
scope: keyword.other.ninja
- match: ^(pool)\b
comment: Pool keyword and keywords for a pool.
captures:
1: keyword.other.ninja
push:
- match: ^(?=\S)
pop: true
- include: main
- match: \b(?:depth)\b
scope: keyword.other.ninja
- match: ^(?:build|rule|default|include|subninja)\b
comment: Other Keywords.
scope: keyword.other.ninja
- match: '(?:[=:]|\|{1,2})(?=\s)'
comment: Operators for variable assignment (=), rule definition (:), implicit (|) and order only (||) dependencies.
scope: keyword.operator.ninja
- match: \$$
comment: Line wrap.
scope: keyword.operator.ninja
- match: \$\$
comment: Dollar literal.
scope: keyword.operator.ninja
- match: '\$[[:alnum:]_-]+'
comment: Simple variables, e.g. $var.
scope: variable.other.ninja
- match: '\${[[:alnum:]_.-]+}'
comment: "Variables, e.g. ${some.var.name}."
scope: variable.other.ninja

View File

@ -1,9 +1,10 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Robot Framework syntax highlighting.
name: Robot Framework
file_extensions:
- robot
- resource
scope: source.robot
contexts:
main:

@ -1 +1 @@
Subproject commit bc6332c1be2c5590d334a2a58d3b83a8d07ac7ef
Subproject commit 4868322030c3644d6b8cfff68c85849789d9bdb2

1
assets/syntaxes/02_Extra/Svelte vendored Submodule

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

@ -1 +1 @@
Subproject commit 64208ea816d940e4b9c93f4a6b67d64c02a09825
Subproject commit 54d8350c3c5929c921ea7561c932aa15e7d96c48

@ -1 +1 @@
Subproject commit 603ebb48b162bc453a0bb2cbb0192f3606819f6d
Subproject commit a607ddfec90648c1c2f33f8306733f6aec5d2b78

@ -1 +1 @@
Subproject commit ed40c3bc814cd0c8107dbbb8fcd95946b33217f0
Subproject commit 23afc890977bb1fd43fd05e7d983f994993d4982

View File

@ -75,10 +75,10 @@ contexts:
- match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
scope: string.quoted.single.viml
string_regex:
- match: '/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
- match: '[gvs]{1}/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
scope: string.regexp.viml
support_function:
- match: \b(set(local|global)?|let|command|filetype|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
- match: \b(set(local|global)?|let|command|filetype|syntax|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
scope: support.function.viml
support_type:
- match: <.*?>

1
assets/syntaxes/02_Extra/Zig vendored Submodule

@ -0,0 +1 @@
Subproject commit 87ecbcae6fb5718369ce3bb3472ca0b2634e78e6

@ -1 +1 @@
Subproject commit 1ddcb320aca1bf31b0048a3109540475d5af64e2
Subproject commit 201816b609abf7ccf583f7e888f6dc4121410d70

View File

@ -0,0 +1,151 @@
# SYNTAX TEST "Manpage.sublime-syntax"
SOMETHING(8) System Manager's Manual SOMETHING(8)
# ^^^^^ meta.preprocessor
# ^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.title
# ^^^^^^^ meta.preprocessor
NAME
#^^^ markup.heading.other
example - do something useful
SYNOPSIS
example [options] [--home DIR] [--shell SHELL] [--no-create-home]
# ^ punctuation.section.brackets.begin
# ^^^^^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ punctuation.section.brackets.end
# ^ punctuation.section.brackets.begin
# ^^^^^^^ entity.name.command-line-option
# ^^^^^ variable.parameter
# ^ punctuation.section.brackets.end
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
[-u | --set-upstream] [-o <string> | --push-option=<string>]
# ^ punctuation.section.brackets.begin
# ^^ entity.name.command-line-option
# ^ keyword.operator.logical
# ^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.command-line-option
[--force-with-lease[=<refname>[:<expect>]]]
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.begin
# ^ keyword.operator
# ^^^^^^^ variable.parameter
# ^ punctuation.section.brackets.begin
# ^^^^^^ variable.parameter
# ^^^ punctuation.section.brackets.end
example --system [options]
# ^^^^^^^^ entity.name
COMMON OPTIONS
[--quiet] [--debug] [--help|-h] [--version] [--conf FILE]
/* According to POSIX.1-2001, POSIX.1-2008 */
# ^^ source.c comment.block punctuation.definition.comment
#include <sys/select.h>
# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
struct timeval {
# ^^^^^^ source.c storage.type
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
DESCRIPTION
example does something useful in relation to the command line options
and configuration information in /etc/example.conf.
OPTIONS
--conf FILE
# ^^^^^^ entity.name.command-line-option
#^^^^^^ - variable - entity - markup
# ^^^^ variable.parameter
Use FILE instead of /etc/example.conf.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable - entity
--disabled-login
Do not run passwd to set the password. The user won't be able
to use her account until the password is set.
--disabled-password
Like --disabled-login, but logins are still possible (for exam-
# ^^^^^^^^^^^^^^^^ entity.name
#^^^^^^^^^^^^^^^^^^ - entity - variable - markup
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - entity - variable - markup
ple using SSH RSA keys) but not using password authentication.
--help Display brief instructions.
# ^^^^^^ entity.name.command-line-option
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable.parameter
--home DIR
# ^^^^^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ - variable - entity - markup
Use DIR as the user's home directory, rather than the default
specified by the configuration file. If the directory does not
exist, it is created and skeleton files are copied.
--[no-]signed, --signed=(true|false|if-asked)
# ^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^^^^^^^ entity.name.command-line-option
# ^ keyword.operator
# ^ - variable
# ^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^^^^ variable.parameter
# ^ - variable
--no-recurse-submodules, --recurse-submodules=check|on-demand|only|no
# ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ keyword.operator
# ^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^ variable.parameter
May be used to make sure all submodule commits used by the
-c, -C NUM, --context[=NUM]
# ^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ punctuation.separator
# ^^^^^^^^^ entity.name.command-line-option
# ^^^^^^^ - entity.name
# ^ keyword.operator
# ^^^ variable.parameter
# ^^ - variable
output NUM (default 3) lines of copied context
EXAMPLE
#include <stdio.h>
# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
(This is not C code.)
# ^^^^^^^^^^^^^^^^^^^^^^ - source.c
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
# ^ source.c punctuation.terminator
The corresponding argument for pselect() has the following type:
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c
#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
EPOLLHUP | EPOLLERR)
# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end

BIN
assets/themes.bin vendored

Binary file not shown.

1
assets/themes/Coldark vendored Submodule

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

View File

@ -1,504 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
palette number from 00 to 0f, and AA is the special value 00 to indicate
that this encoding is being used.
-->
<key>author</key>
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
<key>name</key>
<string>ANSI Light</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#07000000</string>
<key>caret</key>
<string>#00000000</string>
<key>foreground</key>
<string>#00000000</string>
<key>invisibles</key>
<string>#00000000</string>
<key>lineHighlight</key>
<string>#00000000</string>
<key>selection</key>
<string>#00000000</string>
<key>gutter</key>
<string>#07000000</string>
<key>gutterForeground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
<key>scope</key>
<string>entity.name.function, meta.require, support.function.any-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Labels</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>support.class, entity.name.class, entity.name.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
<key>scope</key>
<string>keyword.other.special-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Strings, Inherited Class</string>
<key>scope</key>
<string>string, constant.other.symbol, entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Integers</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Floats</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constants</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tags</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attribute IDs</string>
<key>scope</key>
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Selector</string>
<key>scope</key>
<string>meta.selector</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Headings</string>
<key>scope</key>
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Units</string>
<key>scope</key>
<string>keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>scope</key>
<string>markup.bold, punctuation.definition.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Italic</string>
<key>scope</key>
<string>markup.italic, punctuation.definition.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Code</string>
<key>scope</key>
<string>markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Text</string>
<key>scope</key>
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Url</string>
<key>scope</key>
<string>meta.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Quotes</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Colors</string>
<key>scope</key>
<string>constant.other.color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape Characters</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded</string>
<key>scope</key>
<string>punctuation.section.embedded, variable.interpolation</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#01000000</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Broken</string>
<key>scope</key>
<string>invalid.broken</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#03000000</string>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>

View File

@ -3,14 +3,14 @@
<plist version="1.0">
<dict>
<!--
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
palette number from 00 to 0f, and AA is the special value 00 to indicate
that this encoding is being used.
The colors in this theme are encoded as #RRGGBBAA where:
* If AA is 00, then RR is an ANSI palette number from 00 to 07.
* If AA is 01, the terminal's default fg/bg color is used.
-->
<key>author</key>
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
<key>name</key>
<string>ANSI Dark</string>
<string>ANSI</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>settings</key>
@ -19,32 +19,17 @@
<key>settings</key>
<dict>
<key>background</key>
<string>#00000000</string>
<key>caret</key>
<string>#07000000</string>
<string>#00000001</string>
<key>foreground</key>
<string>#07000000</string>
<key>invisibles</key>
<string>#07000000</string>
<key>lineHighlight</key>
<string>#07000000</string>
<key>selection</key>
<string>#07000000</string>
<string>#00000001</string>
<!--
Explicitly set the gutter color since bat falls back to a
hardcoded DEFAULT_GUTTER_COLOR otherwise.
-->
<key>gutter</key>
<string>#00000000</string>
<string>#00000001</string>
<key>gutterForeground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
<string>#00000001</string>
</dict>
</dict>
<dict>
@ -58,39 +43,6 @@
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
@ -102,17 +54,6 @@
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
@ -146,17 +87,6 @@
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
@ -480,8 +410,6 @@
<dict>
<key>background</key>
<string>#01000000</string>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
@ -493,8 +421,6 @@
<dict>
<key>background</key>
<string>#03000000</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
</array>

@ -1 +1 @@
Subproject commit 26c57ec282abcaa76e57e055f38432bd827ac34e
Subproject commit c2de0acf5af67042393cf70de68013153c043656

@ -1 +1 @@
Subproject commit e3db74d0e5de7bc09cab76377723ccf6bcc64e8c
Subproject commit 64c47250e54298b91e2cf8d401320009aba9f991

@ -1 +1 @@
Subproject commit 3aa42a39ed3cddde0c53976a700b81b8a7067890
Subproject commit 89923117bc49dd1e0c6b7fdd34bc6dc4d425fe1f

@ -1 +1 @@
Subproject commit cb746f69624e635f6f4d127fa9244658e690c34b
Subproject commit 7f6fb86e0dcdd06d3c5181ad1cbe94c970834143

10
diagnostics/info.sh vendored
View File

@ -58,7 +58,8 @@ _bat_:run() {
_out "$BAT" --version
_out env | grep '^BAT_\|^PAGER='
local cache_dir="$($BAT --cache-dir)"
local cache_dir
cache_dir="$($BAT --cache-dir)"
if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
_print_command "$BAT" "--list-languages"
echo "Found custom syntax set."
@ -79,8 +80,8 @@ _bat_config_:run() {
_bat_wrapper_:run() {
_bat_wrapper_:detect_wrapper() {
local bat="$1"
if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
_out_fence cat "$(which "${bat}")"
if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then
_out_fence cat "$(command -v "${bat}")"
return
fi
@ -104,7 +105,8 @@ _bat_wrapper_function_:run() {
fi ;;
*bash* | *zsh*)
local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
local type
type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
if grep 'function' <<< "$type" &> /dev/null; then
_out_fence "$SHELL" --login -i -c "declare -f ${command}"
return

View File

@ -191,7 +191,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
次の方法でインストールします:
```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux

View File

@ -170,7 +170,7 @@ apt install bat
만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux

View File

@ -185,7 +185,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
[release page](https://github.com/sharkdp/bat/releases) и установить так:
```bash
sudo dpkg -i bat_0.16.0_amd64.deb # измените архитектуру и версию
sudo dpkg -i bat_0.17.1_amd64.deb # измените архитектуру и версию
```
### Alpine Linux

97
doc/assets.md Normal file
View File

@ -0,0 +1,97 @@
## Adding new builtin languages for syntax highlighting
Should you find that a particular syntax is not available within `bat` and think it should be included in `bat` by default, you can follow the instructions outlined below.
`bat` uses the excellent [syntect](https://github.com/trishume/syntect) library to highlight source
code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions
in the `.sublime-syntax` format.
**Important:** Before proceeding, verify that the syntax you wish to add meets the [criteria for inclusion](#Criteria-for-inclusion-of-new-syntaxes).
1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository
which can be included as a submodule (under `assets/syntaxes`).
2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in
Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* ->
*New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
3. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available
`.sublime-syntax` files and serialize them to a `syntaxes.bin` file.
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.
6. Add a syntax test for the new language. See [#Syntax-tests](below) for details.
7. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
file. A new binary cache file will be created once before every new release of `bat`.
### Syntax tests
`bat` has a set of syntax highlighting regression tests in `tests/syntax-tests`. The main idea is
make sure that we do not run into issues we had in the past where either (1) syntax highlighting
for some language is suddenly not working anymore or (2) `bat` suddenly crashes for some input (due
to `regex` incompatibilities between `syntect` and Sublime Text).
In order to add a new test file, please follow these steps (let's take "Ruby" as an example):
1. Make sure that you are running the **latest version of `bat`** and that `bat` is available on
the path. If you are creating a syntax test for a new builtin syntax (see above), make sure that
your version of `bat` already has the new syntax builtin.
2. Find an example Ruby source file or write one yourself. If possible, the file should aim to be
"comprehensive" (i.e. include a lot of the possible syntax), but this is not strictly necessary.
A simple file is better than none at all. Also, the files shouldn't be gigantic.
3. Save the file in `tests/syntax-tests/source/Ruby` (adapt for your language). The file name could
be `test.rb` (adapt extension) but can also be adapted if that is necessary in order for `bat` to
highlight it correctly (e.g. `Makefile`).
4. If you have copied the file from somewhere else, please make sure that the file *may* be copied
under the respective license and that the license is compatible with `bat`s license. If it
requires attribution, please add a `LICENSE.md` in the same folder with a text like this:
```
The `test.rb` file has been added from [enter source here] under the following license:
[add license text here]
```
5. Go to `tests/syntax-tests` and run the `update.sh` Bash script. A new file should be generated
in the `highlighted` folder (e.g. `highlighted/Ruby/test.rb`).
6. Use `cat` or `bat --language=txt` to display the content of this file and make sure that the
syntax highlighting looks correct.
7. `git add` the new files in the `source` folder as well as the autogenerated files in the
`highlighted` folder.
### Troubleshooting
Make sure that the local cache does not interfere with the internally stored syntaxes and
themes (`bat cache --clear`).
## Criteria for inclusion of new syntaxes
* More than 10,000 downloads on packagecontrol.io/
### Manual modifications
The following files have been manually modified after converting from a `.tmLanguage` file:
* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
* `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
* `Org mode.sublime-syntax` => removed `task` file type.
* `SML.sublime_syntax` => removed `ml` file type.
* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension
### Non-submodule additions
* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems
* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime
* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax
as it is not kept in a standalone repository. The file is generated from
https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage
* `SML.sublime_syntax` has been added manually from
https://github.com/seanjames777/SML-Language-Definitiona as it is not
kept in a standalone repository. The file generated is from
https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
* `Cabal.sublime_syntax` has been added manually from
https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
* `Lean.sublime-syntax` has been added manually from https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json via conversion.

View File

@ -45,7 +45,7 @@
showguides="true"
inkscape:guide-bbox="true" />
<rect
style="opacity:1;fill:#f2f2f2;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.14294769px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
style="opacity:0.5;fill:#e5e5e5;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.14294769px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
id="rect1929"
width="1000"
height="286.64285"

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -11,6 +11,7 @@ use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
use path_abs::PathAbs;
use crate::assets_metadata::AssetsMetadata;
use crate::bat_warning;
use crate::error::*;
use crate::input::{InputReader, OpenedInput, OpenedInputKind};
use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
@ -37,9 +38,16 @@ impl HighlightingAssets {
};
let theme_dir = source_dir.join("themes");
let res = theme_set.add_from_folder(&theme_dir);
if res.is_err() {
if theme_dir.exists() {
let res = theme_set.add_from_folder(&theme_dir);
if let Err(err) = res {
println!(
"Failed to load one or more themes from '{}' (reason: '{}')",
theme_dir.to_string_lossy(),
err,
);
}
} else {
println!(
"No themes were found in '{}', using the default set",
theme_dir.to_string_lossy()
@ -189,13 +197,12 @@ impl HighlightingAssets {
match self.theme_set.themes.get(theme) {
Some(theme) => theme,
None => {
if theme == "ansi-light" || theme == "ansi-dark" {
bat_warning!("Theme '{}' is deprecated, using 'ansi' instead.", theme);
return self.get_theme("ansi");
}
if theme != "" {
use ansi_term::Colour::Yellow;
eprintln!(
"{}: Unknown theme '{}', using default.",
Yellow.paint("[bat warning]"),
theme
);
bat_warning!("Unknown theme '{}', using default.", theme)
}
&self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
}

View File

@ -16,6 +16,7 @@ use console::Term;
use crate::input::{new_file_input, new_stdin_input};
use bat::{
assets::HighlightingAssets,
bat_warning,
config::{Config, VisibleLines},
error::*,
input::Input,
@ -82,10 +83,9 @@ impl App {
Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never,
Some("auto") | None => {
if self.matches.occurrences_of("plain") > 1 {
// If we have -pp as an option when in auto mode, the pager should be disabled.
PagingMode::Never
} else if self.matches.is_present("no-paging") {
// If we have -pp as an option when in auto mode, the pager should be disabled.
let extra_plain = self.matches.occurrences_of("plain") > 1;
if extra_plain || self.matches.is_present("no-paging") {
PagingMode::Never
} else if inputs.iter().any(Input::is_stdin) {
// If we are reading from stdin, only enable paging if we write to an
@ -169,9 +169,8 @@ impl App {
|| match self.matches.value_of("color") {
Some("always") => true,
Some("never") => false,
Some("auto") | _ => {
env::var_os("NO_COLOR").is_none() && self.interactive_output
}
Some("auto") => env::var_os("NO_COLOR").is_none() && self.interactive_output,
_ => unreachable!("other values for --color are not allowed"),
},
paging_mode,
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
@ -226,17 +225,14 @@ impl App {
style_components,
syntax_mapping,
pager: self.matches.value_of("pager"),
use_italic_text: match self.matches.value_of("italic-text") {
Some("always") => true,
_ => false,
},
use_italic_text: self.matches.value_of("italic-text") == Some("always"),
highlighted_lines: self
.matches
.values_of("highlight-line")
.map(|ws| ws.map(LineRange::from).collect())
.transpose()?
.map(LineRanges::from)
.map(|lr| HighlightedLineRanges(lr))
.map(HighlightedLineRanges)
.unwrap_or_default(),
})
}
@ -288,8 +284,8 @@ impl App {
fn style_components(&self) -> Result<StyleComponents> {
let matches = &self.matches;
Ok(StyleComponents(
if matches.value_of("decorations") == Some("never") {
let mut styled_components =
StyleComponents(if matches.value_of("decorations") == Some("never") {
HashSet::new()
} else if matches.is_present("number") {
[StyleComponent::LineNumbers].iter().cloned().collect()
@ -323,7 +319,13 @@ impl App {
acc.extend(components.iter().cloned());
acc
})
},
))
});
// If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
bat_warning!("Style 'rule' is a subset of style 'grid', 'rule' will not be visible.");
}
Ok(styled_components)
}
}

View File

@ -367,7 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.validator(|val| {
let mut invalid_vals = val.split(',').filter(|style| {
!&[
"auto", "full", "plain", "header", "grid", "numbers", "snip",
"auto", "full", "plain", "header", "grid", "rule", "numbers", "snip",
#[cfg(feature = "git")]
"changes",
]
@ -382,7 +382,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
})
.help(
"Comma-separated list of style elements to display \
(*auto*, full, plain, changes, header, grid, numbers, snip).",
(*auto*, full, plain, changes, header, grid, rule, numbers, snip).",
)
.long_help(
"Configure which elements (line numbers, file headers, grid \
@ -400,6 +400,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
* header: show filenames before the content.\n \
* grid: vertical/horizontal lines to separate side bar\n \
and the header from the content.\n \
* rule: horizontal lines to delimit files.\n \
* numbers: show line numbers in the side bar.\n \
* snip: draw separation lines between distinct line ranges.",
),

View File

@ -44,8 +44,7 @@ pub fn generate_config_file() -> bat::error::Result<()> {
}
}
let default_config =
r#"# This is `bat`s configuration file. Each line either contains a comment or
let default_config = r#"# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options.
@ -86,7 +85,7 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
.ok()
.map(|content| get_args_from_str(&content))
.transpose()?
.unwrap_or_else(|| vec![]))
.unwrap_or_else(Vec::new))
}
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {

View File

@ -36,6 +36,7 @@ use bat::{
input::Input,
style::{StyleComponent, StyleComponents},
MappingTarget,
PagingMode,
};
const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
@ -78,7 +79,9 @@ fn get_syntax_mapping_to_paths<'a>(
map
}
pub fn list_languages(config: &Config) -> Result<()> {
pub fn get_languages(config: &Config) -> Result<String> {
let mut result: String = String::new();
let assets = assets_from_cache_or_binary()?;
let mut languages = assets
.syntaxes()
@ -119,12 +122,9 @@ pub fn list_languages(config: &Config) -> Result<()> {
}
}
let stdout = io::stdout();
let mut stdout = stdout.lock();
if config.loop_through {
for lang in languages {
writeln!(stdout, "{}:{}", lang.name, lang.file_extensions.join(","))?;
result += &format!("{}:{}\n", lang.name, lang.file_extensions.join(","));
}
} else {
let longest = languages
@ -145,7 +145,7 @@ pub fn list_languages(config: &Config) -> Result<()> {
};
for lang in languages {
write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
result += &format!("{:width$}{}", lang.name, separator, width = longest);
// Number of characters on this line so far, wrap before `desired_width`
let mut num_chars = 0;
@ -156,20 +156,20 @@ pub fn list_languages(config: &Config) -> Result<()> {
let new_chars = word.len() + comma_separator.len();
if num_chars + new_chars >= desired_width {
num_chars = 0;
write!(stdout, "\n{:width$}{}", "", separator, width = longest)?;
result += &format!("\n{:width$}{}", "", separator, width = longest);
}
num_chars += new_chars;
write!(stdout, "{}", style.paint(&word[..]))?;
result += &format!("{}", style.paint(&word[..]));
if extension.peek().is_some() {
write!(stdout, "{}", comma_separator)?;
result += comma_separator;
}
}
writeln!(stdout)?;
result += "\n";
}
}
Ok(())
Ok(result)
}
fn theme_preview_file<'a>() -> Input<'a> {
@ -200,6 +200,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
.ok();
writeln!(stdout)?;
}
writeln!(
stdout,
"Further themes can be installed to '{}', \
and are added to the cache with `bat cache --build`. \
For more information, see:\n\n \
https://github.com/sharkdp/bat#adding-new-themes",
config_file().join("themes").to_string_lossy()
)?;
} else {
for theme in assets.themes() {
writeln!(stdout, "{}", theme)?;
@ -240,8 +248,14 @@ fn run() -> Result<bool> {
let config = app.config(&inputs)?;
if app.matches.is_present("list-languages") {
list_languages(&config)?;
Ok(true)
let languages: String = get_languages(&config)?;
let inputs: Vec<Input> = vec![Input::from_reader(Box::new(languages.as_bytes()))];
let plain_config = Config {
style_components: StyleComponents::new(StyleComponent::Plain.components(false)),
paging_mode: PagingMode::QuitIfOneScreen,
..Default::default()
};
run_controller(inputs, &plain_config)
} else if app.matches.is_present("list-themes") {
list_themes(&config)?;
Ok(true)

View File

@ -54,7 +54,10 @@ impl<'b> Controller<'b> {
paging_mode = PagingMode::Never;
}
}
output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
let wrapping_mode = self.config.wrapping_mode;
output_type = OutputType::from_mode(paging_mode, wrapping_mode, self.config.pager)?;
}
#[cfg(not(feature = "paging"))]
@ -144,7 +147,7 @@ impl<'b> Controller<'b> {
Ok(no_errors)
}
fn print_file<'a>(
fn print_file(
&self,
printer: &mut dyn Printer,
writer: &mut dyn Write,
@ -194,6 +197,8 @@ impl<'b> Controller<'b> {
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) {
RangeCheckResult::BeforeOrBetweenRanges => {
@ -204,7 +209,7 @@ impl<'b> Controller<'b> {
}
RangeCheckResult::InRange => {
if self.config.style_components.snip() {
if style_snip {
if first_range {
first_range = false;
mid_range = true;

View File

@ -20,6 +20,10 @@ error_chain! {
description("unknown syntax"),
display("unknown syntax: '{}'", name)
}
InvalidPagerValueBat {
description("invalid value `bat` for pager property"),
display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")
}
}
}

View File

@ -143,9 +143,8 @@ impl<'a> Input<'a> {
}
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
match provided_name {
Some(name) => self.description.name = name.to_string_lossy().to_string(),
None => {}
if let Some(name) = provided_name {
self.description.name = name.to_string_lossy().to_string()
}
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());

View File

@ -19,6 +19,8 @@
//! .unwrap();
//! ```
mod macros;
pub mod assets;
pub mod assets_metadata;
pub mod config;

7
src/macros.rs Normal file
View File

@ -0,0 +1,7 @@
#[macro_export]
macro_rules! bat_warning {
($($arg:tt)*) => ({
use ansi_term::Colour::Yellow;
eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*));
})
}

View File

@ -7,6 +7,15 @@ use crate::error::*;
use crate::less::retrieve_less_version;
#[cfg(feature = "paging")]
use crate::paging::PagingMode;
#[cfg(feature = "paging")]
use crate::wrapping::WrappingMode;
#[cfg(feature = "paging")]
#[derive(Debug, PartialEq)]
enum SingleScreenAction {
Quit,
Nothing,
}
#[derive(Debug)]
pub enum OutputType {
@ -17,18 +26,28 @@ pub enum OutputType {
impl OutputType {
#[cfg(feature = "paging")]
pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result<Self> {
pub fn from_mode(
paging_mode: PagingMode,
wrapping_mode: WrappingMode,
pager: Option<&str>,
) -> Result<Self> {
use self::PagingMode::*;
Ok(match mode {
Always => OutputType::try_pager(false, pager)?,
QuitIfOneScreen => OutputType::try_pager(true, pager)?,
Ok(match paging_mode {
Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?,
QuitIfOneScreen => {
OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?
}
_ => OutputType::stdout(),
})
}
/// Try to launch the pager. Fall back to stdout in case of errors.
#[cfg(feature = "paging")]
fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
fn try_pager(
single_screen_action: SingleScreenAction,
wrapping_mode: WrappingMode,
pager_from_config: Option<&str>,
) -> Result<Self> {
use std::env;
use std::ffi::OsString;
use std::path::PathBuf;
@ -66,10 +85,10 @@ impl OutputType {
match pagerflags.split_first() {
Some((pager_name, args)) => {
let mut pager_path = PathBuf::from(pager_name);
let pager_path = PathBuf::from(pager_name);
if pager_path.file_stem() == Some(&OsString::from("bat")) {
pager_path = PathBuf::from("less");
return Err(ErrorKind::InvalidPagerValueBat.into());
}
let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
@ -78,10 +97,14 @@ impl OutputType {
let mut p = Command::new(&pager_path);
if args.is_empty() || replace_arguments_to_less {
p.arg("--RAW-CONTROL-CHARS");
if quit_if_one_screen {
if single_screen_action == SingleScreenAction::Quit {
p.arg("--quit-if-one-screen");
}
if wrapping_mode == WrappingMode::NoWrapping {
p.arg("--chop-long-lines");
}
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
//

View File

@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
}
}
// line feed
'\x0A' => output.push('␊'),
'\x0A' => output.push_str("\x0A"),
// carriage return
'\x0D' => output.push('␍'),
// null

View File

@ -23,6 +23,7 @@ struct ActiveStyleComponents {
header: bool,
vcs_modification_markers: bool,
grid: bool,
rule: bool,
line_numbers: bool,
snip: bool,
}
@ -179,6 +180,12 @@ impl<'a> PrettyPrinter<'a> {
self
}
/// Whether to paint a horizontal rule to delimit files
pub fn rule(&mut self, yes: bool) -> &mut Self {
self.active_style_components.rule = yes;
self
}
/// Whether to show modification markers for VCS changes. This has no effect if
/// the `git` feature is not activated.
#[cfg_attr(
@ -285,6 +292,9 @@ impl<'a> PrettyPrinter<'a> {
if self.active_style_components.grid {
style_components.push(StyleComponent::Grid);
}
if self.active_style_components.rule {
style_components.push(StyleComponent::Rule);
}
if self.active_style_components.header {
style_components.push(StyleComponent::Header);
}
@ -328,7 +338,7 @@ impl<'a> Input<'a> {
/// A new input from bytes.
pub fn from_bytes(bytes: &'a [u8]) -> Self {
Input::from_reader(bytes).into()
Input::from_reader(bytes)
}
/// A new input from STDIN.

View File

@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> {
if self.config.show_nonprintable {
let line = replace_nonprintable(line_buffer, self.config.tab_width);
write!(handle, "{}", line)?;
if line_buffer.last() == Some(&b'\n') {
writeln!(handle)?;
}
} else {
handle.write_all(line_buffer)?
};
@ -200,13 +197,18 @@ impl<'a> InteractivePrinter<'a> {
})
}
fn print_horizontal_line_term(&mut self, handle: &mut dyn Write, style: Style) -> Result<()> {
writeln!(
handle,
"{}",
style.paint("".repeat(self.config.term_width))
)?;
Ok(())
}
fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
if self.panel_width == 0 {
writeln!(
handle,
"{}",
self.colors.grid.paint("".repeat(self.config.term_width))
)?;
self.print_horizontal_line_term(handle, self.colors.grid)?;
} else {
let hline = "".repeat(self.config.term_width - (self.panel_width + 1));
let hline = format!("{}{}{}", "".repeat(self.panel_width), grid_char, hline);
@ -251,6 +253,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
input: &OpenedInput,
add_header_padding: bool,
) -> Result<()> {
if add_header_padding && self.config.style_components.rule() {
self.print_horizontal_line_term(handle, self.colors.rule)?;
}
if !self.config.style_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
writeln!(
@ -279,7 +285,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
.paint(if self.panel_width > 0 { "" } else { "" }),
)?;
} else {
if add_header_padding {
// Only pad space between files, if we haven't already drawn a horizontal rule
if add_header_padding && !self.config.style_components.rule() {
writeln!(handle)?;
}
write!(handle, "{}", " ".repeat(self.panel_width))?;
@ -301,7 +308,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
description
.kind()
.map(|kind| format!("{}: ", kind))
.unwrap_or("".into()),
.unwrap_or_else(|| "".into()),
self.colors.filename.paint(description.title()),
mode
)?;
@ -441,7 +448,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
if text.len() != text_trimmed.len() {
if let Some(background_color) = background_color {
let mut ansi_style = Style::default();
ansi_style.background = Some(to_ansi_color(background_color, true_color));
ansi_style.background = to_ansi_color(background_color, true_color);
let width = if cursor_total <= cursor_max {
cursor_max - cursor_total + 1
} else {
@ -453,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
}
if line.bytes().next_back() != Some(b'\n') {
if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') {
writeln!(handle)?;
}
} else {
@ -582,8 +589,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
if let Some(background_color) = background_color {
let mut ansi_style = Style::default();
ansi_style.background =
Some(to_ansi_color(background_color, self.config.true_color));
ansi_style.background = to_ansi_color(background_color, self.config.true_color);
write!(
handle,
@ -603,6 +609,7 @@ const DEFAULT_GUTTER_COLOR: u8 = 238;
#[derive(Debug, Default)]
pub struct Colors {
pub grid: Style,
pub rule: Style,
pub filename: Style,
pub git_added: Style,
pub git_removed: Style,
@ -616,19 +623,27 @@ impl Colors {
}
fn colored(theme: &Theme, true_color: bool) -> Self {
let gutter_color = theme
.settings
.gutter_foreground
.map(|c| to_ansi_color(c, true_color))
.unwrap_or(Fixed(DEFAULT_GUTTER_COLOR));
let gutter_style = Style {
foreground: match theme.settings.gutter_foreground {
// If the theme provides a gutter foreground color, use it.
// Note: It might be the special value #00000001, in which case
// to_ansi_color returns None and we use an empty Style
// (resulting in the terminal's default foreground color).
Some(c) => to_ansi_color(c, true_color),
// Otherwise, use a specific fallback color.
None => Some(Fixed(DEFAULT_GUTTER_COLOR)),
},
..Style::default()
};
Colors {
grid: gutter_color.normal(),
grid: gutter_style,
rule: gutter_style,
filename: Style::new().bold(),
git_added: Green.normal(),
git_removed: Red.normal(),
git_modified: Yellow.normal(),
line_number: gutter_color.normal(),
line_number: gutter_style,
}
}
}

View File

@ -9,6 +9,7 @@ pub enum StyleComponent {
#[cfg(feature = "git")]
Changes,
Grid,
Rule,
Header,
LineNumbers,
Snip,
@ -29,6 +30,7 @@ impl StyleComponent {
#[cfg(feature = "git")]
StyleComponent::Changes => &[StyleComponent::Changes],
StyleComponent::Grid => &[StyleComponent::Grid],
StyleComponent::Rule => &[StyleComponent::Rule],
StyleComponent::Header => &[StyleComponent::Header],
StyleComponent::LineNumbers => &[StyleComponent::LineNumbers],
StyleComponent::Snip => &[StyleComponent::Snip],
@ -54,6 +56,7 @@ impl FromStr for StyleComponent {
#[cfg(feature = "git")]
"changes" => Ok(StyleComponent::Changes),
"grid" => Ok(StyleComponent::Grid),
"rule" => Ok(StyleComponent::Rule),
"header" => Ok(StyleComponent::Header),
"numbers" => Ok(StyleComponent::LineNumbers),
"snip" => Ok(StyleComponent::Snip),
@ -81,6 +84,10 @@ impl StyleComponents {
self.0.contains(&StyleComponent::Grid)
}
pub fn rule(&self) -> bool {
self.0.contains(&StyleComponent::Rule)
}
pub fn header(&self) -> bool {
self.0.contains(&StyleComponent::Header)
}

View File

@ -3,13 +3,13 @@ use ansi_term::{self, Style};
use syntect::highlighting::{self, FontStyle};
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Color {
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<ansi_term::Color> {
if color.a == 0 {
// Themes can specify one of the user-configurable terminal colors by
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
// to the 8-bit color palette number. The built-in themes ansi-light,
// ansi-dark, base16, and base16-256 use this.
match color.r {
// to the 8-bit color palette number. The built-in themes ansi, base16,
// and base16-256 use this.
Some(match color.r {
// For the first 8 colors, use the Color enum to produce ANSI escape
// sequences using codes 30-37 (foreground) and 40-47 (background).
// For example, red foreground is \x1b[31m. This works on terminals
@ -31,11 +31,18 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term:
// 90-97 (foreground) and 100-107 (background), we should use those
// for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
n => Fixed(n),
}
})
} else if color.a == 1 {
// Themes can specify the terminal's default foreground/background color
// (i.e. no escape sequence) using the encoding #RRGGBBAA with AA set to
// 01. The built-in theme ansi uses this.
None
} else if true_color {
RGB(color.r, color.g, color.b)
Some(RGB(color.r, color.g, color.b))
} else {
Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
Some(Fixed(ansi_colours::ansi256_from_rgb((
color.r, color.g, color.b,
))))
}
}
@ -54,7 +61,10 @@ pub fn as_terminal_escaped(
let mut style = if !colored {
Style::default()
} else {
let mut color = Style::from(to_ansi_color(style.foreground, true_color));
let mut color = Style {
foreground: to_ansi_color(style.foreground, true_color),
..Style::default()
};
if style.font_style.contains(FontStyle::BOLD) {
color = color.bold();
}
@ -67,6 +77,6 @@ pub fn as_terminal_escaped(
color
};
style.background = background_color.map(|c| to_ansi_color(c, true_color));
style.background = background_color.and_then(|c| to_ansi_color(c, true_color));
style.paint(text).to_string()
}

View File

@ -4,10 +4,6 @@ snapshots/** text=auto eol=lf
syntax-tests/source/** text=auto eol=lf
syntax-tests/highlighted/** text=auto eol=lf
# BAT/CMD files always need CRLF EOLs
*.[Bb][Aa][Tt] text eol=crlf
*.[Cc][Mm][Dd] text eol=crlf
examples/* linguist-vendored
snapshots/* linguist-vendored
benchmarks/* linguist-vendored

View File

@ -1,7 +1,9 @@
use bat::assets::HighlightingAssets;
/// This test ensures that we are not accidentally removing themes due to submodule updates.
/// It is 'ignore'd by default because it requires themes.bin to be up-to-date.
#[test]
#[ignore]
fn all_themes_are_present() {
let assets = HighlightingAssets::from_binary();
@ -12,6 +14,8 @@ fn all_themes_are_present() {
themes,
vec![
"1337",
"Coldark-Cold",
"Coldark-Dark",
"DarkNeon",
"Dracula",
"GitHub",
@ -26,13 +30,11 @@ fn all_themes_are_present() {
"Solarized (light)",
"Sublime Snazzy",
"TwoDark",
"ansi-dark",
"ansi-light",
"ansi",
"base16",
"base16-256",
"gruvbox",
"gruvbox-dark",
"gruvbox-light",
"gruvbox-white",
"zenburn"
]
);

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
if ! which hyperfine > /dev/null 2>&1; then
if ! command -v hyperfine > /dev/null 2>&1; then
echo "'hyperfine' does not seem to be installed."
echo "You can get it here: https://github.com/sharkdp/hyperfine"
exit 1

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
# Check that Hyperfine is installed.
if ! which hyperfine > /dev/null 2>&1; then
echo "'hyperfine' does not seem to be installed." 1>&2
echo "You can get it here: https://github.com/sharkdp/hyperfine" 1>&2
if ! command -v hyperfine > /dev/null 2>&1; then
echo "'hyperfine' does not seem to be installed."
echo "You can get it here: https://github.com/sharkdp/hyperfine"
exit 1
fi

View File

@ -405,6 +405,16 @@ fn pager_disable() {
.stdout(predicate::eq("hello world\n").normalize());
}
#[test]
fn pager_value_bat() {
bat()
.arg("--pager=bat")
.arg("--paging=always")
.arg("test.txt")
.assert()
.failure();
}
#[test]
fn alias_pager_disable() {
bat()
@ -570,6 +580,18 @@ fn empty_file_leads_to_empty_output_with_grid_enabled() {
.stdout("");
}
#[test]
fn empty_file_leads_to_empty_output_with_rule_enabled() {
bat()
.arg("empty.txt")
.arg("--style=rule")
.arg("--decorations=always")
.arg("--terminal-width=80")
.assert()
.success()
.stdout("");
}
#[test]
fn filename_basic() {
bat()
@ -668,6 +690,48 @@ fn header_padding() {
.stderr("");
}
#[test]
fn header_padding_rule() {
bat()
.arg("--decorations=always")
.arg("--style=header,rule")
.arg("--terminal-width=80")
.arg("test.txt")
.arg("single-line.txt")
.assert()
.stdout(
"File: test.txt
hello world
File: single-line.txt
Single Line
",
)
.stderr("");
}
#[test]
fn grid_overrides_rule() {
bat()
.arg("--decorations=always")
.arg("--style=grid,rule")
.arg("--terminal-width=80")
.arg("test.txt")
.arg("single-line.txt")
.assert()
.stdout(
"\
hello world
Single Line
",
)
.stderr("\x1b[33m[bat warning]\x1b[0m: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.\n");
}
#[cfg(target_os = "linux")]
#[test]
fn file_with_invalid_utf8_filename() {
@ -749,3 +813,41 @@ fn show_all_mode() {
.stdout("hello·world␊\n├──┤␍␀␇␈␛")
.stderr("");
}
#[test]
fn plain_mode_does_not_add_nonexisting_newline() {
bat()
.arg("--paging=never")
.arg("--color=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("single-line.txt")
.assert()
.success()
.stdout("Single Line");
}
// Regression test for https://github.com/sharkdp/bat/issues/299
#[test]
fn grid_for_file_without_newline() {
bat()
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=full")
.arg("single-line.txt")
.assert()
.success()
.stdout(
"\
File: single-line.txt
1 Single Line
",
)
.stderr("");
}

View File

@ -19,17 +19,27 @@ snapshot_tests! {
grid: "grid",
header: "header",
numbers: "numbers",
rule: "rule",
changes_grid: "changes,grid",
changes_header: "changes,header",
changes_numbers: "changes,numbers",
changes_rule: "changes,rule",
grid_header: "grid,header",
grid_numbers: "grid,numbers",
grid_rule: "grid,rule",
header_numbers: "header,numbers",
header_rule: "header,rule",
changes_grid_header: "changes,grid,header",
changes_grid_numbers: "changes,grid,numbers",
changes_grid_rule: "changes,grid,rule",
changes_header_numbers: "changes,header,numbers",
changes_header_rule: "changes,header,rule",
grid_header_numbers: "grid,header,numbers",
grid_header_rule: "grid,header,rule",
header_numbers_rule: "header,numbers,rule",
changes_grid_header_numbers: "changes,grid,header,numbers",
changes_grid_header_rule: "changes,grid,header,rule",
changes_grid_header_numbers_rule: "changes,grid,header,numbers,rule",
full: "full",
plain: "plain",
}

View File

@ -7,7 +7,7 @@ import shutil
def generate_snapshots():
single_styles = ["changes", "grid", "header", "numbers"]
single_styles = ["changes", "grid", "header", "numbers", "rule"]
collective_styles = ["full", "plain"]
for num in range(len(single_styles)):

View File

@ -0,0 +1,26 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 + │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,26 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ File: sample.rs
──┼─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle {
│ width: u32,
│ height: u32,
│ }
_ │ fn main() {
│ let rect1 = Rectangle { width: 30, height: 50 };
│ println!(
~ │ "The perimeter of the rectangle is {} pixels.",
~ │ perimeter(&rect1)
│ );
+ │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
│ }
│ fn area(rectangle: &Rectangle) -> u32 {
│ rectangle.width * rectangle.height
│ }
+ │
+ │ fn perimeter(rectangle: &Rectangle) -> u32 {
+ │ (rectangle.width + rectangle.height) * 2
+ │ }
──┴─────────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,24 @@
───────┬────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 + │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,24 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle {
│ width: u32,
│ height: u32,
│ }
_ │ fn main() {
│ let rect1 = Rectangle { width: 30, height: 50 };
│ println!(
~ │ "The perimeter of the rectangle is {} pixels.",
~ │ perimeter(&rect1)
│ );
+ │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
│ }
│ fn area(rectangle: &Rectangle) -> u32 {
│ rectangle.width * rectangle.height
│ }
+ │
+ │ fn perimeter(rectangle: &Rectangle) -> u32 {
+ │ (rectangle.width + rectangle.height) * 2
+ │ }
──┴─────────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,23 @@
File: sample.rs
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 _ fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 ~ "The perimeter of the rectangle is {} pixels.",
11 ~ perimeter(&rect1)
12 );
13 + println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19 +
20 + fn perimeter(rectangle: &Rectangle) -> u32 {
21 + (rectangle.width + rectangle.height) * 2
22 + }

View File

@ -0,0 +1,23 @@
File: sample.rs
struct Rectangle {
width: u32,
height: u32,
}
_ fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
~ "The perimeter of the rectangle is {} pixels.",
~ perimeter(&rect1)
);
+ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
+
+ fn perimeter(rectangle: &Rectangle) -> u32 {
+ (rectangle.width + rectangle.height) * 2
+ }

View File

@ -0,0 +1,22 @@
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 _ fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 ~ "The perimeter of the rectangle is {} pixels.",
11 ~ perimeter(&rect1)
12 );
13 + println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19 +
20 + fn perimeter(rectangle: &Rectangle) -> u32 {
21 + (rectangle.width + rectangle.height) * 2
22 + }

View File

@ -0,0 +1,22 @@
struct Rectangle {
width: u32,
height: u32,
}
_ fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
~ "The perimeter of the rectangle is {} pixels.",
~ perimeter(&rect1)
);
+ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
+
+ fn perimeter(rectangle: &Rectangle) -> u32 {
+ (rectangle.width + rectangle.height) * 2
+ }

View File

@ -0,0 +1,26 @@
─────┬──────────────────────────────────────────────────────────────────────────
│ File: sample.rs
─────┼──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 │ "The perimeter of the rectangle is {} pixels.",
11 │ perimeter(&rect1)
12 │ );
13 │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 │ (rectangle.width + rectangle.height) * 2
22 │ }
─────┴──────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,26 @@
────────────────────────────────────────────────────────────────────────────────
File: sample.rs
────────────────────────────────────────────────────────────────────────────────
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
────────────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,24 @@
─────┬──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 │ "The perimeter of the rectangle is {} pixels.",
11 │ perimeter(&rect1)
12 │ );
13 │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 │ (rectangle.width + rectangle.height) * 2
22 │ }
─────┴──────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,24 @@
────────────────────────────────────────────────────────────────────────────────
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
────────────────────────────────────────────────────────────────────────────────

View File

@ -0,0 +1,23 @@
File: sample.rs
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 "The perimeter of the rectangle is {} pixels.",
11 perimeter(&rect1)
12 );
13 println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19
20 fn perimeter(rectangle: &Rectangle) -> u32 {
21 (rectangle.width + rectangle.height) * 2
22 }

View File

@ -0,0 +1,23 @@
File: sample.rs
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}

View File

@ -0,0 +1,22 @@
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 "The perimeter of the rectangle is {} pixels.",
11 perimeter(&rect1)
12 );
13 println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19
20 fn perimeter(rectangle: &Rectangle) -> u32 {
21 (rectangle.width + rectangle.height) * 2
22 }

View File

@ -0,0 +1,22 @@
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}

View File

@ -16,11 +16,32 @@ BAT_OPTIONS = [
"--italic-text=always",
]
SKIP_FILENAMES = [
"LICENSE.md",
"README.md",
"bat_options",
]
def get_options(source):
options = BAT_OPTIONS.copy()
source_dirpath = path.dirname(source)
options_file = path.join(source_dirpath, "bat_options")
try:
with open(options_file, "r") as f:
options.extend(map(lambda x: x.rstrip(), f.readlines()))
except FileNotFoundError:
pass
return options
def create_highlighted_versions(output_basepath):
root = os.path.dirname(os.path.abspath(__file__))
sources = path.join(root, "source", "*")
for source in glob.glob(path.join(root, "source", "*", "*")):
for source in glob.glob(path.join(sources, "*")) + glob.glob(path.join(sources, ".*")):
try:
env = os.environ.copy()
env.pop("PAGER", None)
@ -31,16 +52,18 @@ def create_highlighted_versions(output_basepath):
env.pop("BAT_TABS", None)
env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
bat_output = subprocess.check_output(
["bat"] + BAT_OPTIONS + [source], stderr=subprocess.PIPE, env=env,
)
source_dirname = path.basename(path.dirname(source))
source_filename = path.basename(source)
if source_filename == "LICENSE.md":
if source_filename in SKIP_FILENAMES:
continue
bat_output = subprocess.check_output(
["bat"] + get_options(source) + [source],
stderr=subprocess.PIPE,
env=env,
)
output_dir = path.join(output_basepath, source_dirname)
output_path = path.join(output_dir, source_filename)
@ -65,7 +88,10 @@ def create_highlighted_versions(output_basepath):
)
sys.exit(1)
except FileNotFoundError:
print("Error: Could not execute 'bat'. Please make sure that the executable is available on the PATH.")
print(
"Error: Could not execute 'bat'. Please make sure that the executable "
"is available on the PATH."
)
sys.exit(1)

View File

@ -0,0 +1,36 @@
<html>
<body>
<!-- #include file ="headers\header.inc" -->
<%
For i = 0 To 5
Response.Write("The number is " & i & "<br />")
Next
%>
<%
Response.Write("Hello World!")
%>
<%
Dim x(2,2)
x(0,0)="Volvo"
x(0,1)="BMW"
x(0,2)="Ford"
x(1,0)="Apple"
x(1,1)="Orange"
x(1,2)="Banana"
x(2,0)="Coke"
x(2,1)="Pepsi"
x(2,2)="Sprite"
for i=0 to 2
response.write("<p>")
for j=0 to 2
response.write(x(i,j) & "<br />")
next
response.write("</p>")
next
%>
</body>
</html>

View File

@ -0,0 +1,75 @@
import flash.events.*;
import flash.events.MouseEvent;
package TestSyntax {
 public class TestSyntax extends flash.display.Sprite {
 public static const TEST_CONSTANT:Number = 33.333;
 var testAttribute:int = 1;
 public namespace TestNamespace;
 TestNamespace function Method2():void { }
 /**
 * Multi-line comment
 */
 override public function set x(value:Number):void
 {
 super.x = Math.round(value);
 }
 /**
 * Actual multi-line comment
 * Takes up multiple lines
 */
 override public function set y(value:Number):void
 {
 super.y = 0;
 }
 public function testFunction() {
 var test:String = 'hello';
 // arrays
 var testArray:Array = ["a", "b", "c", "d"];
 for (var i:uint = 0; i < testArray.length; i++)
 trace(testArray[i]);
 // objects
 var testObject:Object = {foo: 20, bar: 40};
 for (var key:String in testObject) {
 trace(testObject[key]);
 }
 for each (var objectValue:int in testObject) {
 trace(objectValue);
 }
 // dynamic variables
 var testDynamic:*;
 testDynamic = 75;
 testDynamic = "Seventy-five";
 // regex
 var testRegExp:RegExp = /foo-\d+/i;
 // XML
 var testXML:XML =
<employee>
 <firstName>Harold</firstName>
 <lastName>Webster</lastName>
</employee>;
 }
 private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) {
 }
 [Embed(source="sound1.mp3")] public var soundCls:Class;
 public function SoundAssetExample()
 {
 var mySound:SoundAsset = new soundCls() as SoundAsset;
 var sndChannel:SoundChannel = mySound.play();
 }
 }
}

View File

@ -0,0 +1,42 @@
# This is a comment
#
ServerRoot ""
Listen 80
LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
 AllowOverride none
 Require all denied
</Directory>
DocumentRoot "/usr/share/apache2/default-site/htdocs"
<Directory "/usr/share/apache2/default-site/htdocs">
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted
</Directory>
<Files ".ht*">
 Require all denied
</Files>
ErrorLog "/var/log/apache2/error_log"
LogLevel warn
<IfModule log_config_module>
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
 CustomLog "/var/log/apache2/access_log" common
</IfModule>
<IfModule alias_module>
 ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
</IfModule>
<IfModule mime_module>
 TypesConfig /etc/apache2/mime.types
 AddType application/x-compress .Z
 AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule proxy_html_module>
Include /etc/apache2/extra/proxy-html.conf
</IfModule>

View File

@ -0,0 +1,25 @@
-- This is a comment
property defaultClientName : "Mary Smith"
on greetClient(nameOfClient)
 display dialog ("Hello " & nameOfClient & "!")
end greetClient
script testGreet
 greetClient(defaultClientName)
end script
run testGreet
greetClient("Joe Jones")
set myList to {1, "what", 3}
set beginning of myList to 0
set end of myList to "four"
myList
tell application "TextEdit"
 paragraph 1 of document 1
end tell

View File

@ -0,0 +1,86 @@
global enlight
section .data
 red dq 0 ; some comment
 green dq 0
 blue dq 0
 data dq 0
 N dd 0
 M dd 0
 change dd 0
 delta db 0
section .text
enlight:
 call assign_arguments
 call set_data
 call make_deltas
 ret
assign_arguments:
 mov qword[red], rdi
 mov qword[green], rsi
 mov qword[blue], rdx
 mov dword[N], ecx
 mov dword[M], r8d
 mov dword[change], r9d
 mov al, byte[rsp + 16]
 mov byte[delta], al
 ret
set_data:
 mov eax, dword[change]
 cmp eax, 1
 jne not_1
 mov rax, qword[red]
 mov qword[data], rax
 ret
not_1:
 cmp eax, 2
 jne not_2
 mov rax, qword[green]
 mov qword[data], rax
 ret
not_2:
 mov rax, qword[blue]
 mov qword[data], rax
 ret
make_deltas:
 mov ecx, dword[N]
 mov eax, dword[M]
 imul ecx, eax
loop_start:
 call make_delta
 loop loop_start
 ret
make_delta:
 mov rax, qword[data]
 add rax, rcx
 dec rax
 mov dl, byte[delta]
 cmp dl, 0
 jl substracting
adding:
 add dl, byte[rax]
 jc adding_overflow
 mov byte[rax], dl
 ret
adding_overflow:
 mov byte[rax], 255 
 ret
substracting:
 mov r9b, dl
 mov dl, 0
 sub dl, r9b
 mov r8b, byte[rax]
 sub r8b, dl
 jc substracting_overflow
 mov byte[rax], r8b
 ret
; another comment
substracting_overflow:
 mov byte[rax], 0
 ret

View File

@ -0,0 +1,59 @@
@echo off
:: Change to your LLVM installation
set "LLVMPath=C:\Program Files\LLVM"
:: Change to your Visual Studio 2017 installation
set "VSPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
set "VSVersion=14.10.25017"
:: Change to your Windows Kit version & installation
set "WinSDKVersion=10.0.15063.0"
set "WinSDKPath=C:\Program Files (x86)\Windows Kits\10"
:: Change this to your resulting exe
set "OUTPUT=test.exe"
:: Setup
set "VSBasePath=%VSPath%\VC\Tools\MSVC\%VSVersion%"
set "PATH=%PATH%;%LLVMPath%\bin;%VSBasePath%\bin\HostX64\x64"
:: Compiler Flags
set CFLAGS= ^
 -std=c++14 -Wall -Wextra
set CPPFLAGS= ^
 -I "%VSBasePath%\include" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\shared" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\ucrt" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\um"
:: Linker Libs
set LDFLAGS= ^
 -machine:x64 ^
 -nodefaultlib ^
 -subsystem:console
set LDLIBS= ^
 -libpath:"%VSBasePath%\lib\x64" ^
 -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\ucrt\x64" ^
 -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\um\x64" ^
 libucrt.lib libvcruntime.lib libcmt.lib libcpmt.lib ^
 legacy_stdio_definitions.lib oldnames.lib ^
 legacy_stdio_wide_specifiers.lib ^
 kernel32.lib User32.lib
:: Compiling
@echo on
@for %%f in (*.cc) do (
 clang++.exe "%%~f" -o "%%~nf.o" -c %CFLAGS%
)
:: Linking
@set "LINK_FILES="
@for %%f in (*.o) do (
 @set "LINK_FILES=%LINK_FILES% %%~f"
)
lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS%

View File

@ -0,0 +1,18 @@
@book{knuth1997art,
 title={The art of computer programming},
 author={Knuth, Donald Ervin},
 volume={3},
 year={1997},
 publisher={Pearson Education}
}
@article{egholm1993pna,
 title={PNA hybridizes to complementary oligonucleotides obeying the Watson--Crick hydrogen-bonding rules},
 author={Egholm, Michael and Buchardt, Ole and Christensen, Leif and Behrens, Carsten and Freier, Susan M and Driver, David A and Berg, Rolf H and Kim, Seog K and Norden, Bengt and Nielsen, Peter E},
 journal={Nature},
 volume={365},
 number={6446},
 pages={566--568},
 year={1993},
 publisher={Springer}
}

View File

@ -0,0 +1,16 @@
# This is a file for testing syntax highlighting.
cmake_minimum_required(VERSION 3.13)
project(hello-bat VERSION 0.0.1 LANGUAGES C)
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
file(GLOB_RECURSE SOURCES "${SOURCE_DIR}/*.c")
add_executable(hello-bat SOURCES)
find_package(assimp CONFIG)
target_link_libraries(hello-bat assimp)
option("ENABLE_TESTS" OFF)
if(ENABLE_TESTS)
 add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/")
endif()

View File

@ -0,0 +1,115 @@
/*Scrolling*/
html { scroll-behavior: smooth; }
/*Header text*/
.jumbotron {
 background-image: linear-gradient(90deg, #849EB5, #30394A);
 padding-bottom: 20px;
 padding-top: 20px;
 text-shadow: 0px 2px 4px #000000;
}
.container {
 margin-top: -25px;
}
/*Background related*/
body {
 background: #161616;
}
/*Text related CSS*/
h4 {
 font-size: 70px;
 color: #FFFFFF;
 font-family: News Cycle, serif;
}
h3 {
 color: #e5e5e5;
}
p {
 font-size: 17px;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
p2 {
 font-size: 24px;
 color: #DEDEDE;
 font-family: News Cycle, serif;
}
date {
 font-family: News Cycle, serif;
 font-style: italic;
 font-size: 17px;
 color: #DEDEDE;
}
jobtitle {
 font-size: 17px;
 font-weight: bold;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
jobtilenolink {
 font-size: 17px;
 font-weight: bold;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
li {
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
a {
 color: #4A8ECC;
}
p a:visited {
 color: #4A8ECC;
}
.href {
 color: #4A8ECC;
}
a:visited {
 color: #4A8ECC;
}
p a:hover {
 color: #4FB1F4;
}
a:hover {
 color: #4FB1F4;
}
jobtitle:hover {
 color: #4FB1F4;
}
/*Section*/
section {
 background-color: #1B1B1B;
 padding: 20px;
 margin: -5px;
 margin-bottom: 30px;
 box-shadow: 0px 2px 4px rgba(0,0,0,0.3);
}
/*Icon related*/
.icon {
 position: relative;
 top: 3px;
 right: 5px;
}

View File

@ -0,0 +1,7 @@
first,last,address,city,zip
John,Doe,120 any st.,"Anytown, WW",08123
a,b
1,"ha 
""ha"" 
ha",120 any st.,"Anytown, WW",08123
3,4,120 any st.,"Anytown, WW",08123
Can't render this file because it contains an unexpected character in line 2 and column 276.

View File

@ -0,0 +1,58 @@
(ns clojure-sample.core
 (:gen-class))
 
 (require '[clj-time.core :as t])
 (require '[clj-time.format :as f])
 
 ;; Product record
 (defrecord Product [id name available price])
 
 ;; Positional constructor
 (def product1 (->Product "1" "T-Shirt 1" true 15.00))
 
 ;; Map constructor
 (def product2 (map->Product
 {:id "2"
 :name "T-Shirt 2"
 :available true
 :price 20.00}))
 
 ;; Nested
 (def product3 {:id "1"
 :name "Product 1"
 :available true
 :sellers [{:id "1"
 :name "Seller 1"
 :stock 3},
 {:id 2
 :name "Seller 2"
 :stock 5}]})
 
 ;; Set
 (def categories #{"shirts" "shoes" "belts"})
 
 ;; List
 (def wishlist '(1 2))
 
 ;; Recursion
 (defn factorial [value] (cond
 (<= value 1) 1
 :else (* value (factorial (- value 1)))))
 
 (def basic-formatter (f/formatter "YYYY-MM-dd hh:mm:ss"))
 (defn now [] (f/unparse basic-formatter (t/now)))
 (defn log
 ([] (println (now) "No message"))
 ([message] (println (now) message)))
 
 (defn -main
 [& args]
 (println (:id product1))
 (println (:name product2))
 (println (:name (get (:sellers product3) 0)))
 (println (first categories))
 (println wishlist)
 (println (factorial 5))
 (log)
 (log "Message"))
 

View File

@ -0,0 +1,45 @@
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Hardware : BCM2711
Revision : b03111
Serial : 1000000095fd9fc5
Model : Raspberry Pi 4 Model B Rev 1.1

Some files were not shown because too many files have changed in this diff Show More