From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Best way to intercept terminal escape sequences? Date: Fri, 27 Aug 2010 16:17:14 +0200 Organization: Organization?!? Message-ID: <87pqx487it.fsf@lola.goethe.zz> References: <20100827112348.5023B3D5@osgood.ece.cmu.edu> <4C77C3FE.1040503@ece.cmu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1282918670 14215 80.91.229.12 (27 Aug 2010 14:17:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Aug 2010 14:17:50 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 27 16:17:49 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 1Oozka-00067i-Fe for ged-emacs-devel@m.gmane.org; Fri, 27 Aug 2010 16:17:48 +0200 Original-Received: from localhost ([127.0.0.1]:51566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OozkZ-0001W3-FO for ged-emacs-devel@m.gmane.org; Fri, 27 Aug 2010 10:17:47 -0400 Original-Received: from [140.186.70.92] (port=38114 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OozkK-0001Sz-El for emacs-devel@gnu.org; Fri, 27 Aug 2010 10:17:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OozkF-0005an-C5 for emacs-devel@gnu.org; Fri, 27 Aug 2010 10:17:32 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:48213) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OozkF-0005aX-1H for emacs-devel@gnu.org; Fri, 27 Aug 2010 10:17:27 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OozkD-0005r9-0l for emacs-devel@gnu.org; Fri, 27 Aug 2010 16:17:25 +0200 Original-Received: from p508ece9d.dip.t-dialin.net ([80.142.206.157]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Aug 2010 16:17:25 +0200 Original-Received: from dak by p508ece9d.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Aug 2010 16:17:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 43 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508ece9d.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:JoYr1ZVveJltbGVSxIKSR4E932I= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:129305 Archived-At: Ryan Johnson writes: > 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)))) I don't see that you are setting the > (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)))) You can't go setting the keyboard reading system back and forth. It operates into a buffer even before calling read-char. You have to put it to raw and stick with it. > First, it's unusably slow. It would probably be best to write a CCL program for that sort of thing. -- David Kastrup