chiark / gitweb /
fixes from bessar fettling session
[trains.git] / hostside / gui-displayer
index 7a66bf36682b56a2874f925aa4b3289107cddffe..eadac7d9fa4a603520de7e336704bdc2c8362171 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/wish
+#!/usr/bin/wish8.2
 
 proc widgets {} {
     global widg_pipe
@@ -44,10 +44,10 @@ proc P {onoff} { # power
     update_push
 }
 
-proc R {args} { # reverse segnames
+proc R {now args} { # reverse segnames
     foreach segname $args {
        upvar #0 segrev($segname) r
-       set r [expr {!$r}]
+       set r $now
        update_seg $segname
     }
     update_push
@@ -93,7 +93,7 @@ proc update_seg {segname} {
 #puts stderr "update_seg $segname"
 
     if {!$power} {
-       set command off
+        set command off
     } else {
        set command [expr {$d ? "det" : "on"}]
        if {$r} { set command "i$command" }
@@ -104,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
@@ -142,4 +142,17 @@ proc main {} {
     update_push
 }
 
+proc EOE {} { global exitoneof; set exitoneof 1}
+
 main
+
+while {[gets stdin l]>=0} {
+    if {[regexp {^GUI ([A-Z][0-9a-zA-Z ]*)$} $l dummy cmd]} {
+       puts "GUI $cmd"
+       eval $cmd
+    } else {
+       puts $l
+    }
+}
+
+if {[info exists exitoneof]} { exit 0 }