irssi mouse patches

Tiago Sousa (aka mirage)
Last updated on 08/10/2007

Introduction

These are a couple of patches that bring some mouse funcionality to irssi when running in a xterm-compatible terminal, including screen and putty! It does NOT work in the console with gpm; however, this shouldn't be too hard to implement for someone with the time and will to do it. The first patch, irssi_mouse_xterm.patch, is the core patch that enables mouse clicks, simple mouse gestures and window scrolling with the mouse wheel. It does this by activating xterm mouse tracking, handling mouse events and adding irssi settings and signals to control them. The second patch, irssi_mouse_xterm_act.patch, is an experimental proof-of-concept handling of mouse clicks to change windows when an act item in the statusbar is clicked. This feature works only with the default statusbar act item setting.

Installation

Download the latest versions: irssi_mouse_xterm-0.7.patch and irssi_mouse_xterm_act-0.2.patch (older ones here). The patch was made with irssi-0.8.11 but also works with previous versions, and probably will work with future ones with minor modifications.

tar xvfj irssi-0.8.9.tar.bz2
cd irssi-0.8.9
patch -p1 < /path/to/irssi_mouse_xterm-version.patch

If you also want the experimental statusbar act item support:

patch -p1 < /path/to/irssi_mouse_xterm_act-version.patch

Now compile and install irssi as usual.

Internals

The core patch is responsible for starting/stopping the xterm mouse tracking. This is done depending on the boolean setting term_mouse_xterm, and on the TERM environment variable, which must be one of the following: xterm, xterm-color, screen, rxvt.

There are 6 simple mouse gestures being recognized, with actions configurable by settings. They are:

Gesture Setting Default action
Up mouse_gesture_up /window last
Down mouse_gesture_down /window goto active
Left mouse_gesture_left /window prev
Big left (distance >40) mouse_gesture_bigleft /eval window prev;window prev
Right
mouse_gesture_right /window next
Big right (distance >40) mouse_gesture_bigright /eval window prev;window prev

The following mouse events generate signals that can be scripted:

Signal Default handler
mouse event /* Handle mouse event (button press or release) */
static void sig_mouse_event(int b, int x, int y, int oldb, int oldx, int oldy)
mouse click /* Mouse click (press and release in the same position) */
static void sig_mouse_click(int b, int x, int y)
mouse gesture up static void sig_mouse_gesture_up(void)
mouse gesture down static void sig_mouse_gesture_down(void)
mouse gesture left static void sig_mouse_gesture_left(void)
mouse gesture bigleft static void sig_mouse_gesture_bigleft(void)
mouse gesture right static void sig_mouse_gesture_right(void)
mouse gesture bigright static void sig_mouse_gesture_bigright(void)

FAQ

Q: I can't select/copy/paste text!
A: Hold shift to bypass the xterm mouse tracking.

Q: I already patched, compiled and installed irssi, but the mouse isn't working!
A: On the terminal do an echo $TERM and make sure it's one of the TERM types listed above (xterm, screen, rxvt, etc). Also, there's a setting that must be enabled, try /set term_mouse_xterm on.

Q: Scroll doesn't work!
A: This problem appeared at least in gnome-terminal-2.18 and is fixed in irssi mouse patch 0.7.