Subject: keyboard handling

From: [email-masked] (putnam)
Date: Fri, 3 Jul 87 01:48:46 EDT

Date: 2 Jul 87 13:19:56 GMT
From: [email-masked]  (putnam)
Subject: keyboard handling
To: [email-masked]

Im more than a little bothered by the keyboard handling in NeWS.  The
keyboard handling that is already in it is ok for most vanilla stuff
and emulates terminal (ie vt100) keyboard handling acceptably (with
one exception) - but im not sure that is enough for major windowing
applications.

The first problem with keyboard handling is the lack of auto-repeat
on keys.  That is, if i hold down the "f" key, i expect to get
"fffffff" until i take it up with some reasonable time between the
"f"'s.  This does not happen and i have looked at the keyboard handling
code and dont see offhand just where to put it.  I thought it might be
nice to put it in the terminal handling at least for psterm - but that
would require even more hackery as there is no provision for handling
"up" events.  Not impossible, just painful.

A more fundamental problem seems to be the handling of
shift-control-meta type keys.  Currently the shift and control keys
are encoded when you get the event (so that "shift-a" becomes "A" and
so forth), the meta key is ignored here.  It is certainly possible to
get the values of the shift, control, meta keys - but is more work
(look for shift_keys_down, and so forth in dictionary UI_private).
But at this point the key has already been encoded for you and it may
be more difficult to get at what you want - that is if you really
want to deal with control-shift-meta-left-overshoe-x.  Again, its
not impossible to get this stuff - but i think the X model is simpler
and easier to deal with - though it does require more work on the part
of the client to handle.

I imagine that one of the reasons for doing things this way is to
help to unify the user interface - so that most user interfaces look
similar - and this is a laudable goal - but is this the right level
at which to do it?

Any thoughts?

Well, shall we go?  -- jefu (jeff putnam)
Yes, lets go.       -- UUCP: steinmetz!putnam
(They do not move.) -- ARPA: [email-masked]

---

From: Rafael Bracho <[email-masked]>
Date: Tue, 7 Jul 87 01:33:47 EDT

Date: 6 Jul 1987 08:28-PST
From: Rafael Bracho <[email-masked]>
Subject: Re: keyboard handling
To: [email-masked]  (putnam)
Cc: [email-masked]

Jeff,

I agree with you in that auto-repeat is an important feature missing
from NeWS 1.0; mind you, it was present in most of the older beta tapes.
Hopefully Sun will re-instate auto-repeat soon.

As for the shift keys, there is a field in the events called KeyState
which is an array of both keywords and numbers, corresponding to the
raw data obtained from the keyboard.  Thus the following event handler
returns a byte encoding the state of the keyboard (recall that the
event is put on the stack by NeWS before calling your handler):

	/HandleMouseClick {	% event => -
	    begin
	    0			% The byte we'll modify
	    KeyState length 0 ne {
		KeyState {
		    dup /Meta eq {
			pop 2#00010000 or
		    } {
			dup /Control eq {
			    pop 2#00001000 or
			} {
			    /Shift eq { 2#00000100 or } if
			} ifelse
		    } ifelse
		} forall
	    } if
	    end
	} def

(Note that I don't use a case statement because I've found it too slow
for inner-loop applications.)

There is one more problem I've found.  Often NeWS misses a shift key
completely, thus you get lowercase when you meant uppercase, or the
string "xs" is inserted in your emacs buffer when you meant to save the
file.  This seems to be a synchronization problem, but I haven't had
time to track it down.

					Rafael Bracho
					[email-masked]

---

From: Ian Kemmish <[email-masked]>
Date: Sat, 11 Jul 87 01:46:58 EDT

From: Ian Kemmish <[email-masked]>
Date: Thu, 9 Jul 87 11:00:23 +0100
To: [email-masked]
Subject: Re: Keyboard handling

Hmmm.  We've got NeWS running on machines with cheap IBM clone
keyboards on them. (Well, it's one way to keep costs down!)
These auto-repeat whether you like it or not, so we definitely
don't want the window manager to start repeating keys as well. . .
If Sun re-instate auto-repeat keys in NeWS, I hope they do it
portably!