bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10642: xt-mouse: Support extended coordinates


From: Egmont Koblinger
Subject: bug#10642: xt-mouse: Support extended coordinates
Date: Sun, 29 Jan 2012 17:27:43 +0100

Hi,

When running in terminal, Emacs only supports mouse clicks up to column or row 223, due to a limitation in the original mouse protocol. However, there is an extension (well, unfortunately, there are a couple of extensions) to overcome this limit.

This request is hereby for emacs to implement one of them, so that mouse click works on arbitrary coordinates.

The first of such extensions, implemented originally by xterm, is the "1005" mode.  It is horribly broken, it breaks mouse handling of applications that implement this extension but run on a terminal that doesn't.  So long story short: please don't even consider implementing this mode.

The next such extension, to overcome some problems with this mode was implemented originall by rxvt-unicode, is the "1015" extension.  Currently it is supported by quite a few terminal emulators, namely rxvt-unicode 9.10, iterm2 1.0 (added by mainstream author), xterm 277, gnome-terminal (vte 0.31) and konsole git HEAD (to become 4.9) -- for the last three the support was added by me.

For technical details about these two extensions, see the first comment of http://www.midnight-commander.org/ticket/2662 .

Since writing that ticket, another extension, the "1006" mode was invented by xterm's author, appeared in xterm-277, see the source of that for details.  In spirit it's pretty much like 1015 (e.g. avoid binary and spells out coordinates in decimal) but addresses some issues with 1015.

For some discussions about this 1006 extension versus 1015, see http://vim.1045645.n5.nabble.com/Fwd-Mouse-reporting-and-new-standards-td3378370.html (warning: multiple pages).

I am new to emacs's source and new to lisp, so probably I won't come up with a patch myself.  However, looking at the code, I have a feeling that adding support for 1006 might be easier than adding support for 1015.  This is because 1006 begins with \e[< (and even though theoretically other non-mouse events might also start with this escape, it's unlikely that emacs will ever be interested in those), so in xt-mouse.el you can define-key for \e[< and do all the rest in this file.  1015, due to lack of a unique prefix, requires a quite different parsing flow, and the fix would probably involve touching the C code, too.  That's my guess only.

Due to much wider adoptation by current terminals, I recommend that you implement the 1015 extension if it's feasible.  If not, then please implement the 1006 extension, and I'm happy to work in getting this extension into as many terminal emulators as possible.

In either case, the good news is that no matter which of 1006 or 1015 you choose, it won't break the behavior on terminals that don't support them.  Just ask the terminal to enable the extension by outputting "\e[?1000h\e[?1015h" or "\e[?1000h\e[?1006h", disable similarly when exiting (e.g. "\e[?1006l\e[?1000l").  If the underlying terminal supports the extension, it will report coordinates in the new format, but if doesn't then it will report coordinates in the old format.  These two formats are distinguishable (except for the 1005 mode, that's why that extension is out of question).

Just for the record: midnight commander >= 4.8.1 already supports the 1015 extension and autodetects it, no configuration is required from the user.  Vim >= 7.3.353 (>= 7.3.405 if running in xterm) also supports this extension, but you need to have ":set ttymouse=urxvt" in your .vimrc, so it's not autodetected; the autodetect possibility was discussed in the thread linked above.

Let me know if there's anything I can help with (apart from writing the actual patch :)).  The overall goal is hopefully to make clicks on arbitrary positions just work out of the box, without the user having to do anything.


thanks a lot,
egmont


reply via email to

[Prev in Thread] Current Thread [Next in Thread]