chiark / gitweb /
fixes from bessar fettling session
[trains.git] / hostside / gui-displayer
index e00265d739560f13d3b0bcd03cf4a6c64121cbce..eadac7d9fa4a603520de7e336704bdc2c8362171 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/wish
+#!/usr/bin/wish8.2
 
 proc widgets {} {
     global widg_pipe
@@ -93,8 +93,7 @@ proc update_seg {segname} {
 #puts stderr "update_seg $segname"
 
     if {!$power} {
-       setsegbyname $segname off
-       return
+        set command off
     } else {
        set command [expr {$d ? "det" : "on"}]
        if {$r} { set command "i$command" }
@@ -105,7 +104,7 @@ proc update_seg {segname} {
     foreach mov $movs {
 #puts stderr "update_seg $segname mov $mov"
        upvar #0 movpos($mov) mp
-       if {[string length $mp]} {
+       if {[string length $mp] && [string compare off $command]} {
            setsegbyname $mov $command $mp
        } else {
            setsegbyname $mov $command
@@ -143,13 +142,17 @@ proc main {} {
     update_push
 }
 
+proc EOE {} { global exitoneof; set exitoneof 1}
+
 main
 
-while {[gets stdin l]} {
+while {[gets stdin l]>=0} {
     if {[regexp {^GUI ([A-Z][0-9a-zA-Z ]*)$} $l dummy cmd]} {
-       puts " * $cmd"
+       puts "GUI $cmd"
        eval $cmd
     } else {
        puts $l
     }
 }
+
+if {[info exists exitoneof]} { exit 0 }