Modification of keyboard code sequences

David S. Browning browning at nas.nasa.gov
Sat Apr 20 00:44:06 AEST 1991


In article <1991Apr12.043331.29665 at nas.nasa.gov> browning at nas.nasa.gov (David S. Browning) writes:

   I want to be able to modify the code sequences generated by the
   IRIS-4D series keyboard.  I have a 4D/60 running IRIX 3.3.1, using the
   4Sight NeWS server (i.e. not X windows).

   My manual is a little old, Version 3.0.  In the 4Sight Programmer's
   Guide, Section 1: Using the GL/DGL Interfaces, Appendix A.2, Table A-3
   lists the code sequences generated for all the keys when combined with
   shift, ctrl and alt.  I want to disable the ANSI CSI ("ESC [") escape
   sequences.

I'll post what I've learned so far.  

Mark_Israel at mts.ucs.ualberta.ca helped me with elisp code that traps
the CSI sequences from within emacs.  I mapped M-[ to a new function
which reads the rest of the CSI sequence.  I had to remap
backward-paragraph since that used M-[, and I remapped
forward-paragraph as well so the two commands would stay together.

The following goes in .emacs:
---------------------------------------------------------------

;; These were originally M-[ and M-], but I want M-[ to trap CSI.
(global-set-key "\M-{" 'backward-paragraph)
(global-set-key "\M-}" 'forward-paragraph)

(defun csi-trap () "Trap CSI escape sequences from SGI Iris keyboard"
  (interactive)
  (setq c (read-char))
  (cond
    ((= c ?C) (forward-char 1))
    ((= c ?D) (backward-char 1))
    ((= c ?A) (previous-line 1))
    ((= c ?B) (next-line 1))
    ((= c ?0)
      (progn
        (setq c (read-char))
        (setq c (read-char))
        (setq c (read-char))
        (ding)))
    ((= c ?1)
      (progn
        (setq c (read-char))
        (setq c (read-char))
        (setq c (read-char))
        (ding)))
    ((= c ?2)
      (progn
        (setq c (read-char))
        (setq c (read-char))
        (setq c (read-char))
        (ding)))))

(global-set-key "\M-[" 'csi-trap)

-----------------------------------------------------------

The trapped CSI sequence beeps, unless it's one of the 4 arrow keys,
in which case it takes the appropriate action.

At the wsh level, bindkey(1) redefines a few of the function keys, and
these override the CSI sequences, even when combined with CTRL, ALT,
etc.  Once bindkey redefines them, they can't be trapped from within
emacs (at least not with csi-trap).

David

--
|============================================================================|
| Internet:  browning at nas.nasa.gov                  Phone:  (415) 604-4321   |
| UUCP:  {hplabs, mailrus, ucbvax, etc.}!ames!amelia!browning                |
|----------------------------------------------------------------------------|
|"the nice thing about true hopelessness is that you don't have to try again"|
| -- jules shear                                                             |
|============================================================================|



More information about the Comp.sys.sgi mailing list