chiark / gitweb /
wip
[ypp-sc-tools.db-live.git] / pctb / show-thing.tcl
index 0b0b8f553616109d21da2d96a99f70bf33809a1f..c0182238557b3dd5e64c5c020d5e8d4d4756393a 100755 (executable)
@@ -26,7 +26,10 @@ set gotsh 20
 set csrh 20
 
 proc init_widgets {} {
+    # idempotent
     global csrh gotsh
+
+    if {[winfo exists .d]} return
     
     frame .d
 
@@ -176,6 +179,8 @@ proc startup_cursor {} {
     set cur_0 $unk_l
     set cur_1 [expr {$unk_r+1}]
     set last_ht {}
+
+    recursor
 }
 
 
@@ -240,7 +245,7 @@ proc recursor/text {} {
     pack .d.csr.csr.e -side left
     focus .d.csr.csr.e
     bind_key Return {
-       binary scan [.d.csr.csr.e get] h* hex
+       binary scan [.d.csr.csr.e get] H* hex
        if {[string length $hex]} {
            RETURN_RESULT DEFINE "$cur_0 $cur_1 $hex"
        }
@@ -343,7 +348,7 @@ proc write_database {} {
     set ol {}
     foreach bm [array names database] {
        set strh $database($bm)
-       set strs [binary format h* $strh]
+       set strs [binary format H* $strh]
        set strdo [format "%d %s" [expr {[string length $strh]/2}] $strh]
        set o "[lindex $bm 0] $strdo\n"
        append o [format "%d\n" [expr {[llength $bm]-1}]]
@@ -401,11 +406,13 @@ proc RETURN_RESULT {how what} {
     helptext {{{ Processing }}}
     unbind_all_keys
     update idletasks
-    puts "$how $what"
+    puts stderr "$how $what"
     eval update_database/$how $what
+    exec kill -STOP [pid]
+    fileevent stdin readable required
 }
 
-#    bind . <Key-space> {}
+#---------- main progrm ----------
 
 proc test_main {} {
     global glyphsdone unk_l unk_r unk_context
@@ -427,7 +434,25 @@ proc test_main {} {
     startup_cursor
 }
 
+proc required {} {
+    global glyphsdone unk_l unk_r unk_context
+    
+    if {[gets stdin l]<0} {
+       if {[eof stdin]} { fconfigure stdin -blocking yes; exit 0 }
+       return
+    }
+    init_widgets
+    manyset [lrange $l 0 3] unk_l unk_r unk_context
+    set glyphsdone [lrange $l 3 end]
+    puts stderr "SHOW-THING GOT $l"
+
+    fileevent stdin readable {}
+
+    read_xpm stdin
+    draw_glyphsdone
+    startup_cursor
+}
+
 read_database
-init_widgets
-test_main
-recursor
+fconfigure stdin -blocking no
+fileevent stdin readable required