Commit Graph

49 Commits

Author SHA1 Message Date
sharkdp b3903175c8 Auto-format Rust code 2020-10-11 21:57:12 +02:00
gahag 6615eceb18 Code review: replace `if let` with equals operator 2020-10-08 18:51:42 +02:00
gahag 53f5a37f01 Code review
- Replace bools with enums
- Replace short flag with long flag
2020-10-08 18:51:42 +02:00
gahag bbef2f41ec Add `-S` flag to less when `--wrap=never` (closes #1255)
Prevent less from wrapping lines by setting the proper flag when `--wrap=never`.
If the user set a custom value for `--pager`, no additional flag is set.
2020-10-08 18:51:42 +02:00
Roy Ivy III 99226b745f Revert 9ed8db22c ('windows' pager process execution fix) based on PR feedback/owner request 2020-06-03 09:13:47 +02:00
Roy Ivy III a2c09b41bc Fix pager process execution under 'windows'
## [why]

For 'windows' platforms, directly spawning a process (eg, called PATHNAME) bypasses the
usual windows shell machinery for determining which process to execute. Specifically,
the extensions in PATHEXT will not be used to determine the final executable. So,
`PATHNAME.bat`, `PATHNAME.cmd`, ... will *not* be executed even if on they exist on the
PATH; and this is counter to the usual expectation of a Windows user. Additionally,
built-in commands, such as `echo` and `dir`, will never be accessible as they do not
have a PATH to execute and, so, will never be found.

To use the usual machinery, giving access to PATHNAME.bat and `echo`, execute the PATHNAME
using the windows shell, eg `cmd /d/c PATHNAME`. Note this may expose the constructed
command line to the windows shell quoting vagaries (sadly, that may be part of the price).

Following Windows standards, the ComSpec environment variable is used to determine which
shell to use, with a fallback to the "modern", built-in `cmd` shell.
2020-06-03 09:13:47 +02:00
sharkdp 48a7ce3bf2 Write error messages to pager, if attached
closes #946
2020-04-25 13:08:00 +02:00
sharkdp 8961f7aef8 Move PagingMode to separate module 2020-04-22 23:55:28 +02:00
sharkdp 702cb198da Rename error module 2020-04-22 23:55:28 +02:00
sharkdp 864656bd11 Pass --no-init on Windows if less version < 559
We used to call `less` with
``` bash
less --RAW-CONTROL-CHARS --quit-if-one-screen --no-init
```
We only passed `--no-init` because there was a bug with previous versions
of `less` which required the use of `--no-init` in combination with
`--quit-if-one-screen` to prevent this "no output" issue from happening.

Since bat 0.13, [we omit the `--no-init` option](0ecc94956b/src/output.rs (L85-L97))
if we can detect that the version of `less` is higher than or equal to 530. We
did that because `--no-init` breaks mouse support and because [less 530 fixed
the above-mentioned bug](http://www.greenwoodsoftware.com/less/news.530.html).
However, it seems that this bug was *not* fixed on Windows!

According to @gwsw, the issue should be fixed with less 559 on Windows.

closes #887
2020-04-21 18:18:03 +02:00
sharkdp ce583eb9bf Revert "Pass '--mouse' to less versions >= 551"
This reverts commit cb21b74ecd.
2020-04-21 17:29:01 +02:00
sharkdp 3a195be14e Revert "Only enable --mouse when running from tmux, see #904"
This reverts commit 5f6e310152.
2020-04-21 17:28:37 +02:00
sharkdp 5f6e310152 Only enable --mouse when running from tmux, see #904 2020-04-21 16:15:02 +02:00
sharkdp c386cb35fb Pass '--mouse' to less versions >= 551
When using `less` version 551 or newer, `bat` will now pass the `--mouse` argument, allowing
for (better) mouse scrolling support in some terminals.

closes #904
2020-04-21 10:00:32 +02:00
David Tolnay 42e3825daf Updates for review of PR 899 2020-03-31 09:27:56 +02:00
David Tolnay 014d754588 Move paging support behind a feature 2020-03-31 09:27:56 +02:00
David Tolnay 570805bc98 Strip dependencies of bat-as-a-library 2020-03-31 09:27:56 +02:00
sharkdp a7338e2ea2 Run cargo fmt 2020-03-21 22:21:23 +01:00
sharkdp 9b8ddb24d1 move Config struct to separate file 2020-03-21 22:21:23 +01:00
sharkdp e400ebd1bd Also pass '--no-init' if version could not be retrieved 2019-12-23 12:45:23 +01:00
sharkdp 67fe804256 Do not pass '--no-init' on newer less versions
With this change, we do not pass the `--no-init` option in newer
versions of less (530 or higher).

This fixes #749
2019-12-23 12:45:23 +01:00
Fahmi Akbar Wildana 2253d07341 Derive fmt::Debug whenever possible 2019-10-20 21:43:51 +02:00
Fahmi Akbar Wildana 0273848f54 Run `cargo fmt` 2019-10-20 21:43:51 +02:00
Fahmi Akbar Wildana e542621125 Move back printer.rs and others into lib
others:
bin/bat/{controller,decorations,output,printer}.rs
2019-10-20 21:43:51 +02:00
Fahmi Akbar Wildana cfd33168af Fix all compile errors in lib.rs 🚚
* Move {controller,output,printer,decorations}.rs into src/bin/

* Add `mod errors` from main.rs
2019-10-20 21:43:51 +02:00
Wild Kat 28266ee441 use explicit dyn with Write to appease compiler 2019-08-02 18:50:55 +02:00
Daniele Esposti 82f14121bd Applied linter fixes 2019-03-09 07:43:41 +01:00
Daniele Esposti a21ae614e6 Migrated to Rust 2018 2019-03-09 07:43:41 +01:00
sharkdp f0771d6532 Do not replace arguments to pager when --pager is used, closes #509 2019-02-18 20:28:44 +01:00
sharkdp 6e8fca5bb2 Replace less command line arguments only for PAGER 2019-02-07 22:37:33 +01:00
Park Juhyung 63c77383ce Ignore flags from PAGER env var if the program is 'less' 2019-02-07 22:37:33 +01:00
sharkdp 7cac07d845 issue #383: Handle cases like `PAGER=/usr/bin/bat` 2018-11-06 19:53:32 +01:00
Rodrigo Orem 148caa1381 Fix code style 2018-11-06 19:35:41 +01:00
Rodrigo Orem ab27cac0cc Remove args when change from bat to less 2018-11-06 19:35:41 +01:00
Rodrigo Orem 01fcbf2183 Better placement of bat detection 2018-11-06 19:35:41 +01:00
Rodrigo Orem 8a0c30b385 Avoid endless bat executions with PAGER="bat"
From issue #383
2018-11-06 19:35:41 +01:00
Park Juhyung 9c782fb692 Fix format error 2018-10-21 22:42:11 +02:00
Park Juhyung 154186a58d Add --pager option 2018-10-21 22:42:11 +02:00
sharkdp e43d97dc15 Small cleanup 2018-10-17 21:12:23 +02:00
sharkdp bb1f5aa841 Add proper handling of empty PAGER variables 2018-10-17 21:08:32 +02:00
sharkdp 2109a7830b Add error handling for parsing errors 2018-10-17 21:08:32 +02:00
sharkdp ec27c78a8a Remove duplicate 'extern crate' 2018-10-17 21:08:32 +02:00
Morten Linderud 67fe833bc8 Add arguments from PAGER/BAT_PAGER
Solves #352

Signed-off-by: Morten Linderud <morten@linderud.pw>
2018-10-17 21:08:32 +02:00
Aankhen 76df41fa97 src/output.rs: Handle `less` in a portable way. 2018-09-07 21:47:31 +02:00
sharkdp 1d9e7ac4c2 Support "(/usr)/bin/less" as PAGER too
closes #271
2018-09-05 21:10:11 +02:00
sharkdp 9316f2a758 Major refactoring and cleanup 2018-08-22 22:29:12 +02:00
sharkdp d179693d1d Use BAT_PAGER and PAGER environment variables, closes #158 2018-08-18 18:48:22 +02:00
Gert Hulselmans 33bbf25468 Fix launching of pager so text is interpreted as UTF-8 by default.
This fixes issue https://github.com/sharkdp/bat/issues/98
2018-05-22 22:41:58 +02:00
Ezinwa Okpoechi 120b33a9db Move output to separate module 2018-05-21 19:24:02 +02:00