Add -useBoardTexture and -usePieceFont options
[xboard.git] / xboard.c
index dae38f2..033c53b 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -1051,6 +1051,8 @@ char globalTranslations[] =
    :Ctrl<Key>o: LoadGameProc() \n \
    :Meta<Key>Next: LoadNextGameProc() \n \
    :Meta<Key>Prior: LoadPrevGameProc() \n \
+   :Ctrl<Key>Down: LoadSelectedProc(3) \n \
+   :Ctrl<Key>Up: LoadSelectedProc(-3) \n \
    :Ctrl<Key>s: SaveGameProc() \n \
    :Ctrl<Key>c: CopyGameProc() \n \
    :Ctrl<Key>v: PasteGameProc() \n \
@@ -1087,6 +1089,8 @@ char globalTranslations[] =
    :Meta<Key>Right: ForwardProc() \n \
    :Meta<Key>Home: ToStartProc() \n \
    :Meta<Key>Left: BackwardProc() \n \
+   :<Key>Left: BackwardProc() \n \
+   :<Key>Right: ForwardProc() \n \
    :<Key>Home: RevertProc() \n \
    :<Key>End: TruncateGameProc() \n \
    :Ctrl<Key>m: MoveNowProc() \n \
@@ -1130,8 +1134,12 @@ char boardTranslations[] =
    Any<Btn3Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD) \
                  PieceMenuPopup(menuB) \n";
 
-char whiteTranslations[] = "<BtnDown>: WhiteClock()\n";
-char blackTranslations[] = "<BtnDown>: BlackClock()\n";
+char whiteTranslations[] =
+   "Shift<BtnDown>: WhiteClock(1)\n \
+   <BtnDown>: WhiteClock(0)\n";
+char blackTranslations[] =
+   "Shift<BtnDown>: BlackClock(1)\n \
+   <BtnDown>: BlackClock(0)\n";
 
 char ICSInputTranslations[] =
     "<Key>Up: UpKeyProc() \n "
@@ -2693,6 +2701,8 @@ XBoard square size (hint): %d\n\
     return 0;
 }
 
+static Boolean noEcho;
+
 void
 ShutDownFrontEnd()
 {
@@ -2702,6 +2712,7 @@ ShutDownFrontEnd()
     if (saveSettingsOnExit) SaveSettings(settingsFileName);
     unlink(gameCopyFilename);
     unlink(gamePasteFilename);
+    if(noEcho) EchoOn();
 }
 
 RETSIGTYPE TermSizeSigHandler(int sig)
@@ -3590,7 +3601,7 @@ void CreateXPMBoard(char *s, int kind)
 {
     XpmAttributes attr;
     attr.valuemask = 0;
-    if(s == NULL || *s == 0 || *s == '*') { useTexture &= ~(kind+1); return; }
+    if(!appData.useBitmaps || s == NULL || *s == 0 || *s == '*') { useTexture &= ~(kind+1); return; }
     if (XpmReadFileToPixmap(xDisplay, xBoardWindow, s, &(xpmBoardBitmap[kind]), NULL, &attr) == 0) {
        useTexture |= kind + 1; textureW[kind] = attr.width; textureH[kind] = attr.height;
     }
@@ -4138,6 +4149,7 @@ void WhiteClock(w, event, prms, nprms)
      String *prms;
      Cardinal *nprms;
 {
+    shiftKey = prms[0][0] & 1;
     ClockClick(0);
 }
 
@@ -4147,6 +4159,7 @@ void BlackClock(w, event, prms, nprms)
      String *prms;
      Cardinal *nprms;
 {
+    shiftKey = prms[0][0] & 1;
     ClockClick(1);
 }
 
@@ -4990,6 +5003,14 @@ void CommentPopDown()
     PopDown(1);
 }
 
+static char *openName;
+FILE *openFP;
+
+void DelayedLoad()
+{
+  (void) (*fileProc)(openFP, 0, openName);
+}
+
 void FileNamePopUp(label, def, filter, proc, openMode)
      char *label;
      char *def;
@@ -5000,12 +5021,11 @@ void FileNamePopUp(label, def, filter, proc, openMode)
     fileProc = proc;           /* I can't see a way not */
     fileOpenMode = openMode;   /*   to use globals here */
     {   // [HGM] use file-selector dialog stolen from Ghostview
-       char *name;
        int index; // this is not supported yet
-       FILE *f;
-       if(f = XsraSelFile(shellWidget, label, NULL, NULL, "could not open: ",
-                          (def[0] ? def : NULL), filter, openMode, NULL, &name))
-         (void) (*fileProc)(f, index=0, name);
+       if(openFP = XsraSelFile(shellWidget, label, NULL, NULL, "could not open: ",
+                          (def[0] ? def : NULL), filter, openMode, NULL, &openName))
+         // [HGM] delay to give expose event opportunity to redraw board after browser-dialog popdown before lengthy load starts
+         ScheduleDelayedEvent(&DelayedLoad, 50);
     }
 }
 
@@ -5733,8 +5753,6 @@ SendGameSelection(Widget w, Atom *selection, Atom *target,
 
 void CopySomething()
 {
-  int ret;
-
   /*
    * Set both PRIMARY (the selection) and CLIPBOARD, since we don't
    * have a notion of a game that is selected but not copied.
@@ -6936,6 +6954,7 @@ void DisplayTitle(text)
     XtSetArg(args[i], XtNiconName, (XtArgVal) icon);    i++;
     XtSetArg(args[i], XtNtitle, (XtArgVal) title);      i++;
     XtSetValues(shellWidget, args, i);
+    XSync(xDisplay, False);
 }
 
 
@@ -7233,12 +7252,14 @@ void
 EchoOn()
 {
     system("stty echo");
+    noEcho = False;
 }
 
 void
 EchoOff()
 {
     system("stty -echo");
+    noEcho = True;
 }
 
 void
@@ -7741,7 +7762,7 @@ int OpenTCP(host, port, pr)
     struct addrinfo hints;
     struct addrinfo *ais, *ai;
     int error;
-    int s;
+    int s=0;
     ChildProc *cp;
 
     memset(&hints, 0, sizeof(hints));
@@ -8639,8 +8660,8 @@ AnimateMove(board, fromX, fromY, toX, toY)
 }
 
 void
-DragPieceBegin(x, y)
-     int x; int y;
+DragPieceBegin(x, y, instantly)
+     int x; int y; Boolean instantly;
 {
     int         boardX, boardY, color;
     XPoint corner;