on master help sign in
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

commitc386cb35fb5f5fd2d2d3dedcb841812982728c2d authorsharkdp <davidpeter@web.de> dateTue 21 Apr 2020, 08:56 (7 years ago) parent97ea3dd
2 files changed+15−1
CHANGELOG.md+2 src/output.rs+13−1
CHANGELOG.md+2
@@ -6,6 +6,8 @@
66 in the header. This is useful when piping input into `bat`. See #654 and #892 (@neuronull).
77- Added a new `--generate-config-file` option to creat an initial configuration file
88 at the right place. See #870 (@jmick414)
9+- When using `less` version 551 or newer, `bat` will now pass the `--mouse` argument, allowing
10+ for (better) mouse scrolling support in some terminals, see #904
911
1012## Bugfixes
1113
src/output.rs+13−1
@@ -82,11 +82,13 @@ impl OutputType {
8282 p.arg("--quit-if-one-screen");
8383 }
8484
85+ let less_version = retrieve_less_version();
86+
8587 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
8688 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
8789 //
8890 // See: http://www.greenwoodsoftware.com/less/news.530.html
89− match retrieve_less_version() {
91+ match less_version {
9092 None => {
9193 p.arg("--no-init");
9294 }
@@ -95,6 +97,16 @@ impl OutputType {
9597 }
9698 _ => {}
9799 }
100+
101+ // Passing '--mouse' allows mouse scrolling in terminals which do not
102+ // support "fake scrolling", see https://github.com/sharkdp/bat/issues/904
103+ // The '--mouse' argument is only supported in less 551 or higher.
104+ match less_version {
105+ Some(version) if version >= 551 => {
106+ p.arg("--mouse");
107+ }
108+ _ => {}
109+ }
98110 } else {
99111 p.args(args);
100112 }