Reading keyboard input from PostScript
"Gary S. Moss", VLD/VMB
moss at BRL.MIL
Sat Mar 4 02:38:13 AEST 1989
Hi,
Any NeWS Extended Input System (EIS) gurus out there, please
help. I have been having difficulty writing PostScript code to read a
line of input on a 4D/60T running IRIX 3.1. It seems as though every
time the script is run, another 'interest' in keyboard events gets registered,
but not revoked, so that each keystroke is received multiple times,
depending on how many times the script has been run since 4Sight was last
loaded (by logging in to the console). Also, the keyboard events don't
get consumed by the 'awaitevent', but get read by the shell after the
script terminates.
I imagine I could do this easiest from 'C' and just call any
necessary PostScript graphics code by using the C to PostScript interface
(CPS), but I would like to understand what is going on.
Thanks,
moss
----------------------- cut here ------------------
#!/usr/NeWS/bin/psh
executive
/bias 16#6F00 def
/cr 13 def
/dim 100 def
/str dim string def
/buf dim string def
/insertchar % key => key
{
dup % => key key
bias sub % remove ASCII bias, => key char
str exch strindex exch put % str[strindex] = char, => key
/strindex strindex 1 add def % increment subscript
}
def
/getkeybdinput % - =>
{
strindex dim eq { exit } if % subscript range check
awaitevent % => event
/Name get % grab key value
insertchar % convert key to char and store it
cr eq { exit } if % quit if carriage return
pause
}
def
/getlinefromkeybd % - =>
{
{ getkeybdinput } loop str print (\n) print
}
def
/strindex 0 def % initialize subscript for string array
currentinputfocus % => [canvas,process]
/inputfocus 2 array def % create 'inputfocus' [canvas,process] array
inputfocus copy % store [canvas,process]
0 get addkbdinterests % enable receipt of keyboard events
/kbdevents 3 array def % create event array 'kbdevents'
kbdevents copy % store keyboard events
% The following line doesn't seem to be necessary.
% 0 get expressinterest % express interest in ascii_keymap
getlinefromkeybd
% The following are attempts to revoke all acquired interests, but only
% result in errors.
%kbdevents 0 get revokeinterest % revoke interest in ascii_keymap
%kbdevents inputfocus 0 get
%revokekbdinterests % undo effects of addkbdinterests
More information about the Comp.sys.sgi
mailing list