+
+set gotsh 20
+set csrh 20
+set ctxh 20
+
+proc init_widgets {} {
+ # idempotent
+ global csrh gotsh ctxh
+
+ if {[winfo exists .d]} return
+
+ frame .d
+
+ image create bitmap image/main
+ label .d.mi -image image/main -borderwidth 0
+
+ frame .d.csr -bg black -height $csrh
+ frame .d.got -bg black -height $gotsh
+ frame .d.ctx -bg black
+
+ image create bitmap image/cursor -data \
+{#define csr_width 11
+#define csr_height 11
+static unsigned char csr_bits[] = {
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x21, 0x04, 0x22, 0x02, 0x25, 0x05,
+ 0xaa, 0x02, 0x74, 0x01, 0xa8, 0x00, 0x70, 0x00, 0x20, 0x00};
+}
+
+ frame .d.csr.csr
+ label .d.csr.csr.l -image image/cursor -compound left
+ entry .d.csr.csr.e -bd 0
+ pack .d.csr.csr.l -side left
+
+ frame .d.mi.csr_0 -bg white -width 1
+ frame .d.mi.csr_1 -bg white -width 1
+
+ pack .d.csr .d.mi .d.got .d.ctx -side top
+ pack .d
+
+ frame .help
+ pack .help
+}
+
+proc show_context {maxhv x ctxs} {
+ global mul
+ upvar 1 $maxhv maxh
+ set w .d.ctx.at$x
+ if {[llength $ctxs]==1} { set fg blue } { set fg yellow }
+ label $w -bg black -fg $fg -text [join $ctxs "/\n"] -justify left
+ place $w -x [expr {($x-1)*$mul}] -y 0
+ set wh [winfo reqheight $w]
+ if {$wh > $maxh} { set maxh $wh }
+}
+
+proc resize_widgets {} {
+ global mulcols mulrows csrh gotsh ctxh glyphsdone
+ global unk_l unk_contexts
+
+ foreach w {.d.csr .d.got .d.ctx} {
+ $w configure -width $mulcols