From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Johnson Newsgroups: gmane.emacs.devel Subject: Re: Best way to intercept terminal escape sequences? Date: Fri, 27 Aug 2010 15:56:14 +0200 Message-ID: <4C77C3FE.1040503@ece.cmu.edu> References: <20100827112348.5023B3D5@osgood.ece.cmu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1282917390 8240 80.91.229.12 (27 Aug 2010 13:56:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Aug 2010 13:56:30 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 27 15:56:29 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OozPw-0001jY-Kl for ged-emacs-devel@m.gmane.org; Fri, 27 Aug 2010 15:56:28 +0200 Original-Received: from localhost ([127.0.0.1]:41909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OozPw-0002SG-2n for ged-emacs-devel@m.gmane.org; Fri, 27 Aug 2010 09:56:28 -0400 Original-Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OozPp-0002Ru-Kd for emacs-devel@gnu.org; Fri, 27 Aug 2010 09:56:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OozPo-0002Op-EH for emacs-devel@gnu.org; Fri, 27 Aug 2010 09:56:21 -0400 Original-Received: from bache.ece.cmu.edu ([128.2.129.23]:51863) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OozPo-0002Oe-BL for emacs-devel@gnu.org; Fri, 27 Aug 2010 09:56:20 -0400 Original-Received: from [128.178.240.148] (tsf-wpa-2-0148.epfl.ch [128.178.240.148]) by bache.ece.cmu.edu (Postfix) with ESMTP id 27671B8 for ; Fri, 27 Aug 2010 09:56:18 -0400 (EDT) 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 In-Reply-To: <20100827112348.5023B3D5@osgood.ece.cmu.edu> X-detected-operating-system: by eggs.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:129303 Archived-At: On Fri, 27 Aug 2010 12:36:52 +0200, David Kastrup wrote: > Ryan Johnson writes >> I 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-g That'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