[PATCH] add mouse scrolling arrowpress emulation when in altscreen

Bug #1199350 reported by hhm
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pangoterm
Fix Committed
Undecided
Unassigned

Bug Description

Adds an option to emulate arrow presses when the scrolling in altscreen. I originally saw such a feature in <https://developer.gnome.org/vte/>.

I hope I coded this correctly! If I did not, feel free to change it to how you see fit.

The patch is inline and attached.

diff --git a/pangoterm.c b/pangoterm.c
index e403896..82564d3 100644
--- a/pangoterm.c
+++ b/pangoterm.c
@@ -19,6 +19,8 @@ CONF_INT(cursor_blink_interval, 0, 500, "Cursor blink interval", "MSEC");
 CONF_BOOL(bold_highbright, 0, TRUE, "Bold is high-brightness");
 CONF_BOOL(altscreen, 0, TRUE, "Alternate screen buffer switching");

+CONF_BOOL(altscreen_scroll, 0, FALSE, "Emulate arrows for mouse scrolling when in alternate screen buffer");
+
 CONF_INT(scrollback_size, 0, 1000, "Scrollback size", "LINES");

 CONF_INT(scrollbar_width, 0, 3, "Scroll bar width", "PIXELS");
@@ -1152,8 +1154,21 @@ static VTermScreenCallbacks cb = {

 static void scroll_delta(PangoTerm *pt, int delta)
 {
- if(pt->on_altscreen)
+ if(pt->on_altscreen) {
+ if (CONF_altscreen_scroll) {
+ VTermKey which_arrow;
+ if(delta > 0) {
+ which_arrow = VTERM_KEY_UP;
+ } else if(delta < 0) {
+ which_arrow = VTERM_KEY_DOWN;
+ }
+ for(int i=0; i < ((which_arrow == VTERM_KEY_DOWN) ? -delta : delta); i++) {
+ vterm_input_push_key(pt->vt, VTERM_MOD_NONE, which_arrow);
+ }
+ term_flush_output(pt);
+ }
     return;
+ }

   if(delta > 0) {
     if(pt->scroll_offs + delta > pt->scroll_current)
diff --git a/pangoterm.cfg b/pangoterm.cfg
index 79ff996..2c95249 100644
--- a/pangoterm.cfg
+++ b/pangoterm.cfg
@@ -20,6 +20,7 @@
 # cursor_blink_interval = 500 (in msec)
 # bold_highbright = true
 # altscreen = true
+# altscreen_scroll = false
 # term = "xterm"
 # scrollback_size = 1000
 # scrollbar_width = 3

Revision history for this message
hhm (hhm) wrote :
Revision history for this message
hhm (hhm) wrote :

New version. A bit of cleaning. Horizontal scrolling in altscreen.

Revision history for this message
James McCoy (jamessan) wrote :

This is essentially the same thing as xterm's alternateScroll resource added in patch 282.

Changed in pangoterm:
status: New → Triaged
Revision history for this message
Paul "LeoNerd" Evans (leonerd) wrote :

Patch applied as -r566

Changed in pangoterm:
status: Triaged → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.