1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <ctype.h>
include <clset.h>
# CLGKEY -- Return the next keystroke value from a list structured `ukey' type
# parameter.
int procedure clgkey (param, key, strval, maxch)
char param[ARB] # parameter to be read
int key # keystroke value of cursor event
char strval[ARB] # string value, if any
int maxch
char ch
int nitems, op
pointer sp, buf, ip
int cctoc(), clglstr()
int clstati(), rdukey()
define quit_ 91
begin
call smark (sp)
call salloc (buf, SZ_LINE, TY_CHAR)
# Flush any buffered text output.
call flush (STDERR)
call flush (STDOUT)
# Read the keyboard in raw mode.
if (clstati (CL_PRTYPE) == PR_CONNECTED) {
if (clglstr (param, Memc[buf], SZ_LINE) == EOF) {
call sfree (sp)
return (EOF)
}
} else {
if (rdukey (Memc[buf], SZ_LINE) == EOF) {
call sfree (sp)
return (EOF)
}
}
ip = buf
nitems = 0
if (cctoc (Memc, ip, ch) == 0)
goto quit_
key = ch
nitems = nitems + 1
while (IS_WHITE (Memc[ip]))
ip = ip + 1
if (Memc[ip] != '\n' && Memc[ip] != EOS) {
op = 1
while (op <= maxch && Memc[ip] != '\n' && Memc[ip] != EOS) {
strval[op] = Memc[ip]
op = op + 1
ip = ip + 1
}
strval[op] = EOS
nitems = nitems + 1
}
quit_
call sfree (sp)
return (nitems)
end
|