diff options
author | Rastislav Barlik | 2017-07-16 13:11:48 +0100 |
---|---|---|
committer | Rastislav Barlik | 2017-07-16 13:13:13 +0100 |
commit | 7335706ed61553955da8ad5d0ff353e3463dcf28 (patch) | |
tree | 15ba48b29093d99723a12230113f2981622ee620 | |
download | aur-7335706ed61553955da8ad5d0ff353e3463dcf28.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 13 | ||||
-rw-r--r-- | PKGBUILD | 15 | ||||
-rw-r--r-- | vtwheel | 50 |
3 files changed, 78 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..4850b6cc067f --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,13 @@ +pkgbase = urxvt-vtwheel-vte + pkgdesc = VTE-like scroll wheel support for urxvt + pkgver = 1.0 + pkgrel = 1 + url = http://aur.archlinux.org/ + arch = any + license = unknown + depends = rxvt-unicode-cvs + source = vtwheel + md5sums = 6c4802c76fb22f92285f875fdb0d7bad + +pkgname = urxvt-vtwheel-vte + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..4420a4b2c80a --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,15 @@ +# Maintainer: Rastislav Barlik <barlik-arch at gmx dot com> +pkgname=urxvt-vtwheel-vte +pkgver=1.0 +pkgrel=1 +pkgdesc="VTE-like scroll wheel support for urxvt" +arch=('any') +url="http://aur.archlinux.org/" +license=('unknown') +depends=('rxvt-unicode-cvs') +source=('vtwheel') +md5sums=('6c4802c76fb22f92285f875fdb0d7bad') + +package() { + install -Dm0664 "$srcdir/vtwheel" "$pkgdir/usr/lib/urxvt/perl/vtwheel" +} diff --git a/vtwheel b/vtwheel new file mode 100644 index 000000000000..2b01589fd75b --- /dev/null +++ b/vtwheel @@ -0,0 +1,50 @@ +#! perl + +=head1 NAME + +vtwheel - emulate scroll wheel for secondary screen + +=head1 DESCRIPTION + +Emulate scroll wheel on secondary screen by simulating key presses. + +With the latest rxvt-unicode, it mirrors the scrolling behavior of VTE-based +terminals by not overriding the scroll wheel while in applications supporting +mouse-reporting (e.g. in vim). + +=cut + +my $scroll_lines = 3; +my $key_scroll_up = 111; +my $key_scroll_down = 116; + +sub simulate_keypress { + my ($self, $keycode) = @_; + + for (my $i = 0; $i < $scroll_lines; $i++) { + $self->key_press(0, $keycode); + $self->key_release(0, $keycode); + } +} + +sub on_button_release { + my ($self, $event) = @_; + + # Don't change scrolling on primary screen + !$self->current_screen and return (); + + # Don't change scrolling when mouse report is on (e.g. inside vim) + eval { + $self->priv_modes & urxvt::PrivMode_mouse_report + } && return (); + + if ($event->{button} eq "4") { + $self->simulate_keypress($key_scroll_up); + return 1; + } elsif ($event->{button} eq "5") { + $self->simulate_keypress($key_scroll_down); + return 1; + } + + return (); +} |