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

TELNET to Unix Emacs



Greetings, all.  

I got tired of typing escape-characters to emacs when I terminal to
unix machines from the LISPM.  This patches the telnet character
typein filter to convert meta-chars to the sequence ESCAPE-followed-
by-char.  It has probably appeared here before, but in case not, here
it is for anyone's use.  Please pardon the length -- it was borderline
whether to just post a note or include the code.

Jeffrey

;;; -*- Mode: LISP; Package: TELNET; Base: 8 -*-

;;; patch to convert meta-<char> to ESCAPE - CHAR in telnet filter
(DEFMETHOD (:FILTER TELNET-FILTER) (CH)
  (COND ((LISTP CH)
	 CH)
	((CL:MEMBER CH '(#\SCROLL #\META-SCROLL #\KEYBOARD:BACK-SCROLL) :TEST #'CHAR-EQUAL)
	 (CP::SCROLL-WINDOW-COMMAND-INTERNAL
	   :SCREEN
	   (SELECTOR CH CHAR-EQUAL
	     (#\SCROLL +1)
	     (#\META-SCROLL -1)
	     (#\KEYBOARD:BACK-SCROLL -1))
	   :Y *TERMINAL-STREAM*)
	 NIL)
	(T
	 (LET ((CODE (SEND INPUT-TRANSLATION-STATE :TRANSLATE-INPUT-CHAR CH)))
	   (WHEN (NULL CODE)
	     (SETQ CODE (CHAR-CODE CH))
	     (WHEN (CHAR-BIT CH :CONTROL)
	       (SETQ CODE (LDB (BYTE 5 0) CODE)))	;Controlify
	     (COND ((> CODE #O400)		; outside standard charset?
		    (SETQ CODE NIL))		; not handled. 
		   (T
		    (SETQ CODE (AREF *TELNET-KEYS* CODE))))
	     (WHEN (AND (FIXP CODE) (CHAR-BIT CH :META))
	       (WHEN (OR ( (CHAR-CODE #/A) CODE (CHAR-CODE #/Z))
			 ( (CHAR-CODE #/a) CODE (CHAR-CODE #/z)))
		 (SETQ CODE (LOGXOR CODE #O40)))	;Flip case (m-A  m-a).
;;; this section patched
	       (SEND OUTPUT-STREAM :TYO #o033)    ; send an escape to the output
	       CODE))
;;; old code   (SETQ CODE (LOGIOR CODE #O200))))
;;; end of patch
	   (IF (ARRAYP CODE)
	       (LOOP FOR CODE BEING THE ARRAY-ELEMENTS OF CODE
		     DO (SEND OUTPUT-STREAM :TYO CODE))
	       CODE)))))