[comp.sys.sgi] Modification of keyboard code sequences

browning@nas.nasa.gov (David S. Browning) (04/12/91)

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've used Mark Segal's "altIntoMeta" routine to make the alt key
behave as a meta key for GNU Emacs, and Eric Pettersen's "replacekeys"
routine to swap the Backspace and Delete keys.  If, instead of typing
alt-'Delete' (emacs "backward-kill-word") I mistakenly type alt-'='
(which is nearby), emacs receives the sequence "ESC [ 0 7 0 q", which
moves the cursor and inserts unwanted characters.  Depending on the
type of file being edited, the cursor can move far away, and it's easy
to lose track of where you were before.  This is very annoying.

It isn't important to know emacs to help me with this, it is only an
example of why I need help.  I want to disable those escape sequences
or reprogram them into something benign.  Has anybody done this, or
can anyone tell me how?  Or where in TFM to R?

I'll post the solution if I get one and there's interest.

Thanks,
David.

|============================================================================|
| Internet:  browning@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                                                             |
|============================================================================|

davet@dgp.toronto.edu (Dave Tonnesen) (04/12/91)

In article <1991Apr12.043331.29665@nas.nasa.gov> browning@amelia.nas.nasa.gov (David S. Browning) writes:
>...
>I've used Mark Segal's "altIntoMeta" routine to make the alt key
>behave as a meta key for GNU Emacs, and Eric Pettersen's "replacekeys"
>routine to swap the Backspace and Delete keys.  If, instead of typing
>...

How does one use/obtain the "altIntoMeta" routine you mention? 
Does one need a binary or is the usage similar to "replacekeys"?

Thanks, 
	Dave

----------------------------------------------------------------
David Tonnesen    davet@dgp.toronto.edu

browning@nas.nasa.gov (David S. Browning) (04/20/91)

In article <1991Apr12.043331.29665@nas.nasa.gov> browning@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@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@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                                                             |
|============================================================================|