diff -urP irssi-0.8.10-rc5/src/fe-text/gui-readline.c irssi-0.8.10-rc5-mouse_xterm/src/fe-text/gui-readline.c
--- irssi-0.8.10-rc5/src/fe-text/gui-readline.c	2004-03-24 17:24:57.000000000 +0000
+++ irssi-0.8.10-rc5-mouse_xterm/src/fe-text/gui-readline.c	2005-03-31 01:47:28.000000000 +0100
@@ -38,6 +38,10 @@
 #include "gui-windows.h"
 #include "utf8.h"
 
+#include "statusbar.h"
+char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight);
+static void key_change_window(const char *data);
+
 #include <signal.h>
 
 typedef void (*ENTRY_REDIRECT_KEY_FUNC) (int key, void *data, SERVER_REC *server, WI_ITEM_REC *item);
@@ -69,6 +73,9 @@
 
 static void sig_input(void);
 
+static int mouse_xterm_status = -1; /* -1:off 0,1,2:filling mouse_xterm_combo */
+static unichar mouse_xterm_combo[3]; /* 0:button 1:x 2:y */
+
 void input_listen_init(int handle)
 {
         GIOChannel *stdin_channel;
@@ -442,6 +449,90 @@
 	return paste_state == 2;
 }
 
+/* Check if the "act" item exists in the statusbar and if the mouse is over
+   it. If it is, then set the current window to the window with the number
+   which has been clicked, if any. */
+static void mouse_check_act(STATUSBAR_REC *bar, int mouse_xpos)
+{
+	GSList *l_item;
+	char *actlist;
+	SBAR_ITEM_REC *item;
+	int i, status, pos;
+
+	for (l_item = bar->items; l_item != NULL; l_item = l_item->next) {
+		item = l_item->data;
+		if (strcmp (item->config->name, "act") != 0 || item->size == 0 || mouse_xpos <= item->xpos || mouse_xpos >= item->xpos+item->size)
+			continue;
+		actlist = get_activity_list(item->bar->parent_window, TRUE, TRUE);
+		if (actlist == NULL)
+			continue;
+		/* Match mouse coordinates with window numbers in actlist.
+		   FIXME: it assumes the default act template "{sb Act: $0-}"
+		   is used. To minimize things, I assume $0- is at the end
+		   anyway, and parse actlist in reverse order. */
+		status = -1;
+		pos = 0;
+		/* Parse from the end to the beginning */
+		for (i = strlen(actlist)-1; i >= 0; i--) {
+			/* Tricky because it may be part of a window number >10 */
+			if (isdigit(actlist[i])) {
+				if (status == -1)
+					status = actlist[i]-'0';
+				else
+					status = status + (actlist[i]-'0')*10;
+				if (item->xpos+item->size-2-pos == mouse_xpos) {
+					/* look-ahead */
+					while (i != 0 && isdigit(actlist[i-1])) {
+						status = status + (actlist[i]-'0')*10;
+						i--;
+					}
+					ltoa(actlist, status);
+					key_change_window(actlist);
+					i = -1;
+					break;
+				}
+				pos++;
+			} else if (actlist[i] == ',') {
+				if (item->xpos-2-pos == mouse_xpos)
+					break;
+				status = -1;
+				pos++;
+			}
+		}
+		g_free_not_null(actlist);
+		break;
+	}
+}
+
+/* Handle mouse click from a xterm tracking sequence */
+static void mouse_xterm_action(void)
+{
+	GSList *l_bar;
+
+	/* match screen coordinates */
+	mouse_xterm_combo[1]--;
+	mouse_xterm_combo[2]--;
+
+	switch (mouse_xterm_combo[0]) {
+	case 0:
+	case 1:
+		for (l_bar = active_mainwin->statusbars; l_bar != NULL; l_bar = l_bar->next) {
+			STATUSBAR_REC *bar = l_bar->data;
+			/* mouse is somewhere over the statusbar */
+			if (bar->real_ypos == mouse_xterm_combo[2])
+				/* but is it over the "act" item? */
+				mouse_check_act (bar, mouse_xterm_combo[1]);
+		}
+		break;
+	case 64:
+		window_prev_page();
+		break;
+	case 65:
+		window_next_page();
+		break;
+	}
+}
+
 static void sig_gui_key_pressed(gpointer keyp)
 {
 	GTimeVal now;
@@ -456,6 +547,16 @@
 		return;
 	}
 
+	if (mouse_xterm_status != -1) {
+		mouse_xterm_combo[mouse_xterm_status] = key-32;
+		mouse_xterm_status++;
+		if (mouse_xterm_status == 3) {
+			mouse_xterm_status = -1;
+			mouse_xterm_action ();
+		}
+		return;
+	}
+
         g_get_current_time(&now);
 	diff = (now.tv_sec - last_keypress.tv_sec) * 1000 +
 		(now.tv_usec - last_keypress.tv_usec)/1000;
@@ -565,6 +666,11 @@
 {
 }
 
+static void key_mouse_xterm(void)
+{
+	mouse_xterm_status = 0;
+}
+
 static void key_backward_history(void)
 {
 	const char *text;
@@ -1034,6 +1140,7 @@
 	key_bind("key", NULL, "meta-[", "meta2", (SIGNAL_FUNC) key_combo);
 	key_bind("key", NULL, "meta-O", "meta2", (SIGNAL_FUNC) key_combo);
 	key_bind("key", NULL, "meta-[O", "meta2", (SIGNAL_FUNC) key_combo);
+	key_bind("key", NULL, "meta-[M", "mouse_xterm", (SIGNAL_FUNC) key_combo);
 
         /* arrow keys */
 	key_bind("key", NULL, "meta2-A", "up", (SIGNAL_FUNC) key_combo);
@@ -1137,6 +1244,7 @@
 
         /* misc */
 	key_bind("stop_irc", "Send SIGSTOP to client", "^Z", NULL, (SIGNAL_FUNC) key_sig_stop);
+	key_bind("mouse_xterm", "Beginning xterm mouse tracking sequence", "mouse_xterm", NULL, (SIGNAL_FUNC) key_mouse_xterm);
 
         key_configure_thaw();
 
@@ -1201,6 +1309,7 @@
 	key_unbind("insert_text", (SIGNAL_FUNC) key_insert_text);
 	key_unbind("change_window", (SIGNAL_FUNC) key_change_window);
 	key_unbind("stop_irc", (SIGNAL_FUNC) key_sig_stop);
+	key_unbind("mouse_xterm", (SIGNAL_FUNC) key_mouse_xterm);
 	keyboard_destroy(keyboard);
         g_array_free(paste_buffer, TRUE);
 
diff -urP irssi-0.8.10-rc5/src/fe-text/irssi.c irssi-0.8.10-rc5-mouse_xterm/src/fe-text/irssi.c
--- irssi-0.8.10-rc5/src/fe-text/irssi.c	2004-07-11 15:40:37.000000000 +0100
+++ irssi-0.8.10-rc5-mouse_xterm/src/fe-text/irssi.c	2005-03-31 01:47:27.000000000 +0100
@@ -158,6 +158,7 @@
 
 static void textui_finish_init(void)
 {
+	char *term;
 	quitting = FALSE;
 
 	if (dummy)
@@ -185,6 +186,10 @@
 
 	module_register("core", "fe-text");
 
+	term = getenv("TERM");
+	if (term != NULL && strcmp (term, "xterm") == 0)
+		printf("\e[?9h"); /* start xterm mouse tracking */
+
 #ifdef HAVE_STATIC_PERL
 	perl_core_init();
 	fe_perl_init();
@@ -203,8 +208,13 @@
 
 static void textui_deinit(void)
 {
+	char *term;
 	signal(SIGINT, SIG_DFL);
 
+	term = getenv("TERM");
+	if (term != NULL && strcmp (term, "xterm") == 0)
+		printf("\e[?9l"); /* stop xterm mouse tracking */
+
         term_refresh_freeze();
 	while (modules != NULL)
 		module_unload(modules->data);
diff -urP irssi-0.8.10-rc5/src/fe-text/statusbar-items.c irssi-0.8.10-rc5-mouse_xterm/src/fe-text/statusbar-items.c
--- irssi-0.8.10-rc5/src/fe-text/statusbar-items.c	2002-12-31 12:36:36.000000000 +0000
+++ irssi-0.8.10-rc5-mouse_xterm/src/fe-text/statusbar-items.c	2005-03-31 02:08:08.000000000 +0100
@@ -68,7 +68,7 @@
 	}
 }
 
-static char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight)
+char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight)
 {
         THEME_REC *theme;
 	GString *str;
