bugGNU Screen - Bugs: bug #37206, Support for newer terminal mouse...

 
 

bug #37206: Support for newer terminal mouse modes

Submitter:  Ryan <scovich>
Submitted:  Mon 27 Aug 2012 03:46:33 PM UTC
   
 
Category:  Feature Request Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Confirmed
Privacy:  Public Assigned to:  amade
Open/Closed:  Open Release:  4.0.3
Fixed Release:  None Planned Release:  4.7.0
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 18 Jan 2018 12:01:31 AM UTC, comment #8: 

Thanks for updated patch, I did some testing and it works great!

Some minor code nitpicks though:

(...)
+/* maximum mouse sequence length is SGR: ESC [ < b ; x ; y M */
+enum { MAX_MOUSE_SEQUENCE = 3+10+1+10+1+10+1 };
+
(...)
I think that this one should just be a #define

(...)
+       /* verify the mouse code (0 and 1005 are always valid) */
(...)
Um... 1005? And where it does this verification, I only see code translating coordinates after that. Looking at older patches seems like leftover comment from previous versions of this patch.

But yeah, I guess I can just fix those when applying. ;)

Amadeusz Sławiński <amade>
Group administrator
Fri 12 Jan 2018 03:56:54 AM UTC, comment #7: 

I've attached a new patch that applies cleanly to screen-4.6.2.

Changes:

  • Removed support for modes 1005 and 1015
  • Fixed the broken 1000 mode and the off-by-one error in 1006 mode (both turned out to be the same bug).
  • Correctly handle mouse sequences split across multiple I/O (the old patch was imperfect)
  • Correctly handle the case where the app requested mode 1006 from a terminal that only supports mode 1000.
  • Correctly handle window focus events in mode 1006
  • Clean up misc code irregularities (comment styles, etc.)


The patch does not attempt to translate mode 1000 sequences to mode 1006. Any app that requests the latter must also be able to handle the former as a fallback, so screen is not doing any favors by attempting to translate.

(file #42891)

Ryan <scovich>
Sat 25 Nov 2017 11:24:32 PM UTC, comment #6: 

I have tried screen-4.3.1 with the correspondingly named patch.

I can confirm that clicks on the bottom line of Midnight Commander (in gnome-terminal + screen) don't work. You don't need mc for that, just manually enable mouse support with the SGR extension:

  echo -ne '\e[?1000h\e[?1006h'

then start a "cat" and click around. Whenever you click in the bottom line or in the rightmost column, only `^[[` appears twice (once for the click and once for the release) which is obviously broken. Sounds like an off-by-one at boundary checking. Also notice the delay which doesn't occur when you click elsewhere, sounds like it's waiting for some data to arrive and gives up on a timeout maybe.

This isn't the only place where such a bug occurs. Start over, this time enable mouse only (1000h) without any extension. Then start cat. As you click around, often only `^[[` appears. Usually there seems to be a rectangle from the upper left corner (let's say the first 24 rows and 120 columns) where clicking works as expected, but further to the right or down they don't. The exact boundaries vary heavily. This is a regression introduced by this patch.

---

As for which protocols to support, I agree with Amadeusz from comment #2 that SGR would be enough. See https://midnight-commander.org/ticket/2662#comment:1 for a detailed example how the old xterm 1005 extension (aka utf8-x10) is backwards incompatible and hence utterly broken. As for the urxvt 1015 extension, as far as I know urxvt is the only piece of software that supports this but not the xterm SGR 1006 one. It would take only a few lines of code to add support there, but the author refused that due to personal reasons (he seemed to be offended that his version wasn't good enough for others). There are plenty of software out there that support SGR 1006 but not urxvt 1015. I wouldn't mind screen putting a bit of additional pressure on urxvt to catch up finally.

Note that the two linked mc bugreports (2662 and 2956) are 5-6 years old, but nothing changed since there in the overall big picture (not just mc in particular).

---

I have not studied and won't study the code and the patch to see how it works, although seeing the bugs I'm not sure I can be confident that screen takes the right approach here. Just to be on the safe side, here's how it should work:

Screen can have split panes, a pane which extends beyond row/column 223 of the host terminal emulator, yet is smaller than 223 rows/cols. The app running there might not have extended mouse support. Yet it's expected that mouse works there.

I'm not sure if screen allows to drag the separator between panes, but if it does (or ever plans to), it should work at all coordinates.

A screen can be detached and reattached from another host terminal emulator supporting another set of extensions, and mouse still needs to work.

In order to implement these, the extension used towards the host terminal emulator should be separated from the extension used within a pane.

Towards the host terminal emulator, whenever screen is interested in mouse at all, it should always unconditionally enable the extension(s in increasing order of preference). Assuming the utterly broken 1005 won't be supported, it should probably enable urxvt 1015 first in case you decide to support it at all, and then enable the new de-facto standard SGR 1006 extension. Depending on the terminal emulator, screen might receive the events in several different formats then, but these formats are clearly distinguishable from each other (unlike in the 1005 mode) so it shouldn't matter. (1006 is a bit tricky here since it encodes the release event a bit differently than others. In fact, in non-1006 modes a bit of guesswork is required to see which button was released (e.g. the leftmost among the pressed ones), whereas 1006 tells you this explicitly.)

As for the windows/panes/whatever you call them inside screen, for each of them the requested extension (or lack thereof) should be remembered, just as by any terminal emulator, and the event should be sent according to that format.

So just as the coordinates themselves are adjusted by screen (the offset of the pane is subtracted), the protocol might also be altered. (And while at it, the set of supported extensions doesn't even have to be the same in the two directions. E.g. if you really care about urxvt, you might want to implement urxvt mode towards the host terminal emulator, but not necessarily towards the apps running inside screen.)

Sorry if that's how it works already.

Egmont Koblinger <egmont>
Wed 01 Feb 2017 03:43:04 PM UTC, comment #5: 

Odd, I wonder what would cause that... emacs user here, so I don't mouse around on the bottom row much. However, I can confirm that clicking on the emacs mini-buffer indeed sends "ESC [" (according to M-x view-lossage). Maybe an off-by-one error somewhere?

I haven't looked at the code in over a year, though, and won't be able to dig into the issue any time soon, unfortunately.


Ryan <scovich>
Wed 01 Feb 2017 03:33:46 PM UTC, comment #4: 

Thanks! I've tested it with vim and mc. It seems to mostly work, but one thing I've noticed is that in mc I can't use bottom row buttons it just writes '[' character to prompt.

Amadeusz Sławiński <amade>
Group administrator
Wed 01 Feb 2017 03:02:20 PM UTC, comment #3: 

Attaching the latest version of my patch, for 4.3.1. I've been using it on every copy of screen I have, without problems, for over a year now. I use the SGR mode almost exclusively, though, so YMMV on the other modes.

(file #39640)

Ryan <scovich>
Wed 01 Feb 2017 02:00:06 PM UTC, comment #2: 

If we want to support big terminal windows we should do this.


There is also
https://lists.gnu.org/archive/html/screen-devel/2014-04/msg00043.html
with similar patch.

One thing to consider is which standard to use (see this - https://midnight-commander.org/ticket/2956 - discussion for example.)

I would prefer only using SGR Extension (1006) - which would probably be solved by patch in e-mail.

See also http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking


Will retest patches again, because I recall having problems with having it to actually work (hence no patch applied).

Amadeusz Sławiński <amade>
Group administrator
Thu 29 May 2014 01:27:42 PM UTC, comment #1: 

Has someone been able to use this patch to get VIM to work with urxvt?

Guillaume Laferriere <guilafer>
Mon 27 Aug 2012 03:46:33 PM UTC, original submission:  

Many terminals have recently added support for so-called "rxvt" and "sgr" mouse modes which are superior to the traditional "x10" mouse mode. Unfortunately, screen doesn't recognize any of them and filters out their escape sequences.

The attached patch implements support for x10, utf8-x10, rxvt, and sgr mouse modes. It also fixes a long-standing bug where mouse sequences are mangled if they get split across 2+ I/O calls.

Ryan <scovich>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #42891:  screen-4_6_2-sgr-mouse-support.patch added by scovich (16KiB - application/octet-stream)
file #39640:  screen-ext-mouse-4.3.1.patch added by scovich (12KiB - application/octet-stream)
file #26434:  screen-ext-mouse.patch added by scovich (11KiB - application/octet-stream - Patch implementing newer terminal mouse modes)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by egmont (Posted a comment)
  • -email is unavailable- added by amade (Posted a comment)
  • -email is unavailable- added by guilafer (Posted a comment)
  • -email is unavailable- added by scovich (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-01-18 amade Assigned toNone amade
        Planned ReleaseNone 4.7.0
    2018-01-12 scovich Attached File- Added screen-4_6_2-sgr-mouse-support.patch, #42891
    2017-02-01 scovich Attached File- Added screen-ext-mouse-4.3.1.patch, #39640
    2017-02-01 amade StatusNone Confirmed
    2012-08-27 scovich Attached File- Added screen-ext-mouse.patch, #26434

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code