mirror of
https://github.com/sharkdp/bat
synced 2026-08-04 19:01:44 +00:00
Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79f016e15c | |||
| 26f9125ebb | |||
| 9814eab13f | |||
| 82ca8804a2 | |||
| b48b9fcf3b | |||
| c64ab29739 | |||
| 83dd3fb551 | |||
| ed345f2889 | |||
| d2492980c0 | |||
| 47d5130764 | |||
| 4ba45e2ba2 | |||
| 7076ae5cd9 | |||
| 2e71146801 | |||
| f3824bad17 | |||
| ec908d5937 | |||
| 3a75d85b80 | |||
| 63d652dab5 | |||
| 7f2e61d579 | |||
| e289a2c698 | |||
| 83a213bae7 | |||
| 3967e28ded | |||
| 2dc2a3712a | |||
| 10e0f9efb0 | |||
| f8ea075e78 | |||
| c187dce2c2 | |||
| 108c907d69 | |||
| 187a3b9341 | |||
| 9c2d4f6a51 | |||
| c1126157d4 | |||
| dcfa810112 | |||
| f963104006 | |||
| 45e1c0ea6f | |||
| 590a1e9a4b | |||
| 8e2c6abb13 | |||
| 28266ee441 | |||
| 21821f1d4c | |||
| 772ce2e4fe | |||
| 35ca1c5191 | |||
| 0cc60a1519 | |||
| ee6659dacf | |||
| 76c615a304 | |||
| e8c04672f0 | |||
| 7f5a5612e4 | |||
| eee5d424bb | |||
| e5311e4b30 | |||
| a1b9334a44 | |||
| d86b7cf7e0 | |||
| 67834da681 | |||
| dcdf8dfaa7 | |||
| 9a44fa11c0 | |||
| 4ee0b2e16d | |||
| 518997135e | |||
| 69fc1caead | |||
| 175dd4c290 | |||
| e9210c0f6c | |||
| 3795acbd17 | |||
| c7d08cfcfd | |||
| 8ec96da9f0 | |||
| c9d7e3652b | |||
| dfa024f9e6 | |||
| b2757cb461 |
+27
@@ -126,3 +126,30 @@
|
|||||||
[submodule "assets/syntaxes/sublime-fish"]
|
[submodule "assets/syntaxes/sublime-fish"]
|
||||||
path = assets/syntaxes/sublime-fish
|
path = assets/syntaxes/sublime-fish
|
||||||
url = https://github.com/Phidica/sublime-fish.git
|
url = https://github.com/Phidica/sublime-fish.git
|
||||||
|
[submodule "assets/syntaxes/Org mode"]
|
||||||
|
path = assets/syntaxes/Org mode
|
||||||
|
url = https://github.com/jezcope/Org.tmbundle.git
|
||||||
|
[submodule "assets/syntaxes/requirementstxt"]
|
||||||
|
path = assets/syntaxes/requirementstxt
|
||||||
|
url = https://github.com/wuub/requirementstxt
|
||||||
|
[submodule "assets/syntaxes/DotENV"]
|
||||||
|
path = assets/syntaxes/DotENV
|
||||||
|
url = https://github.com/zaynali53/DotENV
|
||||||
|
[submodule "assets/syntaxes/hosts"]
|
||||||
|
path = assets/syntaxes/hosts
|
||||||
|
url = https://github.com/brandonwamboldt/sublime-hosts
|
||||||
|
[submodule "assets/syntaxes/ssh-config"]
|
||||||
|
path = assets/syntaxes/ssh-config
|
||||||
|
url = https://github.com/robballou/sublimetext-sshconfig.git
|
||||||
|
[submodule "assets/syntaxes/GraphQL"]
|
||||||
|
path = assets/syntaxes/GraphQL
|
||||||
|
url = https://github.com/dncrews/GraphQL-SublimeText3.git
|
||||||
|
[submodule "assets/syntaxes/Verilog"]
|
||||||
|
path = assets/syntaxes/Verilog
|
||||||
|
url = https://github.com/pro711/sublime-verilog
|
||||||
|
[submodule "assets/syntaxes/SCSS_Sass"]
|
||||||
|
path = assets/syntaxes/SCSS_Sass
|
||||||
|
url = https://github.com/braver/SublimeSass
|
||||||
|
[submodule "assets/syntaxes/Strace"]
|
||||||
|
path = assets/syntaxes/Strace
|
||||||
|
url = https://github.com/djuretic/SublimeStrace
|
||||||
|
|||||||
+3
-3
@@ -32,15 +32,15 @@ matrix:
|
|||||||
|
|
||||||
# Minimum Rust supported channel.
|
# Minimum Rust supported channel.
|
||||||
- os: linux
|
- os: linux
|
||||||
rust: 1.31.0
|
rust: 1.35.0
|
||||||
env: TARGET=x86_64-unknown-linux-gnu
|
env: TARGET=x86_64-unknown-linux-gnu
|
||||||
- os: linux
|
- os: linux
|
||||||
rust: 1.31.0
|
rust: 1.35.0
|
||||||
env:
|
env:
|
||||||
- TARGET=x86_64-unknown-linux-musl
|
- TARGET=x86_64-unknown-linux-musl
|
||||||
- CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc
|
- CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc
|
||||||
- os: osx
|
- os: osx
|
||||||
rust: 1.31.0
|
rust: 1.35.0
|
||||||
env: TARGET=x86_64-apple-darwin
|
env: TARGET=x86_64-apple-darwin
|
||||||
|
|
||||||
# Code formatting check
|
# Code formatting check
|
||||||
|
|||||||
Generated
+427
-450
File diff suppressed because it is too large
Load Diff
+8
-8
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
|
|||||||
name = "bat"
|
name = "bat"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/sharkdp/bat"
|
repository = "https://github.com/sharkdp/bat"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
exclude = [
|
exclude = [
|
||||||
"assets/syntaxes/*",
|
"assets/syntaxes/*",
|
||||||
"assets/themes/*",
|
"assets/themes/*",
|
||||||
@@ -16,24 +16,24 @@ build = "build.rs"
|
|||||||
edition = '2018'
|
edition = '2018'
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atty = "0.2.2"
|
atty = "0.2.13"
|
||||||
ansi_term = "0.11"
|
ansi_term = "0.12"
|
||||||
ansi_colours = "^1.0"
|
ansi_colours = "^1.0"
|
||||||
console = "0.7"
|
console = "0.8"
|
||||||
dirs = "1.0"
|
dirs = "2.0"
|
||||||
lazy_static = "1.3"
|
lazy_static = "1.4"
|
||||||
wild = "2.0"
|
wild = "2.0"
|
||||||
content_inspector = "0.2.4"
|
content_inspector = "0.2.4"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
shell-words = "0.1.0"
|
shell-words = "0.1.0"
|
||||||
|
|
||||||
[dependencies.git2]
|
[dependencies.git2]
|
||||||
version = "0.8"
|
version = "0.10"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = []
|
features = []
|
||||||
|
|
||||||
[dependencies.syntect]
|
[dependencies.syntect]
|
||||||
version = "3.2.0"
|
version = "3.2.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["parsing", "yaml-load", "dump-load", "dump-create"]
|
features = ["parsing", "yaml-load", "dump-load", "dump-create"]
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ tail -f /var/log/pacman.log | bat --paging=never -l log
|
|||||||
Note that we have to switch off paging in order for this to work. We have also specified the syntax
|
Note that we have to switch off paging in order for this to work. We have also specified the syntax
|
||||||
explicitly (`-l log`), as it can not be auto-detected in this case.
|
explicitly (`-l log`), as it can not be auto-detected in this case.
|
||||||
|
|
||||||
### `git show`
|
#### `git show`
|
||||||
|
|
||||||
You can combine `bat` with `git show` to view an older version of a given file with proper syntax
|
You can combine `bat` with `git show` to view an older version of a given file with proper syntax
|
||||||
highlighting:
|
highlighting:
|
||||||
@@ -132,6 +132,17 @@ bat main.cpp | xclip
|
|||||||
```
|
```
|
||||||
`bat` will detect that the output is being redirected and print the plain file contents.
|
`bat` will detect that the output is being redirected and print the plain file contents.
|
||||||
|
|
||||||
|
#### `man`
|
||||||
|
|
||||||
|
`bat` can be used as a pager for `man`. It can be used like this:
|
||||||
|
```
|
||||||
|
export MANPAGER="sh -c 'col -b | bat -l man -p'"
|
||||||
|
|
||||||
|
man 2 select
|
||||||
|
```
|
||||||
|
|
||||||
|
The [Manpage syntax](assets/syntaxes/Manpage.sublime-syntax) is developed in this repository and still needs some work.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### On Ubuntu
|
### On Ubuntu
|
||||||
@@ -140,7 +151,16 @@ bat main.cpp | xclip
|
|||||||
Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases)
|
Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases)
|
||||||
and install it via:
|
and install it via:
|
||||||
``` bash
|
``` bash
|
||||||
sudo dpkg -i bat_0.11.0_amd64.deb # adapt version number and architecture
|
sudo dpkg -i bat_0.12.0_amd64.deb # adapt version number and architecture
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Alpine Linux
|
||||||
|
|
||||||
|
You can install [the `bat` package](https://pkgs.alpinelinux.org/packages?name=bat)
|
||||||
|
from the official sources, provided you have the appropriate repository enabled:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apk add bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Arch Linux
|
### On Arch Linux
|
||||||
@@ -154,10 +174,19 @@ pacman -S bat
|
|||||||
|
|
||||||
### On Fedora
|
### On Fedora
|
||||||
|
|
||||||
You can install `bat` from the [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository. On Fedora 29 and higher, it is enabled by default. Otherwise, run `dnf install fedora-repos-modular` to set up, and make sure that the `fedora-modular` and `fedora-updates-modular` repos are enabled in `/etc/yum.repos.d`.
|
You can install [the `bat` package](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506) from the official [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dnf module install bat
|
dnf install bat
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Gentoo Linux
|
||||||
|
|
||||||
|
You can install [the `bat` package](https://packages.gentoo.org/packages/sys-apps/bat)
|
||||||
|
from the official sources:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
emerge sys-apps/bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Void Linux
|
### On Void Linux
|
||||||
@@ -265,7 +294,7 @@ binaries are also available: look for archives with `musl` in the file name.
|
|||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
If you want to build `bat` from source, you need Rust 1.31 or
|
If you want to build `bat` from source, you need Rust 1.35 or
|
||||||
higher. You can then use `cargo` to build everything:
|
higher. You can then use `cargo` to build everything:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Vendored
+1
@@ -33,6 +33,7 @@ The following files have been manually modified after converting from a `.tmLang
|
|||||||
|
|
||||||
* `Dart.sublime-syntax` => removed `#regex.dart` include.
|
* `Dart.sublime-syntax` => removed `#regex.dart` include.
|
||||||
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
|
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
|
||||||
|
* `Org mode.sublime-syntax` => removed `task` file type.
|
||||||
|
|
||||||
### Non-submodule additions
|
### Non-submodule additions
|
||||||
|
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+1
Submodule assets/syntaxes/DotENV added at f6cad1140c
+88
@@ -0,0 +1,88 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: DotENV
|
||||||
|
file_extensions:
|
||||||
|
- .env
|
||||||
|
- .envrc
|
||||||
|
- .env.dist
|
||||||
|
- .env.local
|
||||||
|
- .env.sample
|
||||||
|
- .env.example
|
||||||
|
- .env.test
|
||||||
|
- .env.test.local
|
||||||
|
- .env.dev
|
||||||
|
- .env.development
|
||||||
|
- .env.development.local
|
||||||
|
- .env.prod
|
||||||
|
- .env.production
|
||||||
|
- .env.production.local
|
||||||
|
- .env.dusk.local
|
||||||
|
scope: source.env
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: (#).*$\n?
|
||||||
|
comment: "Comments - starts with #"
|
||||||
|
scope: comment.line.number-sign.env
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.comment.env
|
||||||
|
- match: (\")
|
||||||
|
comment: Strings (double)
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.env
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.env
|
||||||
|
- match: (\")
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.end
|
||||||
|
pop: true
|
||||||
|
- include: interpolation
|
||||||
|
- include: variable
|
||||||
|
- include: escape-characters
|
||||||
|
- match: (\')
|
||||||
|
comment: Strings (single)
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.env
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.single.env
|
||||||
|
- match: (\')
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.end
|
||||||
|
pop: true
|
||||||
|
- match: '(?<=[\w])\s?='
|
||||||
|
comment: Assignment Operator
|
||||||
|
scope: keyword.operator.assignment.env
|
||||||
|
- match: '([\w]+)(?=\s?\=)'
|
||||||
|
comment: Variable
|
||||||
|
scope: variable.other.env
|
||||||
|
- match: (?i)\s?(export)
|
||||||
|
comment: Keywords
|
||||||
|
scope: keyword.other.env
|
||||||
|
- match: (?i)(?<=\=)\s?(true|false|null)
|
||||||
|
comment: Constants
|
||||||
|
scope: constant.language.env
|
||||||
|
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b'
|
||||||
|
comment: Numeric
|
||||||
|
scope: constant.numeric.env
|
||||||
|
escape-characters:
|
||||||
|
- match: '\\[nrt\\\$\"\'']'
|
||||||
|
scope: constant.character.escape.env
|
||||||
|
interpolation:
|
||||||
|
- match: '(\$\{|\{)'
|
||||||
|
comment: 'Template Syntax: "foo ${bar} {$baz}"'
|
||||||
|
captures:
|
||||||
|
1: string.interpolated.env keyword.other.template.begin.env
|
||||||
|
push:
|
||||||
|
- match: '(\})'
|
||||||
|
captures:
|
||||||
|
1: string.interpolated.env keyword.other.template.end.env
|
||||||
|
pop: true
|
||||||
|
- match: '(?x)(\$+)?([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.variable.env variable.other.env
|
||||||
|
2: variable.other.env
|
||||||
|
variable:
|
||||||
|
- match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.variable.env variable.other.env
|
||||||
|
2: variable.other.env
|
||||||
+1
Submodule assets/syntaxes/GraphQL added at 66ce8713d8
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: hosts
|
||||||
|
file_extensions:
|
||||||
|
- hosts
|
||||||
|
scope: source.hosts
|
||||||
|
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- scope: comment.line.number-sign
|
||||||
|
match: \#.*
|
||||||
|
comment: comment
|
||||||
|
|
||||||
|
- match: ^\s*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[0-9a-f:]+)
|
||||||
|
comment: ipaddress
|
||||||
|
scope: constant.numeric.ipaddress
|
||||||
|
|
||||||
|
|
||||||
|
- match: \s(localhost|ip6-loopback|ip6-localhost|ip6-localnet|ip6-mcastprefix|ip6-allnodes|ip6-allrouters|ip6-allhosts|broadcasthost)\b
|
||||||
|
scope: keyword.host.predefined}
|
||||||
|
comment: prefdfined
|
||||||
|
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: Manpage
|
||||||
|
file_extensions:
|
||||||
|
- man
|
||||||
|
scope: source.man
|
||||||
|
|
||||||
|
variables:
|
||||||
|
section_heading: '^\S.*$'
|
||||||
|
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: ^
|
||||||
|
push: first_line
|
||||||
|
|
||||||
|
first_line:
|
||||||
|
- match: '([A-Z0-9]+)(\()([^)]+)(\))'
|
||||||
|
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}})'
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '^\S.*$'
|
||||||
|
scope: markup.heading
|
||||||
|
|
||||||
|
- match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
|
||||||
|
captures:
|
||||||
|
1: entity.name.function
|
||||||
|
2: keyword.operator
|
||||||
|
3: constant.numeric
|
||||||
|
4: keyword.operator
|
||||||
+1
Submodule assets/syntaxes/Org mode added at 4976d8f84e
+219
@@ -0,0 +1,219 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: orgmode
|
||||||
|
file_extensions:
|
||||||
|
- org
|
||||||
|
scope: text.orgmode
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: |-
|
||||||
|
(?x)
|
||||||
|
^(\*+) # leading stars
|
||||||
|
\s*([A-Z_]{2,})? # todo keywords
|
||||||
|
\s*(\[\#[A-Ca-c]\])? # priority
|
||||||
|
\s*(?=\s+[A-Za-z0-9]+) # expected heading text
|
||||||
|
comment: Outline headings
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.heading.orgmode
|
||||||
|
2: keyword.other.todo.orgmode
|
||||||
|
3: constant.other.priority.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.heading.orgmode
|
||||||
|
- meta_content_scope: entity.name.section.orgmode
|
||||||
|
- match: (?=\s*$\n?)
|
||||||
|
pop: true
|
||||||
|
- include: heading-inline
|
||||||
|
- match: "^-{5,}$"
|
||||||
|
scope: meta.separator.orgmode
|
||||||
|
- match: '^\s*([-+]|\s+\*)\s+(.*?)\s+::'
|
||||||
|
captures:
|
||||||
|
1: keyword.operator.list.orgmode
|
||||||
|
2: markup.bold.definition.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.list.definition.orgmode
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- include: inline
|
||||||
|
- match: '^\s*?([-+]|\s+\*|\d+[).])'
|
||||||
|
captures:
|
||||||
|
1: keyword.operator.list.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.list.plain.orgmode
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- include: list-inline
|
||||||
|
- match: (?i)^#\+(BEGIN_(QUOTE|VERSE|CENTER))$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.quote.orgmode
|
||||||
|
- match: (?i)^#\+(END_\2)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- match: "^#[^+].*$"
|
||||||
|
scope: comment.line.number-sign.orgmode
|
||||||
|
- match: ^:(PROPERTIES):$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.drawer.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.drawer.properties.orgmode
|
||||||
|
- match: ^:(END):$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.drawer.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: properties
|
||||||
|
- match: ^:(.+):$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.drawer.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.drawer.other.orgmode
|
||||||
|
- match: ^:(END):$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.drawer.orgmode
|
||||||
|
pop: true
|
||||||
|
- match: (?i)#\+(BEGIN_LaTeX)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.latex.orgmode
|
||||||
|
- match: (?i)#\+(END_LaTeX)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:text.tex.latex
|
||||||
|
- match: (?i)#\+(BEGIN_HTML)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.html.orgmode
|
||||||
|
- match: (?i)#\+(END_HTML)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:text.html.basic
|
||||||
|
- match: (?i)#\+(BEGIN_SRC)\s+(python)\s*(.*)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
2: constant.other.language.orgmode
|
||||||
|
3: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.source.python.orgmode
|
||||||
|
- match: (?i)#\+(END_SRC)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.python
|
||||||
|
- match: (?i)#\+(BEGIN_SRC)\s+(ruby)\s*(.*)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
2: constant.other.language.orgmode
|
||||||
|
3: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.source.ruby.orgmode
|
||||||
|
- match: (?i)#\+(END_SRC)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.ruby
|
||||||
|
- match: (?i)#\+(BEGIN_SRC)\s+((?:emacs-)?lisp)\s*(.*)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
2: constant.other.language.orgmode
|
||||||
|
3: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.source.lisp.orgmode
|
||||||
|
- match: (?i)#\+(END_SRC)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lisp
|
||||||
|
- match: (?i)#\+(BEGIN_SRC)\s+(sh)\s*(.*)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
2: constant.other.language.orgmode
|
||||||
|
3: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.source.shell.orgmode
|
||||||
|
- match: (?i)#\+(END_SRC)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.shell
|
||||||
|
- match: '(?i)#\+(BEGIN_(SRC|EXAMPLE))(?:\s+([\w-]+)?\s*(.*))?$'
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
3: constant.other.language.orgmode
|
||||||
|
4: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.block.source.other.orgmode
|
||||||
|
- meta_content_scope: markup.raw.block.orgmode
|
||||||
|
- match: (?i)#\+(END_\2)$
|
||||||
|
captures:
|
||||||
|
1: keyword.control.block.orgmode
|
||||||
|
pop: true
|
||||||
|
- match: '#\+(OPTIONS):'
|
||||||
|
captures:
|
||||||
|
1: keyword.control.pragma.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.pragma.options.orgmode
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- match: '([^\s]+):([^\s]+)'
|
||||||
|
scope: meta.option.orgmode
|
||||||
|
captures:
|
||||||
|
1: variable.parameter.option.orgmode
|
||||||
|
2: string.other.option.orgmode
|
||||||
|
- match: '#\+(CALL):\s+[A-Za-z-]+(?:\[([^\]]*)\])?\(?'
|
||||||
|
captures:
|
||||||
|
1: keyword.control.pragma.orgmode
|
||||||
|
2: string.other.header-args.orgmode
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.pragma.call.orgmode
|
||||||
|
- match: '\)?([^)]*)$'
|
||||||
|
captures:
|
||||||
|
1: string.other.header-args.orgmode
|
||||||
|
pop: true
|
||||||
|
- match: (\w+)=
|
||||||
|
scope: meta.assignment.orgmode
|
||||||
|
captures:
|
||||||
|
1: variable.parameter.header-args.orgmode
|
||||||
|
- match: '^#\+([a-zA-Z_-]+): ?(.*)$'
|
||||||
|
scope: meta.pragma.orgmode
|
||||||
|
captures:
|
||||||
|
1: keyword.control.pragma.orgmode
|
||||||
|
2: string.unquoted.pragma.orgmode
|
||||||
|
- include: inline
|
||||||
|
heading-inline:
|
||||||
|
- match: ':([^:^\s]*)(?=:)'
|
||||||
|
scope: meta.keyword.orgmode
|
||||||
|
captures:
|
||||||
|
1: string.quoted.keyword.orgmode
|
||||||
|
- include: inline
|
||||||
|
inline:
|
||||||
|
- match: '(?<=^|[.,:;\s])/[^/]+/(?=$|[.,:;\s])'
|
||||||
|
scope: markup.italic.orgmode
|
||||||
|
- match: '(?<=^|[.,:;\s])\*[^*]+\*(?=$|[.,:;\s])'
|
||||||
|
scope: markup.bold.orgmode
|
||||||
|
- match: '(?<=^|[.,:;\s])_[^_]+_(?=$|[.,:;\s])'
|
||||||
|
scope: markup.underline.orgmode
|
||||||
|
- match: '(?<=^|[.,:;\s])([~=]).+?\1(?=$|[.,:;\s])'
|
||||||
|
scope: markup.raw.inline.orgmode
|
||||||
|
- match: '\[(?:\[([^\]]*)\])?\[([^\]]*)\]\]'
|
||||||
|
scope: meta.link.orgmode
|
||||||
|
captures:
|
||||||
|
1: markup.underline.link.orgmode
|
||||||
|
2: string.other.link.orgmode
|
||||||
|
- match: (?:http|ftp)s?:\/\/\S+
|
||||||
|
scope: markup.underline.url.orgmode
|
||||||
|
list-inline:
|
||||||
|
- match: '\[[ -X]\]'
|
||||||
|
scope: keyword.operator.checkbox.orgmode
|
||||||
|
- include: inline
|
||||||
|
properties:
|
||||||
|
- match: '^:([A-Za-z_]+):\s(.*)$'
|
||||||
|
scope: meta.property.orgmode
|
||||||
|
captures:
|
||||||
|
1: keyword.control.property.orgmode
|
||||||
|
2: string.unquoted.propval.orgmode
|
||||||
+1
Submodule assets/syntaxes/SCSS_Sass added at 1195db9f16
+1
Submodule assets/syntaxes/Strace added at 3ec51e0bca
+1
Submodule assets/syntaxes/Verilog added at 532e87c1b4
+149
@@ -0,0 +1,149 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: Verilog
|
||||||
|
file_extensions:
|
||||||
|
- v
|
||||||
|
- V
|
||||||
|
scope: source.verilog
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: '^\s*(module|function|primitive)\s+\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
|
||||||
|
scope: meta.entity.module.verilog
|
||||||
|
captures:
|
||||||
|
1: storage.type.verilog
|
||||||
|
2: entity.name.type.class.verilog
|
||||||
|
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
|
||||||
|
scope: meta.definition.verilog
|
||||||
|
captures:
|
||||||
|
1: entity.name.type.class.verilog
|
||||||
|
2: entity.name.type.instance.verilog
|
||||||
|
3: keyword.operator.parenthesis.round.verilog
|
||||||
|
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([#])(\()([ ._+`,a-zA-Z0-9]+)(\))\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
|
||||||
|
scope: meta.definition.withparameter.verilog
|
||||||
|
captures:
|
||||||
|
1: entity.name.type.class.verilog
|
||||||
|
2: keyword.other.verilog
|
||||||
|
3: keyword.operator.parenthesis.round.verilog
|
||||||
|
4: keyword.other.verilog
|
||||||
|
5: keyword.operator.parenthesis.round.verilog
|
||||||
|
6: entity.name.type.instance.verilog
|
||||||
|
7: keyword.operator.parenthesis.round.verilog
|
||||||
|
- match: '^\s*\b(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\b\s+([#])'
|
||||||
|
scope: meta.definition.withparameter.verilog
|
||||||
|
captures:
|
||||||
|
1: entity.name.type.class.verilog
|
||||||
|
2: keyword.other.verilog
|
||||||
|
- match: '^\s*(defparam)\s+([a-zA-Z_][a-zA-Z0-9_]*)(.[a-zA-Z_][a-zA-Z0-9_]*)\s*(=)'
|
||||||
|
scope: meta.definition.defparam.verilog
|
||||||
|
captures:
|
||||||
|
1: keyword.other.verilog
|
||||||
|
2: entity.name.type.instance.verilog
|
||||||
|
3: meta.module.parameters.verilog
|
||||||
|
4: keyword.other.verilog
|
||||||
|
- match: \b(automatic|cell|config|deassign|defparam|design|disable|edge|endconfig|endgenerate|endspecify|endtable|endtask|event|generate|genvar|ifnone|incdir|include|instance|liblist|library|localparam|macromodule|negedge|noshowcancelled|posedge|pulsestyle_onevent|pulsestyle_ondetect|real|realtime|scalared|showcancelled|specify|specparam|table|task|time|use|vectored)\b
|
||||||
|
scope: keyword.other.verilog
|
||||||
|
- match: "(#[0-9]+)"
|
||||||
|
scope: keyword.delay.verilog
|
||||||
|
- match: \b(initial|always|wait|force|release|assign)\b
|
||||||
|
scope: keyword.control.verilog
|
||||||
|
- match: \b(begin|end|fork|join)\b
|
||||||
|
scope: keyword.other.verilog
|
||||||
|
- match: \b(forever|repeat|while|for|if|else|case|casex|casez|default|endcase)\b
|
||||||
|
scope: keyword.control.verilog
|
||||||
|
- match: '^\s*(`include)\s+(["<].*[">])'
|
||||||
|
scope: meta.include.verilog
|
||||||
|
captures:
|
||||||
|
1: meta.preprocessor.verilog
|
||||||
|
2: entity.name.type.include.verilog
|
||||||
|
- match: '^\s*(`ifdef|`ifndef|`undef|`define)\s+([a-zA-Z_][a-zA-Z0-9_]*)\b'
|
||||||
|
scope: meta.preprocessor.ifdef.verilog
|
||||||
|
captures:
|
||||||
|
1: meta.preprocessor.verilog
|
||||||
|
2: constant.other.define.verilog
|
||||||
|
- match: '`(celldefine|default_nettype|define|else|elsif|endcelldefine|endif|ifdef|ifndef|include|line|nounconnected_drive|resetall|timescale|unconnected_drive|undef)\b'
|
||||||
|
scope: meta.preprocessor.verilog
|
||||||
|
- match: "[.][_a-zA-Z0-9]+"
|
||||||
|
scope: meta.module.parameters.verilog
|
||||||
|
- match: '`\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
|
||||||
|
scope: constant.other.define.verilog
|
||||||
|
- include: comments
|
||||||
|
- match: \b(endmodule|endfunction|endprimitive)\b
|
||||||
|
scope: storage.type.verilog
|
||||||
|
- match: '^\s*\b([a-zA-Z_][a-zA-Z0-9_]*)\b\s*(:)\s*'
|
||||||
|
scope: meta.case.verilog
|
||||||
|
captures:
|
||||||
|
1: entity.name.state.verilog
|
||||||
|
2: keyword.operator.bitwise.verilog
|
||||||
|
- include: all-types
|
||||||
|
- match: (==|===|!=|!==|<=|>=|<|>)
|
||||||
|
scope: keyword.operator.comparison.verilog
|
||||||
|
- match: (\-|\+|\*|\/|%)
|
||||||
|
scope: keyword.operator.arithmetic.verilog
|
||||||
|
- match: (!|&&|\|\|)
|
||||||
|
scope: keyword.operator.logical.verilog
|
||||||
|
- match: (&|\||\^|~|<<|>>|\?|:)
|
||||||
|
scope: keyword.operator.bitwise.verilog
|
||||||
|
- match: "({|})"
|
||||||
|
scope: keyword.operator.parenthesis.curly.verilog
|
||||||
|
- match: (\(|\))
|
||||||
|
scope: keyword.operator.parenthesis.round.verilog
|
||||||
|
- match: '(\[|\])'
|
||||||
|
scope: keyword.operator.parenthesis.square.verilog
|
||||||
|
- match: "([;,])"
|
||||||
|
scope: keyword.delimiter.verilog
|
||||||
|
- match: (#|@|=)
|
||||||
|
scope: keyword.other.verilog
|
||||||
|
- match: '\b(output|input|inout|and|nand|nor|or|xor|xnor|buf|not|bufif[01]|notif[01]|r?[npc]mos|tran|r?tranif[01]|pullup|pulldown)\b'
|
||||||
|
scope: support.type.verilog
|
||||||
|
- match: '((\b\d+)?''s?([bB]\s*(([0-1_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[oO]\s*(([0-7_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[dD]\s*(([0-9_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[hH]\s*(([0-9a-fA-F_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*)))((e|E)(\+|-)?[0-9]+)?\b)|(\b\d+\b)'
|
||||||
|
scope: constant.numeric.verilog
|
||||||
|
- include: strings
|
||||||
|
- match: '\$\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
|
||||||
|
scope: support.function.verilog
|
||||||
|
all-types:
|
||||||
|
- include: storage-type-verilog
|
||||||
|
- include: storage-modifier-verilog
|
||||||
|
comments:
|
||||||
|
- match: /\*
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.comment.verilog
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.verilog
|
||||||
|
- match: \*/
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.comment.verilog
|
||||||
|
pop: true
|
||||||
|
- match: (//).*$\n?
|
||||||
|
scope: comment.line.double-slash.verilog
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.comment.verilog
|
||||||
|
storage-modifier-verilog:
|
||||||
|
- match: '\b(signed|unsigned|small|medium|large|supply[01]|strong[01]|pull[01]|weak[01]|highz[01])\b'
|
||||||
|
scope: storage.modifier.verilog
|
||||||
|
storage-type-verilog:
|
||||||
|
- match: '\b(wire|tri|tri[01]|supply[01]|wand|triand|wor|trior|trireg|reg|parameter|integer)\b'
|
||||||
|
scope: storage.type.verilog
|
||||||
|
strings:
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.begin.verilog
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.verilog
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.end.verilog
|
||||||
|
pop: true
|
||||||
|
- match: \\.
|
||||||
|
scope: constant.character.escape.verilog
|
||||||
|
- match: "'"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.begin.verilog
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.single.verilog
|
||||||
|
- match: "'"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.end.verilog
|
||||||
|
pop: true
|
||||||
|
- match: \\.
|
||||||
|
scope: constant.character.escape.verilog
|
||||||
+1
Submodule assets/syntaxes/hosts added at 21250a7117
+1
Submodule assets/syntaxes/requirementstxt added at 775e6dd62a
+19
@@ -0,0 +1,19 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: requirements.txt
|
||||||
|
file_extensions:
|
||||||
|
- requirements.txt
|
||||||
|
scope: source.requirementstxt
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: (#).*$\n?
|
||||||
|
scope: comment.line.requirementstxt
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.comment.requirementstxt
|
||||||
|
- match: '(?i)^[a-z0-9_\-\.]+'
|
||||||
|
scope: string.package_name.requirementstxt
|
||||||
|
- match: (?i)==|<|<=|>=|>
|
||||||
|
scope: keyword.operator.logical.punctuation.requirementstxt
|
||||||
|
- match: '(?i)\d+\.[\da-z\-_\.]*'
|
||||||
|
scope: constant.numeric.verions.requirementstxt
|
||||||
@@ -25,3 +25,7 @@ contexts:
|
|||||||
scope: entity.other.attribute-name.show-nonprintable.escape
|
scope: entity.other.attribute-name.show-nonprintable.escape
|
||||||
- match: "␈"
|
- match: "␈"
|
||||||
scope: entity.other.attribute-name.show-nonprintable.backspace
|
scope: entity.other.attribute-name.show-nonprintable.backspace
|
||||||
|
- match: "\\\\x[A-Z0-9][A-Z0-9]"
|
||||||
|
scope: comment.block.show-nonprintable.backspace
|
||||||
|
- match: "\\\\u\\{[a-z0-9]+\\}"
|
||||||
|
scope: comment.block.show-nonprintable.backspace
|
||||||
|
|||||||
+1
Submodule assets/syntaxes/ssh-config added at 86bfd1b090
Vendored
+3
@@ -107,6 +107,9 @@ make_deb() {
|
|||||||
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
||||||
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
|
||||||
|
|
||||||
|
# completions
|
||||||
|
install -Dm644 assets/completions/bat.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"
|
||||||
|
|
||||||
# readme and license
|
# readme and license
|
||||||
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
|
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
|
||||||
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
|
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
|
||||||
|
|||||||
Vendored
+2
-1
@@ -33,5 +33,6 @@ if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
|
|||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
gcc-4.8-aarch64-linux-gnu \
|
gcc-4.8-aarch64-linux-gnu \
|
||||||
binutils-aarch64-linux-gnu \
|
binutils-aarch64-linux-gnu \
|
||||||
gcc-aarch64-linux-gnu
|
gcc-aarch64-linux-gnu \
|
||||||
|
libc6-dev-arm64-cross
|
||||||
fi
|
fi
|
||||||
|
|||||||
+9
-1
@@ -97,7 +97,7 @@ bat f - g # output 'f', then stdin, then 'g'.
|
|||||||
最新の `.deb` パッケージを[こちら](https://github.com/sharkdp/bat/releases)からダウンロードして、インストールしてください:
|
最新の `.deb` パッケージを[こちら](https://github.com/sharkdp/bat/releases)からダウンロードして、インストールしてください:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
sudo dpkg -i bat_0.11.0_amd64.deb # adapt version number and architecture
|
sudo dpkg -i bat_0.12.0_amd64.deb # adapt version number and architecture
|
||||||
```
|
```
|
||||||
|
|
||||||
### Arch Linux
|
### Arch Linux
|
||||||
@@ -124,6 +124,14 @@ xbps-install -S bat
|
|||||||
dnf module install bat
|
dnf module install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Gentoo Linux
|
||||||
|
|
||||||
|
[Gentoo Linuxの公式リソース](https://packages.gentoo.org/packages/sys-apps/bat)からインストールできます。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
emerge sys-apps/bat
|
||||||
|
```
|
||||||
|
|
||||||
### FreeBSD
|
### FreeBSD
|
||||||
|
|
||||||
事前にコンパイル済みである[pkg](https://www.freshports.org/textproc/bat)をインストールできます:
|
事前にコンパイル済みである[pkg](https://www.freshports.org/textproc/bat)をインストールできます:
|
||||||
|
|||||||
@@ -10,27 +10,35 @@ bat [OPTIONS] [FILE]...
|
|||||||
bat <SUBCOMMAND>
|
bat <SUBCOMMAND>
|
||||||
.SH "OPTIONS"
|
.SH "OPTIONS"
|
||||||
.HP
|
.HP
|
||||||
|
General remarks
|
||||||
|
.IP
|
||||||
|
Command-line options like '-l'/'--language' that take values can be specified as
|
||||||
|
either '--language value', '--language=value', '-l value' or '-lvalue'.
|
||||||
|
.HP
|
||||||
\fB\-l\fR, \fB\-\-language\fR <language>
|
\fB\-l\fR, \fB\-\-language\fR <language>
|
||||||
.IP
|
.IP
|
||||||
Explicitly set the language for syntax highlighting. The language can be specified as a
|
Explicitly set the language for syntax highlighting. The language can be
|
||||||
name (like 'C++' or 'LaTeX') or possible file extension (like 'cpp', 'hpp' or 'md'). Use
|
specified as a name (like 'C++' or 'LaTeX') or possible file extension
|
||||||
\&'\-\-list\-languages' to show all supported language names and file extensions.
|
(like 'cpp', 'hpp' or 'md'). Use '\-\-list\-languages' to show all supported
|
||||||
|
language names and file extensions.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-list\-languages\fR
|
\fB\-L\fR, \fB\-\-list\-languages\fR
|
||||||
.IP
|
.IP
|
||||||
Display a list of supported languages for syntax highlighting.
|
Display a list of supported languages for syntax highlighting.
|
||||||
.HP
|
.HP
|
||||||
\fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>...
|
\fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>...
|
||||||
.IP
|
.IP
|
||||||
Map a file extension or file name to an existing syntax. For example, to highlight
|
Map a file extension or file name to an existing syntax. For example, to
|
||||||
*.conf files with the INI syntax, use '\-m conf:ini'. To highlight files named
|
highlight *.conf files with the INI syntax, use '\-m conf:ini'. To
|
||||||
\&'.myignore' with the Git Ignore syntax, use '\-m .myignore:gitignore'.
|
highlight files named '.myignore' with the Git Ignore syntax, use '\-m
|
||||||
|
\&.myignore:gitignore'.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-theme\fR <theme>
|
\fB\-\-theme\fR <theme>
|
||||||
.IP
|
.IP
|
||||||
Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes.
|
Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all
|
||||||
To set a default theme, add the '\-\-theme="..."' option to the configuration file or
|
available themes. To set a default theme, add the '\-\-theme="..."' option
|
||||||
export the BAT_THEME environment variable (e.g.: export BAT_THEME="...").
|
to the configuration file or export the BAT_THEME environment variable
|
||||||
|
(e.g.: export BAT_THEME="...").
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-list\-themes\fR
|
\fB\-\-list\-themes\fR
|
||||||
.IP
|
.IP
|
||||||
@@ -38,27 +46,29 @@ Display a list of supported themes for syntax highlighting.
|
|||||||
.HP
|
.HP
|
||||||
\fB\-\-style\fR <style\-components>
|
\fB\-\-style\fR <style\-components>
|
||||||
.IP
|
.IP
|
||||||
Configure which elements (line numbers, file headers, grid borders, Git modifications,
|
Configure which elements (line numbers, file headers, grid borders, Git
|
||||||
\&..) to display in addition to the file contents. The argument is a comma\-separated list
|
modifications, ..) to display in addition to the file contents. The
|
||||||
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full').
|
argument is a comma\-separated list of components to display (e.g.
|
||||||
To set a default style, add the '\-\-style=".."' option to the configuration file or
|
\&'numbers,changes,grid') or a pre\-defined style ('full'). To set a default
|
||||||
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
|
style, add the '\-\-style=".."' option to the configuration file or export
|
||||||
values: *auto*, full, plain, changes, header, grid, numbers.
|
the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
|
||||||
|
values: *auto*, full, plain, changes, header, grid, numbers, snip.
|
||||||
.HP
|
.HP
|
||||||
\fB\-p\fR, \fB\-\-plain\fR
|
\fB\-p\fR, \fB\-\-plain\fR
|
||||||
.IP
|
.IP
|
||||||
Only show plain style, no decorations. This is an alias for '\-\-style=plain'. When '\-p'
|
Only show plain style, no decorations. This is an alias for
|
||||||
is used twice ('\-pp'), it also disables automatic paging (alias for '\-\-style=plain
|
\&'\-\-style=plain'. When '\-p' is used twice ('\-pp'), it also disables
|
||||||
\fB\-\-pager\fR=\fI\,never\/\fR').
|
automatic paging (alias for '\-\-style=plain \fB\-\-pager\fR=\fI\,never\/\fR').
|
||||||
.HP
|
.HP
|
||||||
\fB\-n\fR, \fB\-\-number\fR
|
\fB\-n\fR, \fB\-\-number\fR
|
||||||
.IP
|
.IP
|
||||||
Only show line numbers, no other decorations. This is an alias for '\-\-style=numbers'
|
Only show line numbers, no other decorations. This is an alias for
|
||||||
|
\&'\-\-style=numbers'
|
||||||
.HP
|
.HP
|
||||||
\fB\-A\fR, \fB\-\-show\-all\fR
|
\fB\-A\fR, \fB\-\-show\-all\fR
|
||||||
.IP
|
.IP
|
||||||
Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to control the
|
Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to
|
||||||
width of the tab\-placeholders.
|
control the width of the tab\-placeholders.
|
||||||
.HP
|
.HP
|
||||||
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
|
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
|
||||||
.IP
|
.IP
|
||||||
@@ -78,52 +88,57 @@ Highlight the N\-th line with a different background color
|
|||||||
.HP
|
.HP
|
||||||
\fB\-\-color\fR <when>
|
\fB\-\-color\fR <when>
|
||||||
.IP
|
.IP
|
||||||
Specify when to use colored output. The automatic mode only enables colors if an
|
Specify when to use colored output. The automatic mode only enables colors
|
||||||
interactive terminal is detected. Possible values: *auto*, never, always.
|
if an interactive terminal is detected. Possible values: *auto*, never,
|
||||||
|
always.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-italic\-text\fR <when>
|
\fB\-\-italic\-text\fR <when>
|
||||||
.IP
|
.IP
|
||||||
Specify when to use ANSI sequences for italic text in the output. Possible values:
|
Specify when to use ANSI sequences for italic text in the output. Possible
|
||||||
always, *never*.
|
values: always, *never*.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-decorations\fR <when>
|
\fB\-\-decorations\fR <when>
|
||||||
.IP
|
.IP
|
||||||
Specify when to use the decorations that have been specified via '\-\-style'. The
|
Specify when to use the decorations that have been specified via
|
||||||
automatic mode only enables decorations if an interactive terminal is detected. Possible
|
\&'\-\-style'. The automatic mode only enables decorations if an interactive
|
||||||
values: *auto*, never, always.
|
terminal is detected. Possible values: *auto*, never, always.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-paging\fR <when>
|
\fB\-\-paging\fR <when>
|
||||||
.IP
|
.IP
|
||||||
Specify when to use the pager. To control which pager is used, set the PAGER or
|
Specify when to use the pager. To control which pager is used, set the
|
||||||
BAT_PAGER environment variables (the latter takes precedence) or use the '\-\-pager'
|
PAGER or BAT_PAGER environment variables (the latter takes precedence) or
|
||||||
option. To disable the pager permanently, set BAT_PAGER to an empty string or set
|
use the '\-\-pager' option. To disable the pager permanently, set BAT_PAGER
|
||||||
\&'\-\-paging=never' in the configuration file. Possible values: *auto*, never, always.
|
to an empty string or set '\-\-paging=never' in the configuration file.
|
||||||
|
Possible values: *auto*, never, always.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-pager\fR <command>
|
\fB\-\-pager\fR <command>
|
||||||
.IP
|
.IP
|
||||||
Determine which pager is used. This option will overwrite the PAGER and BAT_PAGER
|
Determine which pager is used. This option will overwrite the PAGER and
|
||||||
environment variables. The default pager is 'less'. To disable the pager completely, use
|
BAT_PAGER environment variables. The default pager is 'less'. To disable
|
||||||
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
|
the pager completely, use the '\-\-paging' option. Example: '\-\-pager "less
|
||||||
|
\fB\-RF\fR"'.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-wrap\fR <mode>
|
\fB\-\-wrap\fR <mode>
|
||||||
.IP
|
.IP
|
||||||
Specify the text\-wrapping mode (*auto*, never, character). The '\-\-terminal\-width' option
|
Specify the text\-wrapping mode (*auto*, never, character). The
|
||||||
can be used in addition to control the output width.
|
\&'\-\-terminal\-width' option can be used in addition to control the output
|
||||||
|
width.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-tabs\fR <T>
|
\fB\-\-tabs\fR <T>
|
||||||
.IP
|
.IP
|
||||||
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly
|
Set the tab width to T spaces. Use a width of 0 to pass tabs through
|
||||||
|
directly
|
||||||
.HP
|
.HP
|
||||||
\fB\-u\fR, \fB\-\-unbuffered\fR
|
\fB\-u\fR, \fB\-\-unbuffered\fR
|
||||||
.IP
|
.IP
|
||||||
This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is
|
This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered').
|
||||||
always unbuffered \- this option is simply ignored.
|
The output is always unbuffered \- this option is simply ignored.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-terminal\-width\fR <width>
|
\fB\-\-terminal\-width\fR <width>
|
||||||
.IP
|
.IP
|
||||||
Explicitly set the width of the terminal instead of determining it automatically. If
|
Explicitly set the width of the terminal instead of determining it
|
||||||
prefixed with '+' or '\-', the value will be treated as an offset to the actual terminal
|
automatically. If prefixed with '+' or '\-', the value will be treated as
|
||||||
width. See also: '\-\-wrap'.
|
an offset to the actual terminal width. See also: '\-\-wrap'.
|
||||||
.HP
|
.HP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
.IP
|
.IP
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ impl HighlightingAssets {
|
|||||||
|
|
||||||
pub fn save(&self, dir: Option<&Path>) -> Result<()> {
|
pub fn save(&self, dir: Option<&Path>) -> Result<()> {
|
||||||
let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir());
|
let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir());
|
||||||
let _ = fs::create_dir(target_dir);
|
let _ = fs::create_dir_all(target_dir);
|
||||||
let theme_set_path = target_dir.join("themes.bin");
|
let theme_set_path = target_dir.join("themes.bin");
|
||||||
let syntax_set_path = target_dir.join("syntaxes.bin");
|
let syntax_set_path = target_dir.join("syntaxes.bin");
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -19,6 +19,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.global_setting(AppSettings::UnifiedHelpMessage)
|
.global_setting(AppSettings::UnifiedHelpMessage)
|
||||||
.global_setting(AppSettings::HidePossibleValuesInHelp)
|
.global_setting(AppSettings::HidePossibleValuesInHelp)
|
||||||
.setting(AppSettings::ArgsNegateSubcommands)
|
.setting(AppSettings::ArgsNegateSubcommands)
|
||||||
|
.setting(AppSettings::AllowExternalSubcommands)
|
||||||
.setting(AppSettings::DisableHelpSubcommand)
|
.setting(AppSettings::DisableHelpSubcommand)
|
||||||
.setting(AppSettings::VersionlessSubcommands)
|
.setting(AppSettings::VersionlessSubcommands)
|
||||||
.max_term_width(100)
|
.max_term_width(100)
|
||||||
@@ -54,6 +55,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("list-languages")
|
Arg::with_name("list-languages")
|
||||||
.long("list-languages")
|
.long("list-languages")
|
||||||
|
.short("L")
|
||||||
.conflicts_with("list-themes")
|
.conflicts_with("list-themes")
|
||||||
.help("Display all supported languages.")
|
.help("Display all supported languages.")
|
||||||
.long_help("Display a list of supported languages for syntax highlighting."),
|
.long_help("Display a list of supported languages for syntax highlighting."),
|
||||||
@@ -110,7 +112,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.validator(|val| {
|
.validator(|val| {
|
||||||
let mut invalid_vals = val.split(',').filter(|style| {
|
let mut invalid_vals = val.split(',').filter(|style| {
|
||||||
!&[
|
!&[
|
||||||
"auto", "full", "plain", "changes", "header", "grid", "numbers",
|
"auto", "full", "plain", "changes", "header", "grid", "numbers", "snip"
|
||||||
]
|
]
|
||||||
.contains(style)
|
.contains(style)
|
||||||
});
|
});
|
||||||
@@ -123,7 +125,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
})
|
})
|
||||||
.help(
|
.help(
|
||||||
"Comma-separated list of style elements to display \
|
"Comma-separated list of style elements to display \
|
||||||
(*auto*, full, plain, changes, header, grid, numbers).",
|
(*auto*, full, plain, changes, header, grid, numbers, snip).",
|
||||||
)
|
)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Configure which elements (line numbers, file headers, grid \
|
"Configure which elements (line numbers, file headers, grid \
|
||||||
@@ -133,7 +135,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
pre-defined style ('full'). To set a default style, add the \
|
pre-defined style ('full'). To set a default style, add the \
|
||||||
'--style=\"..\"' option to the configuration file or export the \
|
'--style=\"..\"' option to the configuration file or export the \
|
||||||
BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \
|
BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \
|
||||||
Possible values: *auto*, full, plain, changes, header, grid, numbers.",
|
Possible values: *auto*, full, plain, changes, header, grid, numbers, snip.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
@@ -170,7 +172,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.help("Show non-printable characters (space, tab, newline, ..).")
|
.help("Show non-printable characters (space, tab, newline, ..).")
|
||||||
.long_help(
|
.long_help(
|
||||||
"Show non-printable characters like space, tab or newline. \
|
"Show non-printable characters like space, tab or newline. \
|
||||||
Use '--tabs' to control the width of the tab-placeholders.",
|
This option can also be used to print binary files. \
|
||||||
|
Use '--tabs' to control the width of the tab-placeholders."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
@@ -332,6 +335,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("width")
|
.value_name("width")
|
||||||
.hidden_short_help(true)
|
.hidden_short_help(true)
|
||||||
|
.allow_hyphen_values(true)
|
||||||
.validator(
|
.validator(
|
||||||
|t| {
|
|t| {
|
||||||
let is_offset = t.starts_with('+') || t.starts_with('-');
|
let is_offset = t.starts_with('+') || t.starts_with('-');
|
||||||
|
|||||||
+17
-2
@@ -76,7 +76,7 @@ impl<'b> Controller<'b> {
|
|||||||
&self,
|
&self,
|
||||||
reader: InputFileReader,
|
reader: InputFileReader,
|
||||||
printer: &mut P,
|
printer: &mut P,
|
||||||
writer: &mut Write,
|
writer: &mut dyn Write,
|
||||||
input_file: InputFile<'a>,
|
input_file: InputFile<'a>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
printer.print_header(writer, input_file)?;
|
printer.print_header(writer, input_file)?;
|
||||||
@@ -91,21 +91,36 @@ impl<'b> Controller<'b> {
|
|||||||
fn print_file_ranges<P: Printer>(
|
fn print_file_ranges<P: Printer>(
|
||||||
&self,
|
&self,
|
||||||
printer: &mut P,
|
printer: &mut P,
|
||||||
writer: &mut Write,
|
writer: &mut dyn Write,
|
||||||
mut reader: InputFileReader,
|
mut reader: InputFileReader,
|
||||||
line_ranges: &LineRanges,
|
line_ranges: &LineRanges,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut line_buffer = Vec::new();
|
let mut line_buffer = Vec::new();
|
||||||
let mut line_number: usize = 1;
|
let mut line_number: usize = 1;
|
||||||
|
|
||||||
|
let mut first_range: bool = true;
|
||||||
|
let mut mid_range: bool = false;
|
||||||
|
|
||||||
while reader.read_line(&mut line_buffer)? {
|
while reader.read_line(&mut line_buffer)? {
|
||||||
match line_ranges.check(line_number) {
|
match line_ranges.check(line_number) {
|
||||||
RangeCheckResult::OutsideRange => {
|
RangeCheckResult::OutsideRange => {
|
||||||
// Call the printer in case we need to call the syntax highlighter
|
// Call the printer in case we need to call the syntax highlighter
|
||||||
// for this line. However, set `out_of_range` to `true`.
|
// for this line. However, set `out_of_range` to `true`.
|
||||||
printer.print_line(true, writer, line_number, &line_buffer)?;
|
printer.print_line(true, writer, line_number, &line_buffer)?;
|
||||||
|
mid_range = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeCheckResult::InRange => {
|
RangeCheckResult::InRange => {
|
||||||
|
if self.config.output_components.snip() {
|
||||||
|
if first_range {
|
||||||
|
first_range = false;
|
||||||
|
mid_range = true;
|
||||||
|
} else if !mid_range {
|
||||||
|
mid_range = true;
|
||||||
|
printer.print_snip(writer)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printer.print_line(false, writer, line_number, &line_buffer)?;
|
printer.print_line(false, writer, line_number, &line_buffer)?;
|
||||||
}
|
}
|
||||||
RangeCheckResult::AfterLastRange => {
|
RangeCheckResult::AfterLastRange => {
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ impl OutputType {
|
|||||||
OutputType::Stdout(io::stdout())
|
OutputType::Stdout(io::stdout())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(&mut self) -> Result<&mut Write> {
|
pub fn handle(&mut self) -> Result<&mut dyn Write> {
|
||||||
Ok(match *self {
|
Ok(match *self {
|
||||||
OutputType::Pager(ref mut command) => command
|
OutputType::Pager(ref mut command) => command
|
||||||
.stdin
|
.stdin
|
||||||
|
|||||||
+101
-27
@@ -33,41 +33,115 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
|
|||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replace_nonprintable(input: &str, tab_width: usize) -> String {
|
fn try_parse_utf8_char(input: &[u8]) -> Option<(char, usize)> {
|
||||||
|
let str_from_utf8 = |seq| std::str::from_utf8(seq).ok();
|
||||||
|
|
||||||
|
let decoded = None
|
||||||
|
.or(input.get(0..1).and_then(str_from_utf8).map(|c| (c, 1)))
|
||||||
|
.or(input.get(0..2).and_then(str_from_utf8).map(|c| (c, 2)))
|
||||||
|
.or(input.get(0..3).and_then(str_from_utf8).map(|c| (c, 3)))
|
||||||
|
.or(input.get(0..4).and_then(str_from_utf8).map(|c| (c, 4)));
|
||||||
|
|
||||||
|
let decoded_char = decoded.map(|(seq, n)| (seq.chars().next().unwrap(), n));
|
||||||
|
|
||||||
|
decoded_char
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
|
|
||||||
let tab_width = if tab_width == 0 { 4 } else { tab_width };
|
let tab_width = if tab_width == 0 { 4 } else { tab_width };
|
||||||
|
|
||||||
for chr in input.chars() {
|
let mut idx = 0;
|
||||||
match chr {
|
let len = input.len();
|
||||||
// space
|
while idx < len {
|
||||||
' ' => output.push('•'),
|
if let Some((chr, skip_ahead)) = try_parse_utf8_char(&input[idx..]) {
|
||||||
// tab
|
idx += skip_ahead;
|
||||||
'\t' => {
|
|
||||||
if tab_width == 1 {
|
match chr {
|
||||||
output.push('↹');
|
// space
|
||||||
} else {
|
' ' => output.push('•'),
|
||||||
output.push('├');
|
// tab
|
||||||
output.push_str(&"─".repeat(tab_width - 2));
|
'\t' => {
|
||||||
output.push('┤');
|
if tab_width == 1 {
|
||||||
|
output.push('↹');
|
||||||
|
} else {
|
||||||
|
output.push('├');
|
||||||
|
output.push_str(&"─".repeat(tab_width - 2));
|
||||||
|
output.push('┤');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// line feed
|
||||||
|
'\x0A' => output.push('␊'),
|
||||||
|
// carriage return
|
||||||
|
'\x0D' => output.push('␍'),
|
||||||
|
// null
|
||||||
|
'\x00' => output.push('␀'),
|
||||||
|
// bell
|
||||||
|
'\x07' => output.push('␇'),
|
||||||
|
// backspace
|
||||||
|
'\x08' => output.push('␈'),
|
||||||
|
// escape
|
||||||
|
'\x1B' => output.push('␛'),
|
||||||
|
// printable ASCII
|
||||||
|
c if c.is_ascii_alphanumeric()
|
||||||
|
|| c.is_ascii_punctuation()
|
||||||
|
|| c.is_ascii_graphic() =>
|
||||||
|
{
|
||||||
|
output.push(c)
|
||||||
|
}
|
||||||
|
// everything else
|
||||||
|
c => output.push_str(&c.escape_unicode().collect::<String>()),
|
||||||
}
|
}
|
||||||
// line feed
|
} else {
|
||||||
'\x0A' => output.push('␊'),
|
output.push_str(&format!("\\x{:02X}", input[idx]));
|
||||||
// carriage return
|
idx += 1;
|
||||||
'\x0D' => output.push('␍'),
|
|
||||||
// null
|
|
||||||
'\x00' => output.push('␀'),
|
|
||||||
// bell
|
|
||||||
'\x07' => output.push('␇'),
|
|
||||||
// backspace
|
|
||||||
'\x08' => output.push('␈'),
|
|
||||||
// escape
|
|
||||||
'\x1B' => output.push('␛'),
|
|
||||||
// anything else
|
|
||||||
_ => output.push(chr),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_try_parse_utf8_char() {
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0x20]), Some((' ', 1)));
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0x20, 0x20]), Some((' ', 1)));
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0x20, 0xef]), Some((' ', 1)));
|
||||||
|
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0x00]), Some(('\x00', 1)));
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0x1b]), Some(('\x1b', 1)));
|
||||||
|
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4]), Some(('ä', 2)));
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0xef]), Some(('ä', 2)));
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0x20]), Some(('ä', 2)));
|
||||||
|
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xe2, 0x82, 0xac]), Some(('€', 3)));
|
||||||
|
assert_eq!(
|
||||||
|
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0xef]),
|
||||||
|
Some(('€', 3))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0x20]),
|
||||||
|
Some(('€', 3))
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xe2, 0x88, 0xb0]), Some(('∰', 3)));
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82]),
|
||||||
|
Some(('🌂', 4))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0xef]),
|
||||||
|
Some(('🌂', 4))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0x20]),
|
||||||
|
Some(('🌂', 4))
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(try_parse_utf8_char(&[]), None);
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xef]), None);
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xef, 0x20]), None);
|
||||||
|
assert_eq!(try_parse_utf8_char(&[0xf0, 0xf0]), None);
|
||||||
|
}
|
||||||
|
|||||||
+87
-29
@@ -30,12 +30,15 @@ use crate::style::OutputWrap;
|
|||||||
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||||
|
|
||||||
pub trait Printer {
|
pub trait Printer {
|
||||||
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
|
fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
|
||||||
fn print_footer(&mut self, handle: &mut Write) -> Result<()>;
|
fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
|
||||||
|
|
||||||
|
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
|
||||||
|
|
||||||
fn print_line(
|
fn print_line(
|
||||||
&mut self,
|
&mut self,
|
||||||
out_of_range: bool,
|
out_of_range: bool,
|
||||||
handle: &mut Write,
|
handle: &mut dyn Write,
|
||||||
line_number: usize,
|
line_number: usize,
|
||||||
line_buffer: &[u8],
|
line_buffer: &[u8],
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
@@ -50,18 +53,22 @@ impl SimplePrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Printer for SimplePrinter {
|
impl Printer for SimplePrinter {
|
||||||
fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> {
|
fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_footer(&mut self, _handle: &mut Write) -> Result<()> {
|
fn print_footer(&mut self, _handle: &mut dyn Write) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_snip(&mut self, _handle: &mut dyn Write) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_line(
|
fn print_line(
|
||||||
&mut self,
|
&mut self,
|
||||||
out_of_range: bool,
|
out_of_range: bool,
|
||||||
handle: &mut Write,
|
handle: &mut dyn Write,
|
||||||
_line_number: usize,
|
_line_number: usize,
|
||||||
line_buffer: &[u8],
|
line_buffer: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@@ -134,7 +141,10 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
|
|
||||||
let mut line_changes = None;
|
let mut line_changes = None;
|
||||||
|
|
||||||
let highlighter = if reader.content_type.map_or(false, |c| c.is_binary()) {
|
let highlighter = if reader
|
||||||
|
.content_type
|
||||||
|
.map_or(false, |c| c.is_binary() && !config.show_nonprintable)
|
||||||
|
{
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
// Get the Git modifications
|
// Get the Git modifications
|
||||||
@@ -166,7 +176,7 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_horizontal_line(&mut self, handle: &mut Write, grid_char: char) -> Result<()> {
|
fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
|
||||||
if self.panel_width == 0 {
|
if self.panel_width == 0 {
|
||||||
writeln!(
|
writeln!(
|
||||||
handle,
|
handle,
|
||||||
@@ -182,6 +192,24 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_fake_panel(&self, text: &str) -> String {
|
||||||
|
if self.panel_width == 0 {
|
||||||
|
"".to_string()
|
||||||
|
} else {
|
||||||
|
let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
|
||||||
|
let text_filled: String = format!(
|
||||||
|
"{}{}",
|
||||||
|
text_truncated,
|
||||||
|
" ".repeat(self.panel_width - 1 - text_truncated.len())
|
||||||
|
);
|
||||||
|
if self.config.output_components.grid() {
|
||||||
|
format!("{} │ ", text_filled)
|
||||||
|
} else {
|
||||||
|
format!("{}", text_filled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
|
fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
|
||||||
if self.config.tab_width > 0 {
|
if self.config.tab_width > 0 {
|
||||||
expand_tabs(text, self.config.tab_width, cursor)
|
expand_tabs(text, self.config.tab_width, cursor)
|
||||||
@@ -192,9 +220,9 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Printer for InteractivePrinter<'a> {
|
impl<'a> Printer for InteractivePrinter<'a> {
|
||||||
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> {
|
fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
|
||||||
if !self.config.output_components.header() {
|
if !self.config.output_components.header() {
|
||||||
if Some(ContentType::BINARY) == self.content_type {
|
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
|
||||||
let input = match file {
|
let input = match file {
|
||||||
InputFile::Ordinary(filename) => format!("file '{}'", filename),
|
InputFile::Ordinary(filename) => format!("file '{}'", filename),
|
||||||
_ => "STDIN".into(),
|
_ => "STDIN".into(),
|
||||||
@@ -203,10 +231,15 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
writeln!(
|
writeln!(
|
||||||
handle,
|
handle,
|
||||||
"{}: Binary content from {} will not be printed to the terminal \
|
"{}: Binary content from {} will not be printed to the terminal \
|
||||||
(but will be present if the output of 'bat' is piped).",
|
(but will be present if the output of 'bat' is piped). You can use 'bat -A' \
|
||||||
|
to show the binary file contents.",
|
||||||
Yellow.paint("[bat warning]"),
|
Yellow.paint("[bat warning]"),
|
||||||
input
|
input
|
||||||
)?;
|
)?;
|
||||||
|
} else {
|
||||||
|
if self.config.output_components.grid() {
|
||||||
|
self.print_horizontal_line(handle, '┬')?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -248,7 +281,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
if self.config.output_components.grid() {
|
if self.config.output_components.grid() {
|
||||||
if self.content_type.map_or(false, |c| c.is_text()) {
|
if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
|
||||||
self.print_horizontal_line(handle, '┼')?;
|
self.print_horizontal_line(handle, '┼')?;
|
||||||
} else {
|
} else {
|
||||||
self.print_horizontal_line(handle, '┴')?;
|
self.print_horizontal_line(handle, '┴')?;
|
||||||
@@ -258,8 +291,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_footer(&mut self, handle: &mut Write) -> Result<()> {
|
fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()> {
|
||||||
if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text())
|
if self.config.output_components.grid()
|
||||||
|
&& (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
|
||||||
{
|
{
|
||||||
self.print_horizontal_line(handle, '┴')
|
self.print_horizontal_line(handle, '┴')
|
||||||
} else {
|
} else {
|
||||||
@@ -267,30 +301,54 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()> {
|
||||||
|
let panel = self.create_fake_panel(" ...");
|
||||||
|
let panel_count = panel.chars().count();
|
||||||
|
|
||||||
|
let title = "8<";
|
||||||
|
let title_count = title.chars().count();
|
||||||
|
|
||||||
|
let snip_left = "─ ".repeat((self.config.term_width - panel_count - (title_count / 2)) / 4);
|
||||||
|
let snip_left_count = snip_left.chars().count(); // Can't use .len() with Unicode.
|
||||||
|
|
||||||
|
let snip_right =
|
||||||
|
" ─".repeat((self.config.term_width - panel_count - snip_left_count - title_count) / 2);
|
||||||
|
|
||||||
|
write!(
|
||||||
|
handle,
|
||||||
|
"{}\n",
|
||||||
|
self.colors
|
||||||
|
.grid
|
||||||
|
.paint(format!("{}{}{}{}", panel, snip_left, title, snip_right))
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn print_line(
|
fn print_line(
|
||||||
&mut self,
|
&mut self,
|
||||||
out_of_range: bool,
|
out_of_range: bool,
|
||||||
handle: &mut Write,
|
handle: &mut dyn Write,
|
||||||
line_number: usize,
|
line_number: usize,
|
||||||
line_buffer: &[u8],
|
line_buffer: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut line = match self.content_type {
|
let line = if self.config.show_nonprintable {
|
||||||
Some(ContentType::BINARY) | None => {
|
replace_nonprintable(&line_buffer, self.config.tab_width)
|
||||||
return Ok(());
|
} else {
|
||||||
|
match self.content_type {
|
||||||
|
Some(ContentType::BINARY) | None => {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Some(ContentType::UTF_16LE) => UTF_16LE
|
||||||
|
.decode(&line_buffer, DecoderTrap::Replace)
|
||||||
|
.map_err(|_| "Invalid UTF-16LE")?,
|
||||||
|
Some(ContentType::UTF_16BE) => UTF_16BE
|
||||||
|
.decode(&line_buffer, DecoderTrap::Replace)
|
||||||
|
.map_err(|_| "Invalid UTF-16BE")?,
|
||||||
|
_ => String::from_utf8_lossy(&line_buffer).to_string(),
|
||||||
}
|
}
|
||||||
Some(ContentType::UTF_16LE) => UTF_16LE
|
|
||||||
.decode(&line_buffer, DecoderTrap::Replace)
|
|
||||||
.map_err(|_| "Invalid UTF-16LE")?,
|
|
||||||
Some(ContentType::UTF_16BE) => UTF_16BE
|
|
||||||
.decode(&line_buffer, DecoderTrap::Replace)
|
|
||||||
.map_err(|_| "Invalid UTF-16BE")?,
|
|
||||||
_ => String::from_utf8_lossy(&line_buffer).to_string(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.config.show_nonprintable {
|
|
||||||
line = replace_nonprintable(&line, self.config.tab_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
let regions = {
|
let regions = {
|
||||||
let highlighter = match self.highlighter {
|
let highlighter = match self.highlighter {
|
||||||
Some(ref mut highlighter) => highlighter,
|
Some(ref mut highlighter) => highlighter,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ pub enum OutputComponent {
|
|||||||
Grid,
|
Grid,
|
||||||
Header,
|
Header,
|
||||||
Numbers,
|
Numbers,
|
||||||
|
Snip,
|
||||||
Full,
|
Full,
|
||||||
Plain,
|
Plain,
|
||||||
}
|
}
|
||||||
@@ -34,11 +35,13 @@ impl OutputComponent {
|
|||||||
OutputComponent::Grid => &[OutputComponent::Grid],
|
OutputComponent::Grid => &[OutputComponent::Grid],
|
||||||
OutputComponent::Header => &[OutputComponent::Header],
|
OutputComponent::Header => &[OutputComponent::Header],
|
||||||
OutputComponent::Numbers => &[OutputComponent::Numbers],
|
OutputComponent::Numbers => &[OutputComponent::Numbers],
|
||||||
|
OutputComponent::Snip => &[OutputComponent::Snip],
|
||||||
OutputComponent::Full => &[
|
OutputComponent::Full => &[
|
||||||
OutputComponent::Changes,
|
OutputComponent::Changes,
|
||||||
OutputComponent::Grid,
|
OutputComponent::Grid,
|
||||||
OutputComponent::Header,
|
OutputComponent::Header,
|
||||||
OutputComponent::Numbers,
|
OutputComponent::Numbers,
|
||||||
|
OutputComponent::Snip,
|
||||||
],
|
],
|
||||||
OutputComponent::Plain => &[],
|
OutputComponent::Plain => &[],
|
||||||
}
|
}
|
||||||
@@ -55,6 +58,7 @@ impl FromStr for OutputComponent {
|
|||||||
"grid" => Ok(OutputComponent::Grid),
|
"grid" => Ok(OutputComponent::Grid),
|
||||||
"header" => Ok(OutputComponent::Header),
|
"header" => Ok(OutputComponent::Header),
|
||||||
"numbers" => Ok(OutputComponent::Numbers),
|
"numbers" => Ok(OutputComponent::Numbers),
|
||||||
|
"snip" => Ok(OutputComponent::Snip),
|
||||||
"full" => Ok(OutputComponent::Full),
|
"full" => Ok(OutputComponent::Full),
|
||||||
"plain" => Ok(OutputComponent::Plain),
|
"plain" => Ok(OutputComponent::Plain),
|
||||||
_ => Err(format!("Unknown style '{}'", s).into()),
|
_ => Err(format!("Unknown style '{}'", s).into()),
|
||||||
@@ -82,6 +86,10 @@ impl OutputComponents {
|
|||||||
self.0.contains(&OutputComponent::Numbers)
|
self.0.contains(&OutputComponent::Numbers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn snip(&self) -> bool {
|
||||||
|
self.0.contains(&OutputComponent::Snip)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn plain(&self) -> bool {
|
pub fn plain(&self) -> bool {
|
||||||
self.0.iter().all(|c| c == &OutputComponent::Plain)
|
self.0.iter().all(|c| c == &OutputComponent::Plain)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
@@ -451,7 +451,7 @@ fn utf16() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_print_file_named_cache() {
|
fn can_print_file_named_cache() {
|
||||||
bat()
|
bat_with_config()
|
||||||
.arg("cache")
|
.arg("cache")
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
@@ -459,7 +459,37 @@ fn can_print_file_named_cache() {
|
|||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_print_file_starting_with_cache() {
|
||||||
|
bat_with_config()
|
||||||
|
.arg("cache.c")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout("test\n")
|
||||||
|
.stderr("");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn does_not_print_unwanted_file_named_cache() {
|
fn does_not_print_unwanted_file_named_cache() {
|
||||||
bat_with_config().arg("cach").assert().failure();
|
bat_with_config().arg("cach").assert().failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn snip() {
|
||||||
|
bat()
|
||||||
|
.arg("multiline.txt")
|
||||||
|
.arg("--style=numbers,snip")
|
||||||
|
.arg("--decorations=always")
|
||||||
|
.arg("--line-range=1:2")
|
||||||
|
.arg("--line-range=4:")
|
||||||
|
.arg("--terminal-width=80")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(
|
||||||
|
" 1 line 1
|
||||||
|
2 line 2
|
||||||
|
...─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
|
||||||
|
4 line 4
|
||||||
|
",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
──┬─────────────────────────────────────────────────────────────────────────────
|
||||||
│ struct Rectangle {
|
│ struct Rectangle {
|
||||||
│ width: u32,
|
│ width: u32,
|
||||||
│ height: u32,
|
│ height: u32,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
───────┬────────────────────────────────────────────────────────────────────────
|
||||||
1 │ struct Rectangle {
|
1 │ struct Rectangle {
|
||||||
2 │ width: u32,
|
2 │ width: u32,
|
||||||
3 │ height: u32,
|
3 │ height: u32,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
struct Rectangle {
|
struct Rectangle {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
─────┬──────────────────────────────────────────────────────────────────────────
|
||||||
1 │ struct Rectangle {
|
1 │ struct Rectangle {
|
||||||
2 │ width: u32,
|
2 │ width: u32,
|
||||||
3 │ height: u32,
|
3 │ height: u32,
|
||||||
|
|||||||
Reference in New Issue
Block a user