Recognize Esc and Tab in ICS Console input
[xboard.git] / xaw / xboard.c
index a083e7c..a944313 100644 (file)
@@ -5,7 +5,7 @@
  * Massachusetts.
  *
  * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
- * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
  *
  * The following terms apply to Digital Equipment Corporation's copyright
  * interest in XBoard:
@@ -183,13 +183,6 @@ extern char *getenv();
 // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
 #include "common.h"
 
-#if HAVE_LIBXPM
-#include <X11/xpm.h>
-#define IMAGE_EXT "xpm"
-#else
-#define IMAGE_EXT "xim"
-#endif
-
 #include "bitmaps/icon_white.bm"
 #include "bitmaps/icon_black.bm"
 #include "bitmaps/checkmark.bm"
@@ -210,6 +203,7 @@ extern char *getenv();
 #include "gettext.h"
 #include "draw.h"
 
+#define SLASH '/'
 
 #ifdef __EMX__
 #ifndef HAVE_USLEEP
@@ -418,7 +412,7 @@ char ICSInputTranslations[] =
 
 // [HGM] vari: another hideous kludge: call extend-end first so we can be sure select-start works,
 //             as the widget is destroyed before the up-click can call extend-end
-char commentTranslations[] = "<Btn3Down>: extend-end() select-start() CommentClick() \n";
+char commentTranslations[] = "<Btn3Down>: extend-end(PRIMARY) select-start() CommentClick() \n";
 
 String xboardResources[] = {
     "*Error*translations: #override\\n <Key>Return: ErrorPopDown()",
@@ -429,128 +423,6 @@ String xboardResources[] = {
 /* Max possible square size */
 #define MAXSQSIZE 256
 
-static int xpm_avail[MAXSQSIZE];
-
-#ifdef HAVE_DIR_STRUCT
-
-/* Extract piece size from filename */
-static int
-xpm_getsize (char *name, int len, char *ext)
-{
-    char *p, *d;
-    char buf[10];
-
-    if (len < 4)
-      return 0;
-
-    if ((p=strchr(name, '.')) == NULL ||
-       StrCaseCmp(p+1, ext) != 0)
-      return 0;
-
-    p = name + 3;
-    d = buf;
-
-    while (*p && isdigit(*p))
-      *(d++) = *(p++);
-
-    *d = 0;
-    return atoi(buf);
-}
-
-/* Setup xpm_avail */
-static int
-xpm_getavail (char *dirname, char *ext)
-{
-    DIR *dir;
-    struct dirent *ent;
-    int  i;
-
-    for (i=0; i<MAXSQSIZE; ++i)
-      xpm_avail[i] = 0;
-
-    if (appData.debugMode)
-      fprintf(stderr, "XPM dir:%s:ext:%s:\n", dirname, ext);
-
-    dir = opendir(dirname);
-    if (!dir)
-      {
-         fprintf(stderr, _("%s: Can't access XPM directory %s\n"),
-                 programName, dirname);
-         exit(1);
-      }
-
-    while ((ent=readdir(dir)) != NULL) {
-       i = xpm_getsize(ent->d_name, NAMLEN(ent), ext);
-       if (i > 0 && i < MAXSQSIZE)
-         xpm_avail[i] = 1;
-    }
-
-    closedir(dir);
-
-    return 0;
-}
-
-void
-xpm_print_avail (FILE *fp, char *ext)
-{
-    int i;
-
-    fprintf(fp, _("Available `%s' sizes:\n"), ext);
-    for (i=1; i<MAXSQSIZE; ++i) {
-       if (xpm_avail[i])
-         printf("%d\n", i);
-    }
-}
-
-/* Return XPM piecesize closest to size */
-int
-xpm_closest_to (char *dirname, int size, char *ext)
-{
-    int i;
-    int sm_diff = MAXSQSIZE;
-    int sm_index = 0;
-    int diff;
-
-    xpm_getavail(dirname, ext);
-
-    if (appData.debugMode)
-      xpm_print_avail(stderr, ext);
-
-    for (i=1; i<MAXSQSIZE; ++i) {
-       if (xpm_avail[i]) {
-           diff = size - i;
-           diff = (diff<0) ? -diff : diff;
-           if (diff < sm_diff) {
-               sm_diff = diff;
-               sm_index = i;
-           }
-       }
-    }
-
-    if (!sm_index) {
-       fprintf(stderr, _("Error: No `%s' files!\n"), ext);
-       exit(1);
-    }
-
-    return sm_index;
-}
-#else  /* !HAVE_DIR_STRUCT */
-/* If we are on a system without a DIR struct, we can't
-   read the directory, so we can't collect a list of
-   filenames, etc., so we can't do any size-fitting. */
-int
-xpm_closest_to (char *dirname, int size, char *ext)
-{
-    fprintf(stderr, _("\
-Warning: No DIR structure found on this system --\n\
-         Unable to autosize for XPM/XIM pieces.\n\
-   Please report this error to %s.\n\
-   Include system type & operating system in message.\n"), PACKAGE_BUGREPORT););
-    return size;
-}
-#endif /* HAVE_DIR_STRUCT */
-
-
 /* Arrange to catch delete-window events */
 Atom wm_delete_window;
 void
@@ -767,6 +639,12 @@ GetActualPlacement (Widget wg, WindowPlacement *wp)
 }
 
 void
+GetPlacement (DialogClass dlg, WindowPlacement *wp)
+{ // wrapper to shield back-end from widget type
+  if(shellUp[dlg]) GetActualPlacement(shells[dlg], wp);
+}
+
+void
 GetWindowCoords ()
 { // wrapper to shield use of window handles from back-end (make addressible by number?)
   // In XBoard this will have to wait until awareness of window parameters is implemented
@@ -934,6 +812,7 @@ PrintArg (ArgType t)
     case ArgString:   p = " STR"; break;
     case ArgBoolean:  p = " TF"; break;
     case ArgSettingsFilename:
+    case ArgBackupSettingsFile:
     case ArgFilename: p = " FILE"; break;
     case ArgX:        p = " Nx"; break;
     case ArgY:        p = " Ny"; break;
@@ -947,6 +826,8 @@ PrintArg (ArgType t)
     case ArgTwo:
     case ArgNone:
     case ArgCommSettings:
+    case ArgMaster:
+    case ArgInstall:
       break;
   }
   return p;
@@ -1084,6 +965,11 @@ PrintOptions ()
   if(len) buf[len] = NULLCHAR, printf("%s\n", buf);
 }
 
+void
+SlaveResize (Option *opt)
+{
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1101,7 +987,7 @@ main (int argc, char **argv)
     debugFP = stderr;
 
     if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) {
-       printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+      printf("%s version %s\n\n  configure options: %s\n", PACKAGE_NAME, PACKAGE_VERSION, CONFIGURE_OPTIONS);
        exit(0);
     }
 
@@ -1110,6 +996,23 @@ main (int argc, char **argv)
        exit(0);
     }
 
+    if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info
+       typedef struct {char *name, *value; } Config;
+       static Config configList[] = {
+         { "Datadir", DATADIR },
+         { "Sysconfdir", SYSCONFDIR },
+         { NULL }
+       };
+       int i;
+
+       for(i=0; configList[i].name; i++) {
+           if(argc > 2 && strcmp(argv[2], configList[i].name)) continue;
+           if(argc > 2) printf("%s", configList[i].value);
+           else printf("%-12s: %s\n", configList[i].name, configList[i].value);
+       }
+       exit(0);
+    }
+
     programName = strrchr(argv[0], '/');
     if (programName == NULL)
       programName = argv[0];