aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-01-07 19:12:32 +0000
committerrsc <devnull@localhost>2005-01-07 19:12:32 +0000
commit474ef694962718ddf82f93f841f91ee0a1dc6252 (patch)
tree6ff0531d974aba10fbb6c718b8469e27ab4aeb6c /bin
parent566f93c70d2f97fb885e350764cd750f2d107119 (diff)
downloadplan9port-474ef694962718ddf82f93f841f91ee0a1dc6252.tar.gz
plan9port-474ef694962718ddf82f93f841f91ee0a1dc6252.tar.bz2
plan9port-474ef694962718ddf82f93f841f91ee0a1dc6252.zip
add adict
Diffstat (limited to 'bin')
-rwxr-xr-xbin/adict86
1 files changed, 86 insertions, 0 deletions
diff --git a/bin/adict b/bin/adict
new file mode 100755
index 00000000..979c6473
--- /dev/null
+++ b/bin/adict
@@ -0,0 +1,86 @@
+#!/usr/local/plan9/bin/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 - flag
+ # $6 - nr number of runes in $7
+ # $7 - text
+ # $8 - chorded argument
+ # $9 - 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/$7/ $7
+ if not
+ dictwin /adict/$dict/$7 $dict $7
+ } &
+ }
+}
+
+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'?' | 9sed -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
+}
+