{"action":"created","issue":{"url":"https://api.github.com/repos/keithw/mosh/issues/576","labels_url":"https://api.github.com/repos/keithw/mosh/issues/576/labels{/name}","comments_url":"https://api.github.com/repos/keithw/mosh/issues/576/comments","events_url":"https://api.github.com/repos/keithw/mosh/issues/576/events","html_url":"https://github.com/keithw/mosh/pull/576","id":53025320,"number":576,"title":"Fix xterm mouse support.","user":{"login":"lpkruger","id":5733671,"avatar_url":"https://avatars.githubusercontent.com/u/5733671?v=3","gravatar_id":"","url":"https://api.github.com/users/lpkruger","html_url":"https://github.com/lpkruger","followers_url":"https://api.github.com/users/lpkruger/followers","following_url":"https://api.github.com/users/lpkruger/following{/other_user}","gists_url":"https://api.github.com/users/lpkruger/gists{/gist_id}","starred_url":"https://api.github.com/users/lpkruger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpkruger/subscriptions","organizations_url":"https://api.github.com/users/lpkruger/orgs","repos_url":"https://api.github.com/users/lpkruger/repos","events_url":"https://api.github.com/users/lpkruger/events{/privacy}","received_events_url":"https://api.github.com/users/lpkruger/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2014-12-29T07:54:43Z","updated_at":"2015-06-04T03:49:43Z","closed_at":"2015-06-04T03:49:43Z","pull_request":{"url":"https://api.github.com/repos/keithw/mosh/pulls/576","html_url":"https://github.com/keithw/mosh/pull/576","diff_url":"https://github.com/keithw/mosh/pull/576.diff","patch_url":"https://github.com/keithw/mosh/pull/576.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/keithw/mosh/issues/comments/108709025","html_url":"https://github.com/keithw/mosh/pull/576#issuecomment-108709025","issue_url":"https://api.github.com/repos/keithw/mosh/issues/576","id":108709025,"user":{"login":"cgull","id":1934797,"avatar_url":"https://avatars.githubusercontent.com/u/1934797?v=3","gravatar_id":"","url":"https://api.github.com/users/cgull","html_url":"https://github.com/cgull","followers_url":"https://api.github.com/users/cgull/followers","following_url":"https://api.github.com/users/cgull/following{/other_user}","gists_url":"https://api.github.com/users/cgull/gists{/gist_id}","starred_url":"https://api.github.com/users/cgull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgull/subscriptions","organizations_url":"https://api.github.com/users/cgull/orgs","repos_url":"https://api.github.com/users/cgull/repos","events_url":"https://api.github.com/users/cgull/events{/privacy}","received_events_url":"https://api.github.com/users/cgull/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T03:49:43Z","updated_at":"2015-06-04T03:49:43Z","body":"Pulled, because this is clearly a big improvement on what we had before.\r\n\r\nI see a possible issue though:  If a terminal emulator doesn't support encoding mode 1006 (SGR), and an application requests, say, modes 1005 and 1006, then we may have a problem.  This patch contains the encoding mode as a single state.  Depending on the timing of reception of the application's requests, Mosh may or may not send 1005 with one frame update, but will send mode 1006 with another frame update.  In this case, the terminal emulator will stay in default encoding mode, which reports incorrectly past column or row 223.  I think this issue also applies similarly to the reporting mode.\r\n\r\nIn practice though, it all seems to work as well as it can-- the remaining issue is that terminal emulators that don't support encoding mode 1006 (urxvt, for example) break when you point with the mouse past column/row 223, with any combination of applications, screen/tmux, mosh/ssh.\r\n\r\nIn my testing, the only terminal emulators that have support for encoding mode 1006 are\r\n* iTerm2\r\n* Putty\r\n* Cygwin newterm (not surprising, it's derived from Putty)\r\n* XTerm\r\nI strongly suggest these if you like having large windows open.  Also, it appears that vim does not support encoding mode 1005/1006, and always breaks past column 223.\r\n\r\nI think for a truly pedantically correct fix, Mosh would have to record the individual mouse reporting/encoding codes sent by the application, the individual states they set, and *the order in which they were received*, and replay them to the terminal *in that same order* (including when restarted after `^^ ^Z`).\r\nBut I would guess that the applications that try multiple modes shotgun the terminal with numerically ascending sequences, and just take whatever bytes they get back from the terminal, so in practice I think this fix will work OK most of the time.  I hope.\r\n\r\n### Testing notes:\r\nI tested a subset of @eminence's scenarios in #505 (basically all of his scenarios with XTerm, and some with urxvt).  I also tested:\r\n\r\napps:\r\n* vim: click, mouse-wheel scroll\r\n* emacs: click, drag, mouse-wheel scroll\r\n* weechat: click, mouse-wheel scroll in user list\r\n* elinks: (achin) click, mouse-wheel scroll\r\n* htop: click\r\n\r\ntest programs:\r\n* xterm/vttest\r\n* http://www.leonerd.org.uk/code/libtermkey/\r\n* mousetest.pl https://code.google.com/p/iterm2/issues/detail?id=432\r\n (now at https://gitlab.com/gnachman/iterm2/issues/432, *very* smooth\r\n move on issues)\r\n\r\nterminal emulators:\r\n* Terminal (no XTerm mouse support)\r\n* iTerm 2 (full support)\r\n* xterm (full support)\r\n* Putty (full support)\r\n* Cygwin (full support)\r\n* gnome terminal (no SGR)\r\n* Konsole (no SGR)\r\n* xfce terminal (no SGR)\r\n* urxvt (no SGR)\r\n\r\nvirtual terminals?\r\n* tmux: enable mouse mode, click to select windows\r\n* screen: nothing much?\r\n\r\nparticular issues:\r\n* wide terminals \r\n* ^Z in Mosh (bug found, fixed)\r\n* window resize #560 (works now)\r\n\r\nTesting mouse issues is a combinatorial explosion, it would take a week or two from a full-time QA person to work through all the possible cases.\r\n\r\nI'm closing all the other open mouse issues and redirecting comment here.\r\n"}}