-set rhsmost_max -1
-
-set f [open text.xpm]
-set o {}
-set y -3
-while {[gets $f l] >= 0} {
- if {![regexp {^"(.*)",$} $l dummy l]} {
- append o "$l\n"
- continue
- }
- if {$y==-3} {
- manyset $l cols rows colours cpp
- #assert {$colours==2}
- #assert {$cpp==1}
- set mulcols [expr {$cols*$mul+$inter}]
- set mulrows [expr {$rows*$mul+$inter}]
- append o "\"$mulcols $mulrows 9 1\",\n"
- for {set x 0} {$x<$cols} {incr x} { set wordmap($x) 0 }
- } elseif {$y==-2} { # first pixel
- append o \
+
+set gotsh 20
+set csrh 20
+
+proc init_widgets {} {
+ # idempotent
+ global csrh gotsh
+
+ 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
+
+ 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.csr_0 -bg white -width 1
+ frame .d.csr_1 -bg white -width 1
+
+ place .d.csr -x 0 -y 0
+ place .d.mi -x 0 -y $csrh
+ pack .d
+
+ frame .help
+ pack .help
+}
+
+
+#---------- xpm input processor ----------
+
+proc read_xpm {f} {
+ global glyphsdone mul inter rhsmost_max unk_l unk_r gotsh csrh
+ global cols rows wordmap
+
+ set o {}
+ set y -3
+ while 1 {
+ if {[gets $f l] < 0} { error "huh? "}
+ if {![regexp {^"(.*)",$} $l dummy l]} {
+ append o "$l\n"
+ if {[regexp {^\}\;$} $l]} break
+ continue
+ }
+ if {$y==-3} {
+ manyset $l cols rows colours cpp
+ #assert {$colours==2}
+ #assert {$cpp==1}
+ set mulcols [expr {$cols*$mul+$inter}]
+ set mulrows [expr {$rows*$mul+$inter}]
+ append o "\"$mulcols $mulrows 9 1\",\n"
+ for {set x 0} {$x<$cols} {incr x} { set wordmap($x) 0 }
+ } elseif {$y==-2} { # first pixel
+ append o \