fixed hardcoded location of config file for xboard
[xboard.git] / xboard.c
index 3c4d8d7..8106b9c 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -49,6 +49,8 @@
  *------------------------------------------------------------------------
  ** See the file ChangeLog for a revision history.  */
 
+#define HIGHDRAG 1
+
 #include "config.h"
 
 #include <stdio.h>
@@ -256,6 +258,8 @@ void HandleUserMove P((Widget w, XEvent *event,
                     String *prms, Cardinal *nprms));
 void AnimateUserMove P((Widget w, XEvent * event,
                     String * params, Cardinal * nParams));
+void HandlePV P((Widget w, XEvent * event,
+                    String * params, Cardinal * nParams));
 void WhiteClock P((Widget w, XEvent *event,
                   String *prms, Cardinal *nprms));
 void BlackClock P((Widget w, XEvent *event,
@@ -448,6 +452,7 @@ void NewVariantPopDown P(());
 void SettingsPopDown P(());
 void update_ics_width P(());
 int get_term_width P(());
+int CopyMemoProc P(());
 /*
 * XBoard depends on Xt R4 or higher
 */
@@ -831,6 +836,8 @@ XtActionsRec boardActions[] = {
     { "DrawPosition", DrawPositionProc },
     { "HandleUserMove", HandleUserMove },
     { "AnimateUserMove", AnimateUserMove },
+    { "HandlePV", HandlePV },
+    { "UnLoadPV", UnLoadPV },
     { "FileNameAction", FileNameAction },
     { "AskQuestionProc", AskQuestionProc },
     { "AskQuestionReplyAction", AskQuestionReplyAction },
@@ -954,6 +961,7 @@ XtActionsRec boardActions[] = {
     { "TimeControlPopDown", (XtActionProc) TimeControlPopDown },
     { "NewVariantPopDown", (XtActionProc) NewVariantPopDown },
     { "SettingsPopDown", (XtActionProc) SettingsPopDown },
+    { "CopyMemoProc", (XtActionProc) CopyMemoProc },
 };
 
 char globalTranslations[] =
@@ -986,6 +994,8 @@ char boardTranslations[] =
    "<Btn1Down>: HandleUserMove() \n \
    <Btn1Up>: HandleUserMove() \n \
    <Btn1Motion>: AnimateUserMove() \n \
+   <Btn3Motion>: HandlePV() \n \
+   <Btn3Up>: UnLoadPV() \n \
    Shift<Btn2Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD)\
                  PieceMenuPopup(menuB) \n \
    Any<Btn2Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD) \
@@ -1256,7 +1266,6 @@ BoardToTop()
 #define SEPCHAR " "
 
 // these two must some day move to frontend.h, when they are implemented
-Boolean MoveHistoryIsUp();
 Boolean GameListIsUp();
 
 // The option definition and parsing code common to XBoard and WinBoard is collected in this file
@@ -1275,7 +1284,7 @@ colorVariable[] = {
   &appData.darkSquareColor, 
   &appData.highlightSquareColor,
   &appData.premoveHighlightColor,
-  NULL,
+  &appData.lowTimeWarningColor,
   NULL,
   NULL,
   NULL,
@@ -1665,6 +1674,11 @@ main(argc, argv)
     setbuf(stderr, NULL);
     debugFP = stderr;
 
+    if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) {
+       printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+       exit(0);
+    }
+
     programName = strrchr(argv[0], '/');
     if (programName == NULL)
       programName = argv[0];
@@ -3666,6 +3680,8 @@ void PieceMenuPopup(w, event, params, num_params)
      Cardinal *num_params;
 {
     String whichMenu;
+
+    if (event->type != ButtonRelease) UnLoadPV(); // [HGM] pv
     if (event->type != ButtonPress) return;
     if (errorUp) ErrorPopDown();
     switch (gameMode) {
@@ -3673,12 +3689,25 @@ void PieceMenuPopup(w, event, params, num_params)
       case IcsExamining:
        whichMenu = params[0];
        break;
+      case IcsObserving:
+       if(!appData.icsEngineAnalyze) return;
       case IcsPlayingWhite:
       case IcsPlayingBlack:
-      case EditGame:
+       if(!appData.zippyPlay) goto noZip;
+      case AnalyzeMode:
+      case AnalyzeFile:
       case MachinePlaysWhite:
       case MachinePlaysBlack:
-       if (appData.testLegality &&
+      case TwoMachinesPlay: // [HGM] pv: use for showing PV
+       if (!appData.dropMenu) {
+         LoadPV(event->xbutton.x, event->xbutton.y);
+         return;
+       }
+       if(gameMode == TwoMachinesPlay || gameMode == AnalyzeMode ||
+           gameMode == AnalyzeFile || gameMode == IcsObserving) return;
+      case EditGame:
+      noZip:
+       if (!appData.dropMenu || appData.testLegality &&
            gameInfo.variant != VariantBughouse &&
            gameInfo.variant != VariantCrazyhouse) return;
        SetupDropMenu();
@@ -4170,6 +4199,10 @@ void DrawSquare(row, column, piece, do_flash)
                        x + 2, y + font_ascent + 1, string, 1);
        }
     }
+    if(marker[row][column]) {
+       XFillArc(xDisplay, xBoardWindow, marker[row][column] == 2 ? prelineGC : highlineGC, 
+               x + squareSize/4, y+squareSize/4, squareSize/2, squareSize/2, 0, 64*360);
+    }
 }
 
 
@@ -4423,6 +4456,12 @@ void AnimateUserMove (Widget w, XEvent * event,
     DragPieceMove(event->xmotion.x, event->xmotion.y);
 }
 
+void HandlePV (Widget w, XEvent * event,
+                     String * params, Cardinal * nParams)
+{   // [HGM] pv: walk PV
+    MovePV(event->xmotion.x, event->xmotion.y, lineGap + BOARD_HEIGHT * (squareSize + lineGap));
+}
+
 Widget CommentCreate(name, text, mutable, callback, lines)
      char *name, *text;
      int /*Boolean*/ mutable;
@@ -5515,9 +5554,9 @@ void MailMoveProc(w, event, prms, nprms)
 }
 
 /* this variable is shared between CopyPositionProc and SendPositionSelection */
-static char *selected_fen_position=NULL;
+char *selected_fen_position=NULL;
 
-static Boolean
+Boolean
 SendPositionSelection(Widget w, Atom *selection, Atom *target,
                 Atom *type_return, XtPointer *value_return,
                 unsigned long *length_return, int *format_return)
@@ -8599,7 +8638,7 @@ DragPieceMove(x, y)
     corner.x = x - player.mouseDelta.x;
     corner.y = y - player.mouseDelta.y;
     AnimationFrame(&player, &corner, player.dragPiece);
-#if HIGHDRAG
+#if HIGHDRAG*0
     if (appData.highlightDragging) {
        int boardX, boardY;
        BoardSquare(x, y, &boardX, &boardY);