chiark / gitweb /
progress printing and bugfixing and build system improvements
[ypp-sc-tools.web-live.git] / pctb / show-thing.tcl
index 1af2101f9077d7f24927f1b0ea25ba39312d778d..5356c3292c7c58a276944752d6b16c325b1f5090 100755 (executable)
@@ -134,7 +134,7 @@ proc read_xpm {f} {
 
            set realcols $cols
            set cols [expr {$cols - $chop_l - $chop_r}]
-           puts stderr "NOW cols=$cols chop_l,r=$chop_l,$chop_r rows=$rows\
+           debug "NOW cols=$cols chop_l,r=$chop_l,$chop_r rows=$rows\
                 $unk_l $unk_r $ngd"
            
            set mulcols [expr {$cols*$mul+$inter}]
@@ -477,7 +477,7 @@ proc RETURN_RESULT {how what} {
     helptext {{{ Processing }}}
     unbind_all_keys
     update idletasks
-    puts stderr "$how $what"
+    debug "$how $what"
     eval update_database/$how $what
     done/$mainkind
 }
@@ -518,9 +518,10 @@ proc required {} {
     init_widgets
     manyset [lrange $l 0 3] unk_l unk_r unk_contexts
     set glyphsdone [lrange $l 3 end]
-    puts stderr "SHOW-THING GOT $l"
+    debug "GOT $l"
 
     fileevent stdin readable {}
+    fconfigure stdin -blocking yes
 
     read_xpm stdin
     resize_widgets
@@ -535,14 +536,20 @@ proc main/automatic {} {
 }
 proc done/automatic {} {
     exec sh -c {printf \\0 >&4}
-    fileevent stdin readable required
+    main/automatic
 }
 
-switch -exact -- $argv {
-    {}               { set mainkind test }
-    {--automatic 1}  { set mainkind automatic }
-    {--automatic*}   { error "incompatible versions - install problem" }
-    default          { error "huh $argv ?" }
+proc debug {m} { }
+
+set mainkind test
+foreach arg $argv {
+    switch -exact -- $arg {
+       {--debug}        { proc debug {m} { puts stderr "SHOW-THING $m" } }
+       {--noop-arg}     { }
+       {--automatic-1}  { set mainkind automatic }
+       {--automatic*}   { error "incompatible versions - install problem" }
+       default          { error "huh $argv ?" }
+    }
 }
 
 main/$mainkind