blob: c744c56044b70bb2a9ff294a32789d6a21a25ab5 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/usr/local/plan9/bin/rc
. 9.rc
. $PLAN9/lib/acme.rc
fn event {
# $1 - c1 origin of event
# $2 - c2 type of action
# $3 - q0 beginning of selection
# $4 - q1 end of selection
# $5 - eq0 beginning of expanded selection
# $6 - eq1 end of expanded selection
# $7 - flag
# $8 - nr number of runes in $7
# $9 - text
# $10 - chorded argument
# $11 - origin of chorded argument
switch($1$2){
case E* # write to body or tag
case F* # generated by ourselves; ignore
case K* # type away we do not care
case Mi # mouse: text inserted in tag
case MI # mouse: text inserted in body
case Md # mouse: text deleted from tag
case MD # mouse: text deleted from body
case Mx MX # button 2 in tag or body
winwriteevent $*
case Ml ML # button 3 in tag or body
{
if(~ $dict NONE)
dictwin /adict/$9/ $9
if not
dictwin /adict/$dict/$9 $dict $9
} &
}
}
fn dictwin {
newwindow
winname $1
switch($#*){
case 1
dict -d '?' >[2=1] | sed 1d | winwrite body
case 2
dict=$2
case 3
dict=$2
dict -d $dict $3 >[2=1] | winwrite body
}
winctl clean
wineventloop
}
dict=NONE
if(~ $1 -d){
shift
dict=$2
shift
}
if(~ $1 -d*){
dict=`{echo $1 | sed 's/-d//'}
shift
}
if(~ $1 -*){
echo 'usage: adict [-d dict] [word...]' >[1=2]
exit usage
}
switch($#*){
case 0
if(~ $dict NONE)
dictwin /adict/
if not
dictwin /adict/$dict/ $dict
case *
if(~ $dict NONE){
dict=`{dict -d'?' | 9 sed -n 's/^ ([^\[ ]+).*/\1/p' | sed 1q}
if(~ $#dict 0){
echo 'no dictionaries present on this system' >[1=2]
exit nodict
}
}
for(i)
dictwin /adict/$dict/$i $dict $i
}
|