Merge remote-tracking branch 'upstream/master' into feature-tabs

# Conflicts:
#	src/printer.rs
This commit is contained in:
eth-p 2018-09-11 14:03:47 -07:00
commit 1807f9653c
No known key found for this signature in database
GPG Key ID: 1F8DF8091CD46FBC
6 changed files with 65 additions and 9 deletions

View File

@ -23,7 +23,13 @@ matrix:
- TARGET=arm-unknown-linux-gnueabihf
- CC_arm_unknown_linux_gnueabihf=/usr/bin/arm-linux-gnueabihf-gcc-4.8
- CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8
- os: linux
rust: stable
env:
- TARGET=aarch64-unknown-linux-gnu
- CC_aarch64-unknown-linux-gnu=/usr/bin/aarch64-linux-gnu-gcc-4.8
- CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc-4.8
# Minimum Rust supported channel.
- os: linux
rust: 1.26.0

View File

@ -134,6 +134,8 @@ or install it with [scoop](https://scoop.sh/):
scoop install bat
```
[See below](#using-bat-on-windows) for notes.
### From binaries
Check out the [Release page](https://github.com/sharkdp/bat/releases) for
@ -235,6 +237,28 @@ script as a wrapper, for example:
less --tabs 4 -RF "$@"
```
## Using `bat` on Windows
`bat` mostly works out-of-the-box on Windows, but a few features may need extra configuration.
### Paging
Windows only includes a very limited pager in the form of `more`. You can download a Windows binary
for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through
Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in
your `PATH` or [define an environment variable](#using-a-different-pager).
### Colours
Windows 10 natively supports colours in both `conhost.exe` (Command Prompt) and PowerShell since
[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as
well as in newer versions of bash. On earlier versions of Windows, you can use
[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/).
**Note:** The Git and MSYS versions of `less` do not correctly interpret colours on Windows. If you
dont have any other pagers installed, you can disable paging entirely by passing `--paging=never`
or by setting `BAT_PAGER` to an empty string.
## Troubleshooting
### Terminals & colors

View File

@ -19,6 +19,8 @@ pack() {
if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
gcc_prefix="arm-linux-gnueabihf-"
elif [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then
gcc_prefix="aarch64-linux-gnu-"
else
gcc_prefix=""
fi
@ -49,13 +51,24 @@ make_deb() {
local version
local dpkgname
local conflictname
local gcc_prefix
case $TARGET in
x86_64*)
architecture=amd64
gcc_prefix=""
;;
i686*)
architecture=i386
gcc_prefix=""
;;
aarch64*)
architecture=arm64
gcc_prefix="aarch64-linux-gnu-"
;;
arm*hf)
architecture=armhf
gcc_prefix="arm-linux-gnueabihf-"
;;
*)
echo "make_deb: skipping target '${TARGET}'" >&2
@ -75,7 +88,7 @@ make_deb() {
# copy the main binary
install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
strip "$tempdir/usr/bin/$PROJECT_NAME"
"${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME"
# manpage
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"

View File

@ -27,3 +27,11 @@ if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then
libc6-armhf-cross \
libc6-dev-armhf-cross
fi
# needed for cross-compiling for arm64
if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
sudo apt-get install -y \
gcc-4.8-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu
fi

View File

@ -6,7 +6,7 @@ set -ex
cargo build --target "$TARGET" --verbose
# We cannot run arm executables on linux
if [[ $TARGET != arm-unknown-linux-gnueabihf ]]; then
if [[ $TARGET != arm-unknown-linux-gnueabihf ]] && [[ $TARGET != aarch64-unknown-linux-gnu ]]; then
cargo test --target "$TARGET" --verbose
# Run 'bat' on its own source code and the README

View File

@ -114,9 +114,13 @@ impl<'a> InteractivePrinter<'a> {
}
// Get the Git modifications
let line_changes = match file {
InputFile::Ordinary(filename) => get_git_diff(filename),
_ => None,
let line_changes = if config.output_components.changes() {
match file {
InputFile::Ordinary(filename) => get_git_diff(filename),
_ => None,
}
} else {
None
};
// Determine the type of syntax for highlighting
@ -210,11 +214,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
line_buffer: &[u8],
) -> Result<()> {
let line = String::from_utf8_lossy(&line_buffer).to_string();
// Highlight.
let regions = self.highlighter.highlight(line.as_ref());
// Print.
if out_of_range {
return Ok(());
}
@ -251,6 +252,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
as_terminal_escaped(style, &*text, true_color, colored_output,)
)?;
}
if line.bytes().next_back() != Some(b'\n') {
write!(handle, "\n")?;
}
} else {
for &(style, region) in regions.iter() {
let mut ansi_iterator = AnsiCodeIterator::new(region);