# invocation:
+# OUT OF DATE
# run this without args
# then on stdin write
# one line which is a Tcl list for unk_{l,r} unk_contexts glyphsdone etc.
frame .d.mi.csr_0 -bg white -width 1
frame .d.mi.csr_1 -bg white -width 1
+ frame .d.pe
+ frame .d.pe.grid
+ button .d.pe.ok -text OK
+ pack .d.pe.grid .d.pe.ok -side left
- pack .d.csr .d.mi .d.got .d.ctx -side top
+ pack .d.mi .d.got .d.ctx -side top
pack .d
frame .help
if {$wh > $maxh} { set maxh $wh }
}
-proc resize_widgets {} {
+proc resize_widgets_core {} {
global mulcols mulrows csrh gotsh ctxh glyphsdone
global unk_l unk_contexts
foreach w {.d.csr .d.got .d.ctx} {
$w configure -width $mulcols
}
- #.d configure -height [expr {$csrh+$mulrows+$gotsh+$ctxh}]
- foreach w {0 1} {
- .d.mi.csr_$w configure -height $mulrows
- }
eval destroy [winfo children .d.ctx]
-
- set maxh 0
- foreach {min max contexts got} $glyphsdone {
- show_context maxh $min $contexts
- }
- show_context maxh $unk_l $unk_contexts
- .d.ctx configure -height $maxh
}
#---------- xpm input processor ----------
+proc must_gets {f lvar} {
+ upvar 1 $lvar l
+ if {[gets $f l] < 0} { error "huh?" }
+}
+
proc read_xpm {f} {
global glyphsdone mul inter rhsmost_max unk_l unk_r mulcols mulrows
global cols rows wordmap
set o {}
set y -3
while 1 {
- if {[gets $f l] < 0} { error "huh? "}
+ must_gets $f l
if {![regexp {^"(.*)",$} $l dummy l]} {
append o "$l\n"
if {[regexp {^\}\;$} $l]} break
set cur_0 $unk_l
set cur_1 [expr {$unk_r+1}]
- set last_ht {}
recursor
}
#---------- runtime display and keystroke handling ----------
+set last_ht {}
+
proc helptext {t} {
global last_ht
if {![string compare $t $last_ht]} return
#---------- database read and write ----------
+# OUT OF DATE
# database format:
# series of glyphs:
# <context> <ncharacters> <hex>...
proc main/default {} {
puts stderr "Do not run this program directly."
exit 12
-
- global glyphsdone unk_l unk_r unk_contexts
-
- set glyphsdone {
- 7 11 1 M
- 13 17 0 a
- 19 23 0 n
- }
- set unk_l 25
- set unk_r 29
- set unk_contexts Test
-
- set f [open text.xpm]
- read_xpm $f
- close $f
-
- read_database
- resize_widgets
- draw_glyphsdone
- startup_cursor
}
proc done/default {} {
}
proc required {} {
global glyphsdone unk_l unk_r unk_contexts
+
+ fileevent stdin readable {}
+ fconfigure stdin -blocking yes
if {[gets stdin l]<0} {
if {[eof stdin]} { fconfigure stdin -blocking yes; exit 0 }
return
}
init_widgets
+
+ required/$l
+}
+
+
+proc foreach_pixmap_col {var body} {
+ global alloptions
+ upvar 1 $var col
+ for {set col 0} {$col < [llength $alloptions]/3} {incr col} {
+ uplevel 1 $body
+ }
+}
+
+proc pixmap_select {ncol} {
+ global alloptions
+ debug "PIX SELECT $ncol [llength $alloptions]"
+ foreach_pixmap_col col {
+ if {$col==$ncol} continue
+ .d.pe.grid.l$col selection clear 0 end
+ }
+ pixmap_maybe_ok
+}
+proc pixmap_maybe_ok {} {
+ global alloptions pixmap_selcol pixmap_selrow
+ set nsel 0
+ foreach_pixmap_col col {
+ set cs [.d.pe.grid.l$col curselection]
+ incr nsel [llength $cs]
+ set pixmap_selcol $col
+ set pixmap_selrow [lindex $cs 0]
+ }
+ if {$nsel==1} {
+ .d.pe.ok configure -state normal -command pixmap_ok
+ } else {
+ .d.pe.ok configure -state disabled -command {}
+ }
+}
+proc pixmap_ok {} {
+ foreach_pixmap_col col {
+ .d.pe.grid.l$col configure -state disabled
+ }
+ .d.pe.ok configure -state disabled
+ helptext {{{ Processing }}}
+}
+
+proc required/pixmap {} {
+ global unk_what ppm mulcols alloptions
+ must_gets stdin unk_what
+ debug "GOT pixmap $unk_what"
+ set ppm {}
+ while 1 {
+ must_gets stdin ppml
+ if {![string length $ppml]} break
+ append ppm $ppml "\n"
+ }
+ set data [exec pnmscale 2 << $ppm]
+ image create photo image/main -data $data
+
+ set alloptions [exec ./yppsc-resolver-pixoptions $unk_what]
+
+ #read_database_pixmaps
+
+ set mulcols [image width image/main]
+ set mulrows [image height image/main]
+ resize_widgets_core
+ place forget .d.mi.csr_0
+ place forget .d.mi.csr_1
+ .d.ctx configure -height 0
+ pack forget .d.csr
+ pack .d.pe -side top -before .d.mi -pady 10
+
+ eval destroy [winfo children .d.pe.grid]
+ set col 0; foreach {colname coldesc rows} $alloptions {
+ debug "INIT $col $colname \"$coldesc\""
+ label .d.pe.grid.t$col -text $colname
+ listbox .d.pe.grid.l$col
+ foreach {rowname rowdesc} $rows {
+ debug "INIT $col $colname \"$coldesc\" $rowname \"$rowdesc\""
+ .d.pe.grid.l$col insert end $rowdesc
+ }
+ bind .d.pe.grid.l$col <<ListboxSelect>> [list pixmap_select $col]
+ grid .d.pe.grid.t$col -column $col -row 0
+ grid .d.pe.grid.l$col -column $col -row 1
+ incr col
+ }
+ pixmap_maybe_ok
+
+ helptext {
+ {{Indicate the correct parse of this image, and click OK.}}
+ }
+}
+
+proc required/char {} {
+ global mulrows
+
+ must_gets stdin l
+
manyset [lrange $l 0 3] unk_l unk_r unk_contexts
set glyphsdone [lrange $l 3 end]
debug "GOT $l"
- fileevent stdin readable {}
- fconfigure stdin -blocking yes
-
read_xpm stdin
- resize_widgets
+
+ resize_widgets_core
+ foreach w {0 1} {
+ .d.mi.csr_$w configure -height $mulrows
+ }
+ set maxh 0
+ foreach {min max contexts got} $glyphsdone {
+ show_context maxh $min $contexts
+ }
+ show_context maxh $unk_l $unk_contexts
+ .d.ctx configure -height $maxh
+ pack forget .d.pe
+ pack .d.csr -side top -before .d.mi
+
read_database
draw_glyphsdone
startup_cursor