chiark / gitweb /
Cope with big fonts and commodities
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 26 Jun 2009 21:15:38 +0000 (22:15 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 26 Jun 2009 21:15:38 +0000 (22:15 +0100)
pctb/pages.c
pctb/structure.c

index ca2428d874d9a7b87ee0f3b231fc8f37bb7594c8..8914bd64fa82d01b3283eeb2fcfb1e98df623f0e 100644 (file)
@@ -543,6 +543,7 @@ timestamp();
   send_key(XK_w);
   send_key(XK_Return);
   sync_after_input();
   send_key(XK_w);
   send_key(XK_Return);
   sync_after_input();
+  sysassert(! usleep(1000000) );
 }
 
 void take_screenshots(void) {
 }
 
 void take_screenshots(void) {
@@ -694,7 +695,7 @@ void find_yppclient_window(void) {
 
 #define ASSIGN(what, start, end)                               \
        what= masprintf("%.*s", (end)-(start), start);          \
 
 #define ASSIGN(what, start, end)                               \
        what= masprintf("%.*s", (end)-(start), start);          \
-       if (o_##what) REQUIRE( !strcmp(o_##what, what) );       \
+       if (o_##what) REQUIRE( !strcasecmp(o_##what, what) );   \
        else
 
        ASSIGN(ocean,  spc1 + S(onthe),   (title + len) - S(suffix));
        else
 
        ASSIGN(ocean,  spc1 + S(onthe),   (title + len) - S(suffix));
@@ -712,8 +713,9 @@ void find_yppclient_window(void) {
     if (children1) XFree(children1);
   }
   if (nfound>1)
     if (children1) XFree(children1);
   }
   if (nfound>1)
-    fatal("Found several possible YPP clients."
-         " Close one, or specify the windowid with --window-id.\n");
+    fatal("Found several possible YPP clients.   Close one,\n"
+         " disambiguate with --pirate or --ocean,"
+         " or specify --window-id.\n");
   if (nfound<1)
     fatal("Did not find %sYPP client."
          " Use --window-id and/or report this as a fault.\n",
   if (nfound<1)
     fatal("Did not find %sYPP client."
          " Use --window-id and/or report this as a fault.\n",
index 0bc3be1f5c5287172df9eb75d9b6b22f763bc717..66a669e5ae5d6ba30332c68676c2d6ba8a33a956 100644 (file)
@@ -34,7 +34,7 @@ static inline char get_p(Point p) { return get(p.x,p.y); }
 
 DEBUG_DEFINE_DEBUGF(struct)
 
 
 DEBUG_DEFINE_DEBUGF(struct)
 
-#define START_MAIN {200,100}
+#define START_MAIN {200,200}
 #define MIN_COLUMNS         6
 #define INTERESTING_COLUMNS 7
 #define TEXT_COLUMNS        2
 #define MIN_COLUMNS         6
 #define INTERESTING_COLUMNS 7
 #define TEXT_COLUMNS        2
@@ -156,6 +156,32 @@ static void debug_rect(const char *what, int whati, Rect rr) {
   debug_flush();
 }
 
   debug_flush();
 }
 
+static int commod_selector_matches(Rect search, const char *const *all,
+                                  int allh, int allw) {
+  int alloffy, alloffx;
+  for (alloffy=0; alloffy < search.br.y; alloffy++) {
+    if (alloffy+allh-1 < search.tl.y) continue;
+    for (alloffx=search.tl.x; alloffx+allw-1 <= search.br.x; alloffx++) {
+      int good=0, bad=0;
+      int x,y;
+      for (x=0; x<allw; x++)
+       for (y=0; y<allh; y++) {
+         int want= all[y][x];
+         if (want==' ') continue;
+          if (get(alloffx+x, alloffy+y) == want)
+           good++;
+         else
+           bad++;
+       }
+      debugf("CHECKCOMMOD alloff=%d,%d good=%d bad=%d\n",
+            alloffx,alloffy, good,bad);
+      if (good > 20*bad)
+       return 1;
+    }
+  }
+  return 0;
+}
+
 #define WALK_UNTIL(point,coord,increm,last,edge)                       \
   for (;;) {                                                           \
     if ((point).coord == (last)+(increm)) break;                       \
 #define WALK_UNTIL(point,coord,increm,last,edge)                       \
   for (;;) {                                                           \
     if ((point).coord == (last)+(increm)) break;                       \
@@ -290,7 +316,7 @@ void check_correct_commodities(void) {
 
   debug_rect("commodselr",1, search);
 
 
   debug_rect("commodselr",1, search);
 
-  static const char *all[]= {
+  static const char *all_small[]= {
     "   ___________________________________   ",
     "  ________X____X__X____________________  ",
     " ________ X___ X_ X_____XXXXXXXXXXX_____ ",
     "   ___________________________________   ",
     "  ________X____X__X____________________  ",
     " ________ X___ X_ X_____XXXXXXXXXXX_____ ",
@@ -303,34 +329,30 @@ void check_correct_commodities(void) {
     "  ____X_____ _XX_ X______________________",
     "   __ _______  __ ______________________ ",
   };
     "  ____X_____ _XX_ X______________________",
     "   __ _______  __ ______________________ ",
   };
+  static const char *all_big[]= {
+    "???_______________________________________???",
+    "??_________________________________________??",
+    "?_________X______X___X______________________?",
+    "_________?X_____?X__?X______XXXXXXXXXXX______",
+    "_________X_X____?X__?X_______XXXXXXXXX_______",
+    "________?X?X____?X__?X________XXXXXXX________",
+    "________X_?_X___?X__?X_________XXXXX_________",
+    "_______?X__?X___?X__?X__________XXX__________",
+    "_______?XXXXX___?X__?X___________X___________",
+    "_______X????_X__?X__?X_______________________",
+    "?_____?X____?X__?X__?X_______________________",
+    "??____X_____?_X_?X__?X_______________________",
+    "???__?_______?__?___?_______________________?",
+  };
 
 
-  static int allh= sizeof(all)/sizeof(all[0]);
-  const int allw= strlen(all[0]);
-
-  int alloffy, alloffx;
-  for (alloffy=0; alloffy < search.br.y; alloffy++) {
-    if (alloffy+allh-1 < search.tl.y) continue;
-    for (alloffx=search.tl.x; alloffx+allw-1 <= search.br.x; alloffx++) {
-      int good=0, bad=0;
-      int x,y;
-      for (x=0; x<allw; x++)
-       for (y=0; y<allh; y++) {
-         int want= all[y][x];
-         if (want==' ') continue;
-          if (get(alloffx+x, alloffy+y) == want)
-           good++;
-         else
-           bad++;
-       }
-      debugf("CHECKCOMMOD alloff=%d,%d good=%d bad=%d\n",
-            alloffx,alloffy, good,bad);
-      if (good > 20*bad)
-       goto all_found;
-    }
-  }
-  fatal("Commodities selector not set to `All'.");
+#define COMMOD_SELECTOR_MATCHES(all)                           \
+  commod_selector_matches(search, all,                         \
+                         sizeof((all))/sizeof((all)[0]),       \
+                         strlen((all)[0]))
 
 
- all_found:;
+  if (!(COMMOD_SELECTOR_MATCHES(all_small) ||
+       COMMOD_SELECTOR_MATCHES(all_big)))
+    fatal("Commodities selector not set to `All'.");
 }
 
 CanonImage *alloc_canon_image(int w, int h) {
 }
 
 CanonImage *alloc_canon_image(int w, int h) {