Scale texture bitmaps that are not large enough
[xboard.git] / xaw / xboard.c
index ac57033..a557b41 100644 (file)
@@ -204,6 +204,7 @@ extern char *getenv();
 #include "draw.h"
 
 #define SLASH '/'
+#define DATADIR "~~"
 
 #ifdef __EMX__
 #ifndef HAVE_USLEEP
@@ -496,7 +497,8 @@ ParseFont (char *name, int number)
   if(sscanf(name, "size%d:", &size)) {
     // [HGM] font: font is meant for specific boardSize (likely from settings file);
     //       defer processing it until we know if it matches our board size
-    if(size >= 0 && size<MAX_SIZE) { // for now, fixed limit
+    if(strstr(name, "-*-") &&        // only pay attention to things that look like X-fonts
+       size >= 0 && size<MAX_SIZE) { // for now, fixed limit
        fontTable[number][size] = strdup(strchr(name, ':')+1);
        fontValid[number][size] = True;
     }
@@ -534,7 +536,7 @@ CreateFonts ()
 void
 ParseColor (int n, char *name)
 { // in XBoard, just copy the color-name string
-  if(colorVariable[n]) *(char**)colorVariable[n] = strdup(name);
+  if(colorVariable[n] && *name == '#') *(char**)colorVariable[n] = strdup(name);
 }
 
 char *
@@ -843,17 +845,18 @@ char *
 GenerateGlobalTranslationTable (void)
 {
   /* go through all menu items and extract the keyboard shortcuts, so that X11 can load them */
-  char *output;
+  char *output[2];
 
-  int i,j;
+  int i,j,n=0;
   MenuItem *mi;
 
-  output = strdup("");
+  output[0] = strdup(""); // build keystrokes with and wo mod keys separately
+  output[1] = strdup(""); // so the more specific can preceed the other
 
   /* loop over all menu entries */
-  for( i=0; menuBar[i].mi ; i++)
+  for( i=0; menuBar[i-n].mi || !n++; i++)
     {
-      mi = menuBar[i].mi;
+      mi = menuBar[i+n].mi; // kludge to access 'noMenu' behind sentinel
       for(j=0; mi[j].proc; j++)
        {
          if (mi[j].accel)
@@ -918,17 +921,16 @@ GenerateGlobalTranslationTable (void)
                mods[strlen(mods)-1]='\0';
 
              /* get the name for the callback, we can use MenuItem() here that will call KeyBindingProc */
-             size_t namesize = snprintf(NULL, 0, "%s.%s", menuBar[i].ref, mi[j].ref);
-             char *name = malloc(namesize+1);
-             snprintf(name, namesize+1, "%s.%s", menuBar[i].ref, mi[j].ref);
+             char *name = malloc(MSG_SIZ);
+             if(n) snprintf(name, MSG_SIZ, "%s", mi[j].ref);
+             else  snprintf(name, MSG_SIZ, "%s.%s", menuBar[i].ref, mi[j].ref);
 
-             size_t buffersize = snprintf(NULL, 0, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
-             char *buffer = malloc(buffersize+1);
-             snprintf(buffer, buffersize+1, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
+             char *buffer = malloc(MSG_SIZ);
+             snprintf(buffer, MSG_SIZ, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
 
              /* add string to the output */
-             output = realloc(output, strlen(output) + strlen(buffer)+1);
-             strncat(output, buffer, strlen(buffer));
+             output[shift|alt|ctrl] = realloc(output[shift|alt|ctrl], strlen(output[shift|alt|ctrl]) + strlen(buffer)+1);
+             strncat(output[shift|alt|ctrl], buffer, strlen(buffer));
 
              /* clean up */
              free(key);
@@ -938,7 +940,10 @@ GenerateGlobalTranslationTable (void)
            }
        }
     }
-  return output;
+  output[1] = realloc(output[1], strlen(output[1]) + strlen(output[0])+1);
+  strncat(output[1], output[0], strlen(output[0]));
+  free(output[0]);
+  return output[1];
 }
 
 
@@ -986,6 +991,9 @@ main (int argc, char **argv)
     char *p;
     int forceMono = False;
 
+    extern Option chatOptions[]; // FIXME: adapt Chat window, removing ICS pane and Hide button
+    chatOptions[6].type = chatOptions[10].type = Skip;
+
     srandom(time(0)); // [HGM] book: make random truly random
 
     setbuf(stdout, NULL);
@@ -1280,7 +1288,7 @@ main (int argc, char **argv)
 
     CatchDeleteWindow(shellWidget, "QuitProc");
 
-    CreateAnyPieces();
+    CreateAnyPieces(1);
     CreateGrid();
 
     if(appData.logoSize)
@@ -1352,6 +1360,13 @@ main (int argc, char **argv)
     return 0;
 }
 
+void
+DoEvents ()
+{
+    XtInputMask m;
+    while((m = XtAppPending(appContext))) XtAppProcessEvent(appContext, m);
+}
+
 RETSIGTYPE
 TermSizeSigHandler (int sig)
 {
@@ -2487,7 +2502,7 @@ LoadLogo (ChessProgramState *cps, int n, Boolean ics)
     } else if(appData.autoLogo) {
        if(ics) { // [HGM] logo: in ICS mode second can be used for ICS
            sprintf(buf, "%s/%s.png", appData.logoDir, appData.icsHost);
-       } else if(appData.directory[n] && appData.directory[n][0]) {
+       } else if(appData.logoDir && appData.logoDir[0]) {
            sprintf(buf, "%s/%s.png", appData.logoDir, cps->tidy);
        }
     }