Merge remote-tracking branch 'origin/master' into fix-1063

This commit is contained in:
Martin Nordholts 2021-01-10 11:56:03 +01:00
commit 02e6ff4183
22 changed files with 323 additions and 106 deletions

View File

@ -2,17 +2,18 @@ name: CICD
env:
PROJECT_NAME: bat
PROJECT_VERSION: "0.17.1"
PROJECT_DESC: "A `cat` clone with wings"
PROJECT_MAINTAINER: "David Peter <mail@david-peter.de>"
PROJECT_HOMEPAGE: "https://github.com/sharkdp/bat"
MIN_SUPPORTED_RUST_VERSION: "1.40.0"
MIN_SUPPORTED_RUST_VERSION: "1.42.0"
on: [push, pull_request]
jobs:
min_version:
name: Minimum supported rust version
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v2
@ -27,7 +28,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features -- --allow clippy::style
args: --all-targets --all-features
- name: Test
uses: actions-rs/cargo@v1
with:
@ -35,7 +36,7 @@ jobs:
test_with_new_syntaxes_and_themes:
name: Test with new syntaxes and themes
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v2
@ -83,19 +84,17 @@ jobs:
fail-fast: false
matrix:
job:
# { os, target, cargo-options, features, use-cross }
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , use-cross: true }
- { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true }
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true }
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true }
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu }
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true }
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu }
- { os: macos-latest , target: x86_64-apple-darwin }
# - { os: windows-latest , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
- { os: windows-latest , target: i686-pc-windows-msvc }
- { os: windows-latest , target: x86_64-pc-windows-gnu }
- { os: windows-latest , target: x86_64-pc-windows-msvc }
- { os: ubuntu-18.04 , target: arm-unknown-linux-gnueabihf , use-cross: true }
- { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true }
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true }
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true }
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu }
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true }
- { os: macos-10.15 , target: x86_64-apple-darwin }
# - { os: windows-2019 , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
- { os: windows-2019 , target: i686-pc-windows-msvc }
- { os: windows-2019 , target: x86_64-pc-windows-gnu }
- { os: windows-2019 , target: x86_64-pc-windows-msvc }
steps:
- name: Git checkout
uses: actions/checkout@v2
@ -116,26 +115,14 @@ jobs:
# determine EXE suffix
EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
echo ::set-output name=EXE_suffix::${EXE_suffix}
# parse commit reference info
unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
REF_SHAS=${GITHUB_SHA:0:8}
# parse target
unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
echo ::set-output name=TARGET_OS::${TARGET_OS}
# package name
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }}
PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
echo ::set-output name=PKG_suffix::${PKG_suffix}
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
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}
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
echo ::set-output name=IS_RELEASE::${IS_RELEASE}
# DPKG architecture?
unset DPKG_ARCH
case ${{ matrix.job.target }} in
@ -145,8 +132,7 @@ jobs:
x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
esac;
echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
# DPKG version?
unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
DPKG_VERSION=${PROJECT_VERSION}
echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
# DPKG base name/conflicts?
DPKG_BASENAME=${PROJECT_NAME}
@ -159,10 +145,6 @@ jobs:
if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
echo ::set-output name=DPKG_NAME::${DPKG_NAME}
# target-specific options
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
JOB_DO_TESTING="true"
case ${{ matrix.job.target }} in arm-*) unset JOB_DO_TESTING ;; esac;
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
# # * test only library unit tests and binary for arm-type targets
unset CARGO_TEST_OPTIONS
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac;
@ -241,11 +223,6 @@ jobs:
use-cross: ${{ matrix.job.use-cross }}
command: check
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git,paging
- name: Upload build artifacts
uses: actions/upload-artifact@master
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
- name: Package
shell: bash
run: |
@ -358,9 +335,20 @@ jobs:
# build dpkg
fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
fi
- name: Upload package artifact
uses: actions/upload-artifact@master
with:
name: ${{ steps.vars.outputs.PKG_NAME }}
path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
- name: Upload Debian package artifact
uses: actions/upload-artifact@master
if: steps.vars.outputs.DPKG_NAME
with:
name: ${{ steps.vars.outputs.DPKG_NAME }}
path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
- name: Publish archives and packages
uses: softprops/action-gh-release@v1
if: steps.vars.outputs.DEPLOY
if: steps.vars.outputs.IS_RELEASE
with:
files: |
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
@ -375,11 +363,10 @@ jobs:
strategy:
fail-fast: true
matrix:
# job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ]
job:
- { os: ubuntu-latest , toolchain: nightly-2020-04-29 }
- { os: macos-latest , toolchain: nightly-2020-04-29 }
- { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
- { os: ubuntu-18.04 , toolchain: nightly-2020-04-29 }
- { os: macos-10.15 , toolchain: nightly-2020-04-29 }
- { os: windows-2019 , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
steps:
- uses: actions/checkout@v2
- name: Initialize workflow variables

3
.gitmodules vendored
View File

@ -213,3 +213,6 @@
[submodule "assets/syntaxes/02_Extra/Zig"]
path = assets/syntaxes/02_Extra/Zig
url = https://github.com/ziglang/sublime-zig-language.git
[submodule "assets/syntaxes/02_Extra/gnuplot"]
path = assets/syntaxes/02_Extra/gnuplot
url = https://github.com/hesstobi/sublime_gnuplot

View File

@ -12,23 +12,26 @@
- 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)
- If plain mode is set and wrap is not explicitly opted in, long lines will no be truncated, see #1426
- If `PAGER` (but not `BAT_PAGER` or `--pager`) is `more` or `most`, silently use `less` instead to ensure support for colors, see #1063 (@Enselic)
## Other
- Performance improvements, see #1421 (@LovecraftianHorror)
- Added a new `--diagnostic` option to collect information for bug reports, see #1459 (@sharkdp)
- Upped min required Rust version to 1.42
## Syntaxes
- Added Zig syntax, see #1470 (@paulsmith)
- Added Lean syntax, see #1446 (@Julian)
- Added `.resource` extension for Robot Framework files, see #1386
- Added `gnuplot` syntax, see #1431 (@sharkdp)
## 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.
- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12). **Breaking change:** users that were previously using one of the `ansi-*` themes should switch to `ansi`.
- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously using `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead.
## `bat` as a library

28
Cargo.lock generated
View File

@ -186,9 +186,9 @@ dependencies = [
[[package]]
name = "byteorder"
version = "1.3.4"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
[[package]]
name = "cc"
@ -589,9 +589,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.81"
version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929"
[[package]]
name = "libgit2-sys"
@ -628,9 +628,9 @@ dependencies = [
[[package]]
name = "linked-hash-map"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "lock_api"
@ -903,9 +903,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.4.2"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
"aho-corasick",
"memchr",
@ -915,9 +915,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.21"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]]
name = "remove_dir_all"
@ -1058,9 +1058,9 @@ checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
[[package]]
name = "smallvec"
version = "1.6.0"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "snailquote"
@ -1190,9 +1190,9 @@ dependencies = [
[[package]]
name = "thread_local"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447"
dependencies = [
"lazy_static",
]

View File

@ -356,7 +356,7 @@ binaries are also available: look for archives with `musl` in the file name.
### From source
If you want to build `bat` from source, you need Rust 1.40 or
If you want to build `bat` from source, you need Rust 1.42 or
higher. You can then use `cargo` to build everything:
```bash
@ -700,6 +700,7 @@ Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
- [sharkdp](https://github.com/sharkdp)
- [eth-p](https://github.com/eth-p)
- [keith-hall](https://github.com/keith-hall)
- [Enselic](https://github.com/Enselic)
## Project goals and alternatives

1
assets/syntaxes/02_Extra/gnuplot vendored Submodule

@ -0,0 +1 @@
Subproject commit 04743470ff90237ba3fb34ccf77c2d256d611262

View File

@ -0,0 +1,182 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: gnuplot
file_extensions:
- gp
- gpl
- gnuplot
- gnu
- plot
- plt
scope: source.gnuplot
contexts:
main:
- include: number
- include: string_single
- include: string_double
- match: '\b(for)\b\s*(\[)'
comment: |
gnuplot iteration statement.
There are two forms:
numeric [n = 1:2{:inc}]
string based [str in "x y z"]
but both can also iterate over lists etc, so this is kept loose.
captures:
1: keyword.other.iteration.gnuplot
2: punctuation.definition.range.begin.gnuplot
push:
- meta_scope: meta.structure.iteration.gnuplot
- match: '\]'
captures:
0: punctuation.definition.range.end.gnuplot
pop: true
- include: number
- include: operator
- include: string_double
- include: string_single
- match: ":"
scope: punctuation.separator.range.gnuplot
- match: '\b([a-zA-Z]\w*)\b\s*(=|in)'
scope: variable-assignment.range.gnuplot
- match: '(?i:[^\s(pi|e)\]])'
scope: invalid.illegal.expected-range-separator.gnuplot
- match: '\['
comment: "gnuplot range statement [a:b]. Lots of things are legal, still more make no sense!"
captures:
0: punctuation.definition.range.begin.gnuplot
push:
- meta_scope: meta.structure.range.gnuplot
- match: '\]'
captures:
0: punctuation.definition.range.end.gnuplot
pop: true
- include: number
- include: operator
- match: ":"
scope: punctuation.separator.range.gnuplot
- match: '(?i:[^\s(pi|e)\]])'
scope: invalid.illegal.expected-range-separator.gnuplot
- match: \\.
scope: constant.character.escape.gnuplot
- match: '(?<!\$)(#)(?!\{).*$\n?'
scope: comment.line.number-sign.gnuplot
captures:
1: punctuation.definition.comment.gnuplot
- match: for
comment: introduce in gnuplot 4.3.
scope: keyword.other.iteration.gnuplot
- match: \b(angles|arrow|autoscale|bars|border|boxwidth|clabel|clip|cntrparam|colorbox|contour|decimalsign|dgrid3d|dummy|encoding|fit|format|grid|hidden3d|historysize|isosamples|key|label|locale|logscale|macros|bmargin|lmargin|rmargin|tmargin|mapping|mouse|multiplot|offsets|origin|output|palette|parametric|pm3d|pointsize|polar|print|rrange|trange|urange|vrange|samples|size|style|surface|tics|ticscale|ticslevel|timestamp|timefmt|title|view|xyplane|x2data|xdata|y2data|ydata|z2data|zdata|x2label|xlabel|y2label|ylabel|z2label|zlabel|x2range|xrange|y2range|yrange|z2range|zrange|mx2tics|mxtics|my2tics|mytics|mz2tics|mztics|nomx2tics|nomxtics|nomy2tics|nomytics|nomz2tics|nomztics|nox2tics|noxtics|noy2tics|noytics|noz2tics|noztics|x2tics|xtics|y2tics|ytics|z2tics|ztics|x2dtics|x2mtics|xdtics|xmtics|y2dtics|y2mtics|ydtics|ymtics|z2dtics|z2mtics|zdtics|zmtics|x2zeroaxis|xzeroaxis|y2zeroaxis|yzeroaxis|z2zeroaxis|zeroaxis|zzeroaxis|zero|)\b
scope: keyword.other.setting.gnuplot
- match: \b(cd|call|clear|exit|plot|splot|help|load|pause|quit|fit|replot|if|FIT_LIMIT|FIT_MAXITER|FIT_START_LAMBDA|FIT_LAMBDA_FACTOR|FIT_LOG|FIT_SCRIPT|print|pwd|reread|reset|save|show|test|!|functions|var)\b
comment: missuse of scopes alert! Just for pretty colours
scope: keyword.other.command.gnuplot
- match: \b(abs|acos|acosh|arg|asin|asinh|atan|atan2|atanh|besj0|besj1|besy0|besy1|ceil|cos|cosh|erf|erfc|exp|floor|gamma|ibeta|igamma|imag|int|inverf|invnorm|lambertw|lgamma|log|log10|norm|rand|real|sgn|sin|sinh|sqrt|tan|tanh)\b
scope: support.function.gnuplot
- match: \b(gprintf|sprintf|strlen|strstrt|substr|system|word|words)\b
scope: support.function.string.gnuplot
- match: \b(on|off|default|inside|outside|lmargin|rmargin|tmargin|bmargin|at|left|right|center|top|bottom|center|vertical|horizontal|Left|Right|noreverse|noinvert|samplen|spacing|width|height|noautotitle|columnheader|title|noenhanced|nobox|linestyle|ls|linetype|lt|linewidth|lw)\b
scope: constant.other.type.gnuplot
- match: \b(aed512|aed767|aifm|aqua|bitgraph|cgm|corel|dumb|dxf|eepic|emf|emtex|epslatex|epson_180dpi|epson_60dpi|epson_lx800|fig|gif|gpic|hp2623A|hp2648|hp500c|hpdj|hpgl|hpljii|hppj|imagen|jpeg|kc_tek40xx|km_tek40xx|latex|mf|mif|mp|nec_cp6|okidata|pbm|pcl5|pdf|png|postscript|pslatex|pstex|pstricks|qms|regis|selanar|starc|svg|tandy_60dpi|tek40xx|tek410x|texdraw|tgif|tkcanvas|tpic|unknown|vttek)\b
scope: constant.other.terminal.gnuplot
- match: \b(u(sing)?|t(it(le)?)?|notit(le)?|w(i(th)?)?|steps|fs(teps)?|notitle|l(i(nes)?)?|linespoints|via)\b
scope: keyword.modifier.gnuplot
- match: |-
(?x:
\b # Start with a word boundary
(?=\b[\w$]*(\(|.*=)) # Look-ahead for a bracket or equals
(?![^(]*\)) # negative look ahead for a closing bracket without an opening one. This stops a from matching in f(a)
( # Group variable name
[A-Za-z] # A letter
[\w$]* # Any word chars or $
) # That is it for the name.
)
comment: user defined function / variable
scope: variable.other.gnuplot
- match: \b(if)\b
scope: keyword.control.gnuplot
- match: \b(show)\b
captures:
0: keyword.other.command.gnuplot
push:
- meta_scope: keyword.line.show.gnuplot
- meta_content_scope: keyword.line.show.gnuplot
- match: (?!\#)($\n?)
pop: true
- include: main
- match: \b(set)\b\s*\b(terminal|term)\b
captures:
1: keyword.other.command.gnuplot
2: keyword.other.setting.gnuplot
push:
- meta_scope: keyword.line.set.terminal.gnuplot
- match: (?!\#)($\n?)
pop: true
- include: main
- match: \b(set)\b\s*\b(key)\b
captures:
1: keyword.other.command.gnuplot
2: keyword.other.setting.gnuplot
push:
- meta_scope: keyword.line.set.key.gnuplot
- match: (?!\#)($\n?)
pop: true
- include: main
- match: \b(set|unset)\b\s*(?!\b(terminal|key|for)\b)
captures:
1: keyword.other.command.gnuplot
2: keyword.other.setting.gnuplot
push:
- meta_scope: keyword.line.set.gnuplot
- meta_content_scope: keyword.line.set.gnuplot
- match: (?!\#)($\n?)
pop: true
- include: main
number:
- match: |-
(?x: # turn on extended mode
-? # an optional minus
(?:
0 # a zero
| # ...or...
[1-9] # a 1-9 character
\d* # followed by zero or more digits
)
(?:
\. # a period
\d+ # followed by one or more digits
(?:
[eE] # an e character
[+-]? # followed by an option +/-
\d+ # followed by one or more digits
)? # make exponent optional
)? # make decimal portion optional
)
comment: borrowed from textmate book
scope: constant.numeric.gnuplot
operator:
- match: \s*(==|~=|>|>=|<|<=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s*
comment: Operator symbols
scope: keyword.operator.symbols.matlab
string_double:
- match: '"'
captures:
0: punctuation.definition.string.begin.gnuplot
push:
- meta_scope: string.quoted.double.gnuplot
- match: '"'
captures:
0: punctuation.definition.string.end.gnuplot
pop: true
- match: '\\[\$`"\\\n]'
scope: constant.character.escape.gnuplot
string_single:
- match: "'"
captures:
0: punctuation.definition.string.begin.gnuplot
push:
- meta_scope: string.quoted.single.gnuplot
- match: "'"
captures:
0: punctuation.definition.string.end.gnuplot
pop: true

View File

@ -341,7 +341,7 @@ ansible-galaxy install aeimer.install_bat
### Из исходников
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.40 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.42 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
```bash
cargo install --locked bat

View File

@ -23,7 +23,7 @@ in the `.sublime-syntax` format.
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.
6. Add a syntax test for the new language. See [below](#Syntax-tests) 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`.

View File

@ -150,10 +150,10 @@ impl App {
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
match self.matches.value_of("wrap") {
Some("character") => WrappingMode::Character,
Some("never") => WrappingMode::NoWrapping,
Some("never") => WrappingMode::NoWrapping(true),
Some("auto") | None => {
if style_components.plain() {
WrappingMode::NoWrapping
WrappingMode::NoWrapping(false)
} else {
WrappingMode::Character
}
@ -163,7 +163,7 @@ impl App {
} else {
// We don't have the tty width when piping to another program.
// There's no point in wrapping when this is the case.
WrappingMode::NoWrapping
WrappingMode::NoWrapping(false)
},
colored_output: self.matches.is_present("force-colorization")
|| match self.matches.value_of("color") {

View File

@ -2,7 +2,7 @@ use bat::input::Input;
use std::ffi::OsStr;
pub fn new_file_input<'a>(file: &'a OsStr, name: Option<&'a OsStr>) -> Input<'a> {
named(Input::ordinary_file(file), name.or_else(|| Some(file)))
named(Input::ordinary_file(file), name.or(Some(file)))
}
pub fn new_stdin_input(name: Option<&OsStr>) -> Input {

View File

@ -205,7 +205,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
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()
PROJECT_DIRS.config_dir().join("themes").to_string_lossy()
)?;
} else {
for theme in assets.themes() {
@ -237,10 +237,10 @@ fn run() -> Result<bool> {
.info(EnvironmentVariables::list(&[
"SHELL",
"PAGER",
"BAT_PAGER",
"BAT_CACHE_PATH",
"BAT_CONFIG_PATH",
"BAT_OPTS",
"BAT_PAGER",
"BAT_STYLE",
"BAT_TABS",
"BAT_THEME",
@ -248,6 +248,7 @@ fn run() -> Result<bool> {
"XDG_CACHE_HOME",
"COLORTERM",
"NO_COLOR",
"MANPAGER",
]))
.info(FileContent::new("Config file", config_file()))
.info(CompileTimeInformation::default())

View File

@ -137,11 +137,7 @@ impl<'a> Input<'a> {
}
pub fn is_stdin(&self) -> bool {
if let InputKind::StdIn = self.kind {
true
} else {
false
}
matches!(self.kind, InputKind::StdIn)
}
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {

View File

@ -81,7 +81,7 @@ impl OutputType {
p.arg("--quit-if-one-screen");
}
if wrapping_mode == WrappingMode::NoWrapping {
if wrapping_mode == WrappingMode::NoWrapping(true) {
p.arg("--chop-long-lines");
}
@ -121,11 +121,7 @@ impl OutputType {
#[cfg(feature = "paging")]
pub(crate) fn is_pager(&self) -> bool {
if let OutputType::Pager(_) = self {
true
} else {
false
}
matches!(self, OutputType::Pager(_))
}
#[cfg(not(feature = "paging"))]

View File

@ -320,6 +320,12 @@ impl<'a> PrettyPrinter<'a> {
}
}
impl Default for PrettyPrinter<'_> {
fn default() -> Self {
Self::new()
}
}
/// An input source for the pretty printer.
pub struct Input<'a> {
input: input::Input<'a>,

View File

@ -424,7 +424,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
// Line contents.
if self.config.wrapping_mode == WrappingMode::NoWrapping {
if matches!(self.config.wrapping_mode, WrappingMode::NoWrapping(_)) {
let true_color = self.config.true_color;
let colored_output = self.config.colored_output;
let italics = self.config.use_italic_text;

View File

@ -1,11 +1,12 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WrappingMode {
Character,
NoWrapping,
// The bool specifies whether wrapping has been explicitly disabled by the user via --wrap=never
NoWrapping(bool),
}
impl Default for WrappingMode {
fn default() -> Self {
WrappingMode::NoWrapping
WrappingMode::NoWrapping(false)
}
}

View File

@ -8,7 +8,7 @@ fn all_themes_are_present() {
let assets = HighlightingAssets::from_binary();
let mut themes: Vec<_> = assets.themes().collect();
themes.sort();
themes.sort_unstable();
assert_eq!(
themes,

View File

@ -7,7 +7,7 @@ macro_rules! snapshot_tests {
$(
#[test]
fn $test_name() {
let bat_tester = BatTester::new();
let bat_tester = BatTester::default();
bat_tester.test_snapshot(stringify!($test_name), $style);
}
)*

View File

@ -0,0 +1,19 @@
set terminal pngcairo enhanced
set output "/tmp/polynomial.png"
set grid
set xrange [-5:5]
set yrange [-5:10]
set samples 10000
set key bottom right
f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
plot \
 f(x) title "polynomial of degree 4" \
 with lines \
 linewidth 2 \
 linetype rgb '#0077ff'

View File

@ -0,0 +1,19 @@
set terminal pngcairo enhanced
set output "/tmp/polynomial.png"
set grid
set xrange [-5:5]
set yrange [-5:10]
set samples 10000
set key bottom right
f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
plot \
f(x) title "polynomial of degree 4" \
with lines \
linewidth 2 \
linetype rgb '#0077ff'

View File

@ -19,23 +19,6 @@ pub struct BatTester {
}
impl BatTester {
pub fn new() -> Self {
let temp_dir = create_sample_directory().expect("sample directory");
let root = env::current_exe()
.expect("tests executable")
.parent()
.expect("tests executable directory")
.parent()
.expect("bat executable directory")
.to_path_buf();
let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
let exe = root.join(exe_name);
BatTester { temp_dir, exe }
}
pub fn test_snapshot(&self, name: &str, style: &str) {
let output = Command::new(&self.exe)
.current_dir(self.temp_dir.path())
@ -66,6 +49,25 @@ impl BatTester {
}
}
impl Default for BatTester {
fn default() -> Self {
let temp_dir = create_sample_directory().expect("sample directory");
let root = env::current_exe()
.expect("tests executable")
.parent()
.expect("tests executable directory")
.parent()
.expect("bat executable directory")
.to_path_buf();
let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
let exe = root.join(exe_name);
BatTester { temp_dir, exe }
}
}
fn create_sample_directory() -> Result<TempDir, git2::Error> {
// Create temp directory and initialize repository
let temp_dir = TempDir::new("bat-tests").expect("Temp directory");