X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=pctb%2Fdictionary-manager;h=2c91a2a372be1a9cac3b5e5482b59bdfad8e51bd;hp=3c338cac6c3e0fc3fa8e24e9be427002926efb84;hb=ee971cd7fca39b33cd47a8ee5614e3189673d509;hpb=5bcf61f52358ce7a1ceea3106c4c8a2d0a6dbfcd diff --git a/pctb/dictionary-manager b/pctb/dictionary-manager index 3c338ca..2c91a2a 100755 --- a/pctb/dictionary-manager +++ b/pctb/dictionary-manager @@ -25,9 +25,10 @@ # sponsored by Three Rings. -# ./dictionary-manager --approve-updates ijackson@login.chiark.greenend.org.uk /home/ijackson/things/ypp-sc-tools.pctb-dict-test/pctb /home/ftp/users/ijackson/pctb/test # ./dictionary-manager --approve-updates ijackson@login.chiark.greenend.org.uk /home/ijackson/things/ypp-sc-tools.pctb-dict/pctb /home/ftp/users/ijackson/pctb +# ./dictionary-manager --approve-updates ijackson@login.chiark.greenend.org.uk /home/ijackson/things/ypp-sc-tools.pctb-dict-test/pctb /home/ftp/users/ijackson/pctb/test + # ./dictionary-manager --approve-updates '' . . @@ -41,6 +42,9 @@ # if it wrote a byte to fd 4, it can take another question +set aadepth 2 + + #---------- library routines ---------- proc manyset {list args} { @@ -90,6 +94,13 @@ proc bgerror {m} { exit 16 } +proc execpnm_createphoto {photoname args} { + set tmpfile ./_dictimage.tmp + eval exec $args > $tmpfile + image create photo $photoname -file $tmpfile + file delete $tmpfile +} + #---------- display core ---------- set mul 6 @@ -141,6 +152,7 @@ static unsigned char csr_bits[] = { button .pe.ok -text OK pack .pe.grid .pe.ok -side left + bind .pe.ok { .pe.ok invoke } pack .d.mi .d.ctx -side top -anchor w pack .d -fill x -padx 2 -pady 2 @@ -225,7 +237,7 @@ proc write_database {} { global reqkind database_fn database upvar #0 database_magic/$reqkind magic - set f [open $database_fn.new w] + set f [open $database_fn.tmp w] puts $f $magic write_database_header/$reqkind $f @@ -239,13 +251,13 @@ proc write_database {} { } puts $f "." close $f - file rename -force $database_fn.new $database_fn + file rename -force $database_fn.tmp $database_fn } proc select_database {dbname_spec} { global dbname set dbname $dbname_spec - read_database "./#local-$dbname#.txt" + read_database "./_local-$dbname.txt" } proc do_database_update {im def} { @@ -284,7 +296,7 @@ proc required/char {} { label .selctx.title -text \ {Select match context for altering dictionary:} pack .selctx.title -side left - set new_context [lindex $unk_contexts 0] + set new_context {} set ci 0; foreach ctx [lsort [array names all_contexts]] { set all_contexts($ctx) $ci @@ -362,7 +374,9 @@ proc pixmap_select {ncol} { if {$col==$ncol} continue .pe.grid.l$col selection clear 0 end } - pixmap_maybe_ok + if {[pixmap_maybe_ok]} { + focus .pe.ok + } } proc pixmap_maybe_ok {} { global alloptions pixmap_selcol pixmap_selrow @@ -378,8 +392,10 @@ proc pixmap_maybe_ok {} { if {$nsel==1} { debug "MAYBE_OK YES col=$pixmap_selcol row=$pixmap_selrow." .pe.ok configure -state normal -command pixmap_ok + return 1 } else { .pe.ok configure -state disabled -command {} + return 0 } } proc pixmap_ok {} { @@ -413,8 +429,7 @@ proc required/pixmap {} { if {![string length $ppml]} break append ppm $ppml "\n" } - set data [exec pnmscale 2 << $ppm] - image create photo image/main -data $data + execpnm_createphoto image/main pnmscale 2 << $ppm set alloptions [exec ./database-info-fetch $unk_what] @@ -448,7 +463,7 @@ proc required/pixmap {} { pixmap_maybe_ok helptext { - {{Indicate the meaning of this image, and click OK.}} + {{Indicate the meaning of this image; then click OK or hit Return.}} } } @@ -513,7 +528,7 @@ proc upload_status {} { } proc maybe_upload_entry {im def} { - global reqkind privacy_setting env dbname quiet + global reqkind privacy_setting env dbname quiet aadepth debug "DB-UPDATE PRIVACY $privacy_setting" if {!$privacy_setting} return @@ -522,6 +537,8 @@ proc maybe_upload_entry {im def} { set pl {} lappend pl dict $dbname + lappend pl version 3 + lappend pl depth $aadepth if {$privacy_setting>=2} { set pirate [string totitle $env(YPPSC_PIRATE)] @@ -689,9 +706,9 @@ proc char_read_pgm {f} { append o $ointerl } -# debug "DATA $o" - set data [exec pnmscale 1 << $o] - image create photo image/main -data $data +# debug "DATA1 $o" + + execpnm_createphoto image/main pnmscale 1 << $o } #---------- character set editor display ---------- @@ -723,7 +740,7 @@ proc startup_cursor {} { global glyphsdone unk_l unk_r set cur_already [expr {[llength $glyphsdone]/5-1}] - set cur_mode 1 ;# one of: 0 1 already text + set cur_mode 0 ;# one of: 0 1 already text set cur_0 $unk_l set cur_1 [expr {$unk_r+1}] @@ -764,7 +781,7 @@ proc recursor//01 {z1} { if {[lsearch -exact $okctxts $ctx] >= 0} { bind_key [string tolower $key] " [list set new_context $ctx] - recursor + char_start_define_text " } else { bind_key [string tolower $key] {} @@ -772,7 +789,7 @@ proc recursor//01 {z1} { lappend context_help $key } set context_help [list [join $context_help " "] \ - {Set match context for new glyph.}] + {Set match context for new glyph, confirm location, and start entry.}] bind_key space { othercursor } bind_leftright_q cur_$z1 0 [expr {$cols-1}] @@ -897,7 +914,7 @@ proc recursor {} { # $database($context 0x 0x...) = $hex -set database_magic/char {# ypp-sc-tools pctb font v2} +set database_magic/char "# ypp-sc-tools pctb font v3 depth=$aadepth" proc read_database_header/char {f} { global rows @@ -1133,10 +1150,10 @@ proc chop_counted {var} { } proc approve_decompose_data {specdata} { - global data + global data aadepth set data $specdata - regsub-data {^ypp-sc-tools dictionary update v2\n} {} + regsub-data "^ypp-sc-tools dictionary update v3 depth=$aadepth\\n" {} uplevel 1 chop_counted pirate uplevel 1 chop_counted caller uplevel 1 chop_counted dict @@ -1146,7 +1163,7 @@ proc approve_decompose_data {specdata} { uplevel 1 chop_counted key uplevel 1 chop_counted val - return [uplevel 1 {list $dict $def $image}] + return [uplevel 1 {list $dict $ctx $def $image}] } proc approve_compare {fd1 fd2} { @@ -1186,9 +1203,12 @@ proc approve_showentry {ix file specdata} { label $wb-def.def -text $def pack $wb-def.scope $wb-def.def -side bottom - set ppm [exec pnmscale 2 << $image] - image create photo approve/$ix -data $ppm - label $wb-image -image approve/$ix -bd 2 -relief sunken + if {[regexp {^P2} $image]} { + set image [exec pgmtoppm {#008-white} << $image | pnmnoraw] + append image "\n" + } + execpnm_createphoto approve/$ix pnmscale 2 << $image + label $wb-image -image approve/$ix -bd 2 -relief flat -bg black manyset [dict2_reqkind_rows $dict] reqkind approve_showentry_xinfo/$reqkind $wb-xinfo $def @@ -1236,6 +1256,8 @@ proc approve_check_server {} { proc approve_confirm {} { global approve_ixes approve_entryhow + .ok configure -state disabled + update idletasks approve_check_server foreach ix $approve_ixes { set how $approve_entryhow($ix) @@ -1270,6 +1292,7 @@ proc approve_fetch_list {} { set approve_list [lsort -command approve_compare $approve_list] approve_show_page 0 + .ok configure -state normal } proc main/approve {} {