[comp.sys.sgi] Key mappings under 4Sight 1.0

jeremy@cs.ua.oz.au (Jeremy Webber) (02/06/90)

I have just started using a Personal Iris with 4Sight, and wish to change some
of the key mappings, specifically (in decreasing order of importance):

	Make the key labelled "Backspace" return a DEL
	Make the key labelled "Caps Lock" act like a Control key
	Make the key labelled "Control" act like a META key

These are needed so I can make GNU Emacs work sensibly in a wsh(1) window.

Does anyone have the code necessary to insert into the "user.ps" file?  Can
anyone tell me how to remap keys in general under 4sight?  Yes, I have read TFM
(the 4sight guides), and tried to wade through the megabytes of postscript it
seems to be necessary to be intimate with in order to customize this window
system.

	-jeremy
--
--
Jeremy Webber			   ACSnet: jeremy@chook.ua.oz
Digital Arts Film and Television,  Internet: jeremy@chook.ua.oz.au
60 Hutt St, Adelaide 5001,	   Voicenet: +61 8 223 2430
Australia			   Papernet: +61 8 272 2774 (FAX)

merritt@iris613.gsfc.nasa.gov (John H Merritt) (02/06/90)

In article <JEREMY.90Feb6091202@chook.ua.oz.au> jeremy@cs.ua.oz.au (Jeremy Webber) writes:
>I have just started using a Personal Iris with 4Sight, and wish to change some
>of the key mappings, specifically (in decreasing order of importance):
>
>	Make the key labelled "Backspace" return a DEL
>	Make the key labelled "Caps Lock" act like a Control key
>	Make the key labelled "Control" act like a META key
>
>These are needed so I can make GNU Emacs work sensibly in a wsh(1) window.
>
>Does anyone have the code necessary to insert into the "user.ps" file?  Can
>anyone tell me how to remap keys in general under 4sight?  Yes, I have read TFM
>(the 4sight guides), and tried to wade through the megabytes of postscript it
>seems to be necessary to be intimate with in order to customize this window
>system.
>
>	-jeremy
>--
>--
>Jeremy Webber			   ACSnet: jeremy@chook.ua.oz
>Digital Arts Film and Television,  Internet: jeremy@chook.ua.oz.au
>60 Hutt St, Adelaide 5001,	   Voicenet: +61 8 223 2430
>Australia			   Papernet: +61 8 272 2774 (FAX)
%!
%%I forget where I got this, but it works great...
%%
%%Optionally modify the call to replacekeys, then put it in your user.ps.
%%
%%
/replacekeys { % origkeyvals_array changedkeyvals_array -> -
        {
                /changedvals exch def
                /origvals exch def
                /keysdict origvals length dict def
                keysdict begin
                        0 1 origvals length 1 sub {
                                dup origvals exch get changedvals
                                3 2 roll get def
                        } for
                end
                createevent dup begin
                        /Name origvals def
                        /Priority 2 def
                        /Exclusivity true def
                end
                expressinterest
                {
                        awaitevent dup dup begin
                        /Name get keysdict exch get /Name exch def
                        end
                        redistributeevent
                } loop
        } fork pop pop pop
} def

% Capslock becomes CTRL
% Right CTRL becomes Capslock
% backspace becomes delete
% delete becomes backspace

[28420 28561 28477 28478]
[28419 28420 28478 28477] replacekeys


% 28423	Escape
% 28562	F1
% 28563	F2
% 28564	F3
% 28565	F4
% 28566	F5
% 28567	F6
% 28568	F7
% 28569	F8
% 28570	F9
% 28571	F10
% 28572	F11
% 28573	F12
% 28574	Print Screen
% 28575	Scroll Lock
% 28576	Pause
% 28471	` and ~
% 28424	1 and !
% 28430	2 and @
% 28431	3 and #
% 28438	4 and $
% 28439	5 and %
% 28446	6 and ^
% 28447	7 and &
% 28454	8 and *
% 28455	9 and (
% 28462	0 and )
% 28463	- and _
% 28470	= and +
% 28477	Backspace
% 28577	Insert
% 28578	Home
% 28579	Page Up
% 28582	Keypad Num Lock
% 28583	Keypad /
% 28584	Keypad *
% 28492	Keypad -
% 28425	Tab and Backtab
% 28426	q
% 28432	w
% 28433	e
% 28440	r
% 28441	t
% 28448	y
% 28449	u
% 28456	i
% 28457	o
% 28464	p
% 28465	[ and {
% 28472	] and }
% 28473	\ and |
% 28478	Delete
% 28580	End
% 28581	Page Down
% 28483	Keypad 7
% 28484	Keypad 8
% 28491	Keypad 9
% 28585	Keypad +
% 28420	Caps Lock
% 28427	a
% 28428	s
% 28434	d
% 28435	f
% 28442	g
% 28443	h
% 28450	j
% 28451	k
% 28458	l
% 28459	; and :
% 28466	' and "
% 28467	Enter
% 28479	Keypad 4
% 28485	Keypad 5
% 28486	Keypad 6
% 28422	Shift (left side)
% 28436	z
% 28437	x
% 28444	c
% 28445	v
% 28452	b
% 28453	n
% 28460	m
% 28461	, and <
% 28468	. and >
% 28469	/ and ?
% 28421	Shift (right side)
% 28497	uparrow
% 28474	Keypad 1
% 28480	Keypad 2
% 28481	Keypad 3
% 28498	Keypad Enter
% 28419	Ctrl (left side)
% 28559	Alt (left side)
% 28499	Spacebar
% 28560	Alt (right side)
% 28561	Ctrl (right side)
% 28489	leftarrow
% 28490	downarrow
% 28496	rightarrow
% 28475	Keypad 0
% 28482	Keypad .




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
John H. Merritt                   #  Yesterday I knew nothing,
Applied Research Corporation      #  Today I know that.
merritt@iris613.gsfc.nasa.gov     #

izen@amelia.nas.nasa.gov (Steven H. Izen) (02/06/90)

In article <JEREMY.90Feb6091202@chook.ua.oz.au> jeremy@cs.ua.oz.au (Jeremy Webber) writes:
>I have just started using a Personal Iris with 4Sight, and wish to change some
>of the key mappings, specifically (in decreasing order of importance):
>
>	Make the key labelled "Backspace" return a DEL
>	Make the key labelled "Caps Lock" act like a Control key
>	Make the key labelled "Control" act like a META key
>
>These are needed so I can make GNU Emacs work sensibly in a wsh(1) window.

I am currently dealing with figuring this out myself, but for me it's low 
priority right now.  However, I do have an excellent workaround if your goal
is to get a sensible emacs.  Assuming, that your PI has Xsgi running on it, and
the X development kit, just build emacs to run under X.  I tried this, and to
my astonishment the alt-key worked as the meta-key with no prodding on my part.
Then the rest of your changes become somewhat standard emacs hacks (see 
gnu.emacs for details-don't ask me for help with lisp...)



-- 
Steve Izen: {sun,uunet}!cwjcc!skybridge!izen386!steve  / Quote corner:
or steve@izen386.math.cwru.edu                        / 
or izen@cwru.cwru.edu	   /-------------------------/ My second bike is a car.
                           | Klein bottle for sale - Inquire within.

TORDA@HGRRUG52.BITNET (02/06/90)

On 5-feb, Jeremy Webber writes about remapping keys under wsh in
order to run GNU emacs happily.

Is this the best way ? Remapping at that level is bound to confuse
anything else running under the wsh. Perhaps it would be better to
remap keys in you .emacs file, so for example

  (global-set-key "\b" 'delete-backward-char)
Note that you then have to bind the help functions to another key
of your choice. The above line for remapping is described in the
file called PROBLEMS in the top level directory in the emacs
distribution.

I also think that, for happy editing, it is more important to
define the arrow keys and then the page up/down and so on. Aside
from defining an escape-key-map, I also found it necessary to put
an (enable-arrow-keys) in the .emacs file.
Finally, you should make this stuff dependent on the type of
terminal being used, so people can still come in to the iris with
other terminal types and be able to edit properly.

In the lisp/term subdirectory, there are several sophisticated
examples for this kind of thing.

-Andrew Torda     (bitnet)   torda@hgrrug52

scotth@corp.sgi.com (Scott Henry) (02/10/90)

I have a hack to /usr/NeWS/lib/NeWS/UI.ps that makes the Alt keys act like
Meta keys to GNU Emacs (it was posted to the net a while ago, I forgot by
who). However, there is a big GOTCHA with this patch -- everything else on
the system which looks for the Alt keys won't find them, including X11!
Not being a NeWS hacker, I wasn't able to make it work as both.  I am
including a context diff of the 3.2 UI.ps (put the patched version in
~/NeWS/UI.ps so as not to screw-up anybody else who may use your system,
and to have a backup if it fails in a future release).

Disclaimer: this is public domain and is not supported in any way by SGI.

*** /usr/NeWS/lib/NeWS/UI.ps	Thu Mar  9 16:51:01 1989
--- UI.ps	Wed Mar  8 09:39:49 1989
***************
*** 318,326 ****
--- 318,358 ----
  	} ifelse
      } def
  
+ % new code for meta key
+ /MetaDown false def			% true when either alt key is down
+ 
+ {
+     createevent dup begin 		% gobble alt key
+                                         % Do not eat the right ctrl key.
+                                         % We will need it to swap with capslock
+                                         % in user.ps.
+ 	    /Name [28419 28560 28559] def % first one is left ctrl key
+ 	    /Priority 4 def
+ 	    /Exclusivity true def
+ 	end
+     expressinterest
+     {
+ 	awaitevent
+ 	dup /Action get /DownTransition eq
+ 		{/MetaDown true store}     % downtrans -> set  flag
+ 		{/MetaDown false store}	   % uptrans -> clear flag
+ 	ifelse
+     } loop
+ } fork
+ %end new code
+ 
      /deliver_keyboard_to_focus {				% event => -
  	dup dup begin						% ev ev
  	    sgi_translatekey					% ev (string)
+ % new code for meta key
+ 	    dup dup type /stringtype eq		% if there's a string
+ 	    exch length 0 ne and		% of nonzero length
+ 	    MetaDown and			% and meta is down
+ 	    Action /DownTransition eq and	% and ev is a keypress
+ 	    {dup dup 0 get 128 or		% then ior 128 into
+ 	     0 exch put				% the 1st char in the string
+ 	    } if
+ % end new code
  	    /ClientData exch def				% ev
  	end
  	InteractionLock monitorlocked MenuBusy 0 ne or {
*********************

remember, this is an either/or patch -- you can't have it both ways!

--
  Scott Henry <scotth@sgi.com>	| These are my	| Tardis Express -- when it
  Information Services,		| Opinions only!| absolutely, positively
  Silicon Graphics, Inc		| Whose else?	| has to be there -- yesterday.