set csrh 20
proc init_widgets {} {
+ # idempotent
global csrh gotsh
+
+ if {[winfo exists .d]} return
frame .d
set cur_0 $unk_l
set cur_1 [expr {$unk_r+1}]
set last_ht {}
+
+ recursor
}
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"
}
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}]]
proc RETURN_RESULT {how what} {
+ global mainkind
place forget .d.csr.csr
pack forget .d.csr.csr.e
helptext {{{ Processing }}}
unbind_all_keys
update idletasks
- puts "$how $what"
+ puts stderr "$how $what"
eval update_database/$how $what
+ done/$mainkind
}
-# bind . <Key-space> {}
+#---------- main progrm ----------
-proc test_main {} {
+proc main/test {} {
global glyphsdone unk_l unk_r unk_context
set glyphsdone {
draw_glyphsdone
startup_cursor
}
+proc done/test {} {
+}
+
+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
+}
+
+proc main/automatic {} {
+ fconfigure stdin -blocking no
+ fileevent stdin readable required
+}
+proc done/automatic {} {
+ exec sh -c {printf \\0 >&4}
+ fileevent stdin readable required
+}
+
+switch -exact -- $argv {
+ {} { set mainkind test }
+ {--automatic 1} { set mainkind automatic }
+ {--automatic*} { error "incompatible versions - install problem" }
+ default { error "huh $argv ?" }
+}
read_database
-init_widgets
-test_main
-recursor
+main/$mainkind