> I am still not convinced by this, I don't need more tests, I need good
> reasons why we should do this - what is it useful for apart from
> scrolling in less? Why shouldn't this be done in less itself? It can't
> be that hard to make less support the mouse.
Because it gives all CLI programs (even bash history) "intuitive" mouse
support without updating/fixing every single one of them. There are
numerous CLI tools that do take mouse input, but mess it up somehow,
f.e. aptitude can not deal with it properly and in ncmpcpp, only
scrolling up (!) works. Less has had an open enhancement request (#272
[0]) for it since 2007, and someone has posted a patch [1] for less but
it never got integrated, I sent the less maintainer a mail about it
yesterday with no answer as of yet.

Yes, these programs can and should all be fixed. But integrating the
proposed code in tmux helps work around the issue straight away, as vte
[attached] and KDE's konsole [2] did upstream, and was posted for urxvt
[3] as well.
It just makes tmux usage more comfortable for a very common use case.

#Regards


[0]
http://wayback.archive.org/web/20070519231912/http://www.greenwoodsoftware.com/less/bugs.html
[1]
http://www.linuxquestions.org/questions/linux-software-2/less-command-output-i-cannot-scroll-through-it-627821/page2.html#post3094148
[2]
http://websvn.kde.org/trunk/KDE/kdebase/apps/konsole/src/TerminalDisplay.cpp?r1=786780&r2=786779&pathrev=786780
[3]
http://mywaytoarch.tumblr.com/post/14455320734/scrolling-mouse-wheel-improvments-vte-like-in-urxvt
>From ca778f57c983bf7994563c9b0df1d28f3af024e2 Mon Sep 17 00:00:00 2001
From: Chris Wilson <ch...@chris-wilson.co.uk>
Date: Wed, 4 Apr 2007 10:53:19 +0000
Subject: [PATCH] =?UTF-8?q?Bug=20424184=20=E2=80=93=20Make=20scroll=20whee?=
 =?UTF-8?q?l=20send=20Page=20Up/Down=20when=20it=20makes=20sense?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

2007-04-04  Chris Wilson  <ch...@chris-wilson.co.uk>

    Bug 424184 – Make scroll wheel send Page Up/Down when it makes sense

    Original patch by Shaun McCance and refined by Baris Cicek.

    * src/vte.c (vte_terminal_scroll):
        Send cursor keypress instead of trying to scroll the
        alternate screen in vain.


svn path=/trunk/; revision=1864
---
 ChangeLog | 10 ++++++++++
 src/vte.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ef46cdd..affeff3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-04-04  Chris Wilson  <ch...@chris-wilson.co.uk>
+
+	Bug 424184 – Make scroll wheel send Page Up/Down when it makes sense
+
+	Original patch by Shaun McCance and refined by Baris Cicek.
+
+	* src/vte.c (vte_terminal_scroll):
+	    Send cursor keypress instead of trying to scroll the
+	    alternate screen in vain.
+
 2007-04-03  Chris Wilson  <ch...@chris-wilson.co.uk>
 
 	Bug 425767 – vte_terminal_set_color_highlight should test for
diff --git a/src/vte.c b/src/vte.c
index 69c69ae..d369f47 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -10202,7 +10202,6 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
 		return TRUE;
 	}
 
-	/* Perform a history scroll. */
 	adj = terminal->adjustment;
 	v = MAX (1., ceil (adj->page_increment / 10.));
 	switch (event->direction) {
@@ -10214,10 +10213,45 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
 	default:
 		return FALSE;
 	}
-	v += terminal->pvt->screen->scroll_delta;
-	new_value = floor (CLAMP (v, adj->lower,
-				MAX (adj->lower, adj->upper - adj->page_size)));
-	vte_terminal_queue_adjustment_value_changed (terminal, new_value);
+
+	if (terminal->pvt->screen == &terminal->pvt->alternate_screen) {
+		char *normal;
+		gssize normal_length;
+		const gchar *special;
+		gint i, cnt = v;
+
+		/* In the alternate screen there is no scrolling,
+		 * so fake a few cursor keystrokes. */
+
+		_vte_keymap_map (
+				cnt > 0 ? GDK_Down : GDK_Up,
+				terminal->pvt->modifiers,
+				terminal->pvt->sun_fkey_mode,
+				terminal->pvt->hp_fkey_mode,
+				terminal->pvt->legacy_fkey_mode,
+				terminal->pvt->vt220_fkey_mode,
+				terminal->pvt->cursor_mode == VTE_KEYMODE_APPLICATION,
+				terminal->pvt->keypad_mode == VTE_KEYMODE_APPLICATION,
+				terminal->pvt->termcap,
+				terminal->pvt->emulation ?
+				terminal->pvt->emulation : vte_terminal_get_default_emulation(terminal),
+				&normal,
+				&normal_length,
+				&special);
+		if (cnt < 0)
+			cnt = -cnt;
+		for (i = 0; i < cnt; i++) {
+			vte_terminal_feed_child_using_modes (terminal,
+					normal, normal_length);
+		}
+		g_free (normal);
+	} else {
+		/* Perform a history scroll. */
+		v += terminal->pvt->screen->scroll_delta;
+		new_value = floor (CLAMP (v, adj->lower,
+					MAX (adj->lower, adj->upper - adj->page_size)));
+		vte_terminal_queue_adjustment_value_changed (terminal, new_value);
+	}
 
 	return TRUE;
 }
-- 
2.0.0.rc0

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to