#!/dis/sh # simple tk application: execute commands entered by # the user and place the output in a scrollable text widget { load std load tk pctl newpgrp wid=${tk window 'A shell application'} {while {} {tk winctl $wid ${recv $wid}}} & # default window handling fn x { a := $*; or {tk $wid $a} {echo error on tk cmd $"a':' $status } } nl:=' ' x entry .e x frame .f x scrollbar .f.s -orient vertical -command {.f.t yview} x text .f.t -yscrollcommand {.f.s set} x pack .f.s -side left -fill y x pack .f.t -side top -fill both -expand 1 x pack .e -side top -fill x x pack .f -side top -fill both -expand 1 x pack propagate . 0 x bind .e '' {send event enter} x update chan event tk namechan $wid event event while {} { {} ${recv event} cmd := ${tk $wid .e get} text := "{ rescue '*' {echo 'execution failed: got exception' $exception} { '{'^$cmd^'}' } } x .f.t delete 1.0 end x .f.t insert 1.0 ''''^$text x update } } &