on master help sign in
Pass '--mouse' to less versions >= 551
c386cb3sharkdp
CHANGELOG.md+2
@@ -6,6 +6,8 @@
6 in the header. This is useful when piping input into `bat`. See #654 and #892 (@neuronull).
6 in the header. This is useful when piping input into `bat`. See #654 and #892 (@neuronull).
7- Added a new `--generate-config-file` option to creat an initial configuration file
7- Added a new `--generate-config-file` option to creat an initial configuration file
8 at the right place. See #870 (@jmick414)
8 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
9
11
10## Bugfixes
12## Bugfixes
11
13
src/output.rs+13−1
@@ -82,11 +82,13 @@ impl OutputType {
82 p.arg("--quit-if-one-screen");
82 p.arg("--quit-if-one-screen");
83 }
83 }
84
84
85+ let less_version = retrieve_less_version();
86+
85 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
87 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
86 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
88 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
87 //
89 //
88 // See: http://www.greenwoodsoftware.com/less/news.530.html
90 // See: http://www.greenwoodsoftware.com/less/news.530.html
89− match retrieve_less_version() {
91+ match less_version {
90 None => {
92 None => {
91 p.arg("--no-init");
93 p.arg("--no-init");
92 }
94 }
@@ -95,6 +97,16 @@ impl OutputType {
95 }
97 }
96 _ => {}
98 _ => {}
97 }
99 }
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+ }
98 } else {
110 } else {
99 p.args(args);
111 p.args(args);
100 }
112 }