diff options
author | sharkdp <davidpeter@web.de> | 2020-04-21 08:56:26 +0200 |
---|---|---|
committer | sharkdp <davidpeter@web.de> | 2020-04-21 08:56:26 +0200 |
commit | cb21b74ecd5fe971d356677932bcbf892b1dc088 (patch) | |
tree | da3dfae2e8647d4f47d3ade262c4ccd61fea2181 | |
parent | 96aedf624031901c34763fa44513628e23ded6ca (diff) |
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
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/output.rs | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b7ca55..71d6aa12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ in the header. This is useful when piping input into `bat`. See #654 (@neuronull). - Added a new `--generate-config-file` option to creat an initial configuration file at the right place. See #870 (@jmick414) +- When using `less` version 551 or newer, `bat` will now pass the `--mouse` argument, allowing + for (better) mouse scrolling support in some terminals, see #904 ## Bugfixes diff --git a/src/output.rs b/src/output.rs index 15f29e43..c8c44fbb 100644 --- a/src/output.rs +++ b/src/output.rs @@ -82,11 +82,13 @@ impl OutputType { p.arg("--quit-if-one-screen"); } + let less_version = retrieve_less_version(); + // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older // versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // // See: http://www.greenwoodsoftware.com/less/news.530.html - match retrieve_less_version() { + match less_version { None => { p.arg("--no-init"); } @@ -95,6 +97,16 @@ impl OutputType { } _ => {} } + + // Passing '--mouse' allows mouse scrolling in terminals which do not + // support "fake scrolling", see https://github.com/sharkdp/bat/issues/904 + // The '--mouse' argument is only supported in less 551 or higher. + match less_version { + Some(version) if version >= 551 => { + p.arg("--mouse"); + } + _ => {} + } } else { p.args(args); } |