chiark / gitweb /
wip. before remove sigstop based thing which is mad
authorIan Jackson <ian@liberator.(none)>
Wed, 3 Jun 2009 23:52:29 +0000 (00:52 +0100)
committerIan Jackson <ian@liberator.(none)>
Wed, 3 Jun 2009 23:52:29 +0000 (00:52 +0100)
pctb/database
pctb/ocr.c
pctb/show-thing.tcl

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d5e7803ac2701baa9e9beceb2435504e3e7fb65c 100644 (file)
@@ -0,0 +1,30 @@
+0 1 57
+5
+7e0
+800
+800
+400
+fe0
+0 1 76
+5
+27c0
+2820
+2820
+2420
+1fe0
+1 1 16
+6
+640
+920
+920
+920
+fc0
+800
+1 1 35
+6
+830
+848
+888
+888
+708
+8
index 87bf80842a510280e30826d8fe36c877911b59e8..43636f2d1c18861d77d890e8f49c2373a1bff627 100644 (file)
@@ -88,7 +88,8 @@ static void ocr_readdb(void) {
   eassert(feof(db));
 }      
 
   eassert(feof(db));
 }      
 
-static void callout_unknown(int w, int h, Pixcol cols[], int unk_l, int unk_r,
+static void callout_unknown(int w, int h, Pixcol cols[],
+                           int unk_l, int unk_r, int unk_ctx,
                            const OcrResultGlyph *sofar, int nsofar) {
   int pfd[2], c, r,i, x,y;
   const OcrResultGlyph *s;
                            const OcrResultGlyph *sofar, int nsofar) {
   int pfd[2], c, r,i, x,y;
   const OcrResultGlyph *s;
@@ -108,7 +109,7 @@ static void callout_unknown(int w, int h, Pixcol cols[], int unk_l, int unk_r,
     r= close(pfd[0]); eassert(!r);
     resolver= fdopen(pfd[1],"w"); eassert(resolver);
   }
     r= close(pfd[0]); eassert(!r);
     resolver= fdopen(pfd[1],"w"); eassert(resolver);
   }
-  fprintf(resolver,"%d %d",unk_l,unk_r);
+  fprintf(resolver,"%d %d %d",unk_l,unk_r,unk_ctx);
   for (i=0, s=sofar; i<nsofar; i++, s++) {
     fprintf(resolver," %d %d %d ",s->l,s->r,s->ctx);
     for (p=s->s; (c= *p); p++) {
   for (i=0, s=sofar; i<nsofar; i++, s++) {
     fprintf(resolver," %d %d %d ",s->l,s->r,s->ctx);
     for (p=s->s; (c= *p); p++) {
@@ -245,10 +246,10 @@ OcrResultGlyph *ocr(int w, int h, Pixcol cols[]) {
     } else {
       int rx;
       fprintf(debug," UNKNOWN");
     } else {
       int rx;
       fprintf(debug," UNKNOWN");
-      for (rx=lx+1; rx<w && cols[rx]; rx++);
+      for (rx=lx; rx<w && cols[rx]; rx++);
       fprintf(debug," x=%d ctx=%d %d..%d\n",x, ctx, lx,rx);
       debug_flush();
       fprintf(debug," x=%d ctx=%d %d..%d\n",x, ctx, lx,rx);
       debug_flush();
-      callout_unknown(w,h,cols, lx,rx, results,nresults);
+      callout_unknown(w,h,cols, lx,rx-1,ctx, results,nresults);
       goto restart;
     }
   }
       goto restart;
     }
   }
index 0b0b8f553616109d21da2d96a99f70bf33809a1f..142ab42a712555be20539c2ddf014cd1c1d268cc 100755 (executable)
@@ -26,7 +26,10 @@ set gotsh 20
 set csrh 20
 
 proc init_widgets {} {
 set csrh 20
 
 proc init_widgets {} {
+    # idempotent
     global csrh gotsh
     global csrh gotsh
+
+    if {[winfo exists .d]} return
     
     frame .d
 
     
     frame .d
 
@@ -176,6 +179,8 @@ proc startup_cursor {} {
     set cur_0 $unk_l
     set cur_1 [expr {$unk_r+1}]
     set last_ht {}
     set cur_0 $unk_l
     set cur_1 [expr {$unk_r+1}]
     set last_ht {}
+
+    recursor
 }
 
 
 }
 
 
@@ -403,9 +408,11 @@ proc RETURN_RESULT {how what} {
     update idletasks
     puts "$how $what"
     eval update_database/$how $what
     update idletasks
     puts "$how $what"
     eval update_database/$how $what
+    exec kill -STOP [pid]
+    fileevent stdin readable required
 }
 
 }
 
-#    bind . <Key-space> {}
+#---------- main progrm ----------
 
 proc test_main {} {
     global glyphsdone unk_l unk_r unk_context
 
 proc test_main {} {
     global glyphsdone unk_l unk_r unk_context
@@ -427,7 +434,25 @@ proc test_main {} {
     startup_cursor
 }
 
     startup_cursor
 }
 
+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 "SHOW-THING GOT $l"
+
+    fileevent stdin readable {}
+
+    read_xpm stdin
+    draw_glyphsdone
+    startup_cursor
+}
+
 read_database
 read_database
-init_widgets
-test_main
-recursor
+fconfigure stdin -blocking no
+fileevent stdin readable required