#!/dis/sh
load expr
args=$*
pctl newpgrp
fn debug {
echo $* >[1=2]
}
ifs='
'
nl='
'
{
rargs := ()
rnum := 1
getlines {
rargs=$rargs $line
echo $rnum blue $line
rnum=${expr $rnum 1 +}
}
echo ${join $nl $rargs} | rectfind $args | getlines {
echo $rnum $line
rnum=${expr $rnum 1 +}
}
} | {
load tk
wid := ${tk window 'Test rects'}
while {} {tk winctl $wid ${recv $wid}} &
fn x { a := $*; or {tk $wid $a} {echo error on tk cmd $"a':' $status }}
x canvas .c -width 500 -height 400
x pack .c
chan stdout; tk namechan $wid stdout
x bind .c '<Button-1>' {send stdout %x %y}
tk onscreen $wid
while {} {echo ${recv stdout}} &
x update
getlines {
(rnum col r) := ${split $line}
lastcmd = x .c create rectangle $r -fill $col -tags t^$rnum
$lastcmd
x update
if {! ~ $col blue} {
sleep 1
x .c delete t^$rnum
x update
}
}
$lastcmd
x update
echo finished >[2=1]
< /dev/cons getlines {
x ${unquote $line}
x update
}
}
|