|
From: | Ryan Johnson |
Subject: | Re: Best way to intercept terminal escape sequences? |
Date: | Fri, 27 Aug 2010 15:56:14 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 |
On Fri, 27 Aug 2010 12:36:52 +0200, David Kastrup wrote:
Ryan Johnson<address@hidden> writesI tried setting the keyboard-coding-system to iso-latin-1, but no luck.You should set it to raw-text, do your mouse code preprocessing, and afterwards decode the remainder using the intended coding system.
Like this? (defun xterm-mouse-event-read () (let ((c (read-char))) (cond ;; out-of-bounds values come back as zero ((eq c 0) #x100) ;; 8-bit characters come back weird ((> c (unibyte-char-to-multibyte #xff)) (+ #x80 (logand #xff c))) ((> c #xff) (multibyte-char-to-unibyte c)) ;; normal 7-bit character (c)))) (defun xterm-mouse-pos-read () (let ((old-coding (keyboard-coding-system))) (set-keyboard-coding-system 'raw-text) (unwind-protect (cons (xterm-mouse-event-read) (xterm-mouse-event-read)) (set-keyboard-coding-system old-coding)))) That sort of works, but has two major problems:First, it's unusably slow. The terminal appears to do several full redraw operations with every mouse click, which takes several tenths of a second.
Second, it's buggy. If I release the mouse button during that flickering, there's a very good chance for things to go very wrong. Looking at the lossage buffer for a double-click-gone-bad at (235 . 117) gave:
ESC [ M SPC \301\253 u ESC [ M # u ESC ESC [ M # u C-gThat's a mouse-down, followed by part of a mouse-up (missing px), followed by a lone ESC, followed by another partial mouse-up, followed by the keyboard-quit I sent when I saw this minibuffer prompt:
ESC [ M # u-In between each line was a raw-text --> utf-8-unix --> raw-text transition. Does something fail to release buffered-up characters when it gets swapped out? Or might this be related to bug #6920 in some way?
Ryan
[Prev in Thread] | Current Thread | [Next in Thread] |