cleaned up the directory a bit. Removed winboard-dm-beta, merged the two Changelogs...
[xboard.git] / xboard.c
index e31a7a6..3698728 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -1147,6 +1147,10 @@ XtResource clientResources[] = {
     { "showButtonBar", "showButtonBar", XtRBoolean,
        sizeof(Boolean), XtOffset(AppDataPtr, showButtonBar),
        XtRImmediate, (XtPointer) True },
+       /* icsEngineAnalyze */
+    {"icsEngineAnalyze", "icsEngineAnalyze", XtRBoolean,
+       sizeof(Boolean), XtOffset(AppDataPtr, icsEngineAnalyze),
+       XtRImmediate, (XtPointer) False },
 };
 
 XrmOptionDescRec shellOptions[] = {
@@ -1869,6 +1873,7 @@ main(argc, argv)
 #ifdef ENABLE_NLS
     XtSetLanguageProc(NULL, NULL, NULL);
     bindtextdomain(PRODUCT, LOCALEDIR);
+    bind_textdomain_codeset(PRODUCT, "UTF-8");
     textdomain(PRODUCT);
 #endif
 
@@ -1903,7 +1908,15 @@ main(argc, argv)
     XtGetApplicationResources(shellWidget, (XtPointer) &appData,
                              clientResources, XtNumber(clientResources),
                              NULL, 0);
-
+                             
+    if (appData.debugMode) {
+       if ((debugFP = fopen("xboard.debug", "w")) == NULL)  {
+          printf(_("Failed to open file xboard.debug \n"));
+          exit(errno);
+       }
+        setbuf(debugFP, NULL);
+    }
+    
 #if !HIGHDRAG
     /* This feature does not work; animation needs a rewrite */
     appData.highlightDragging = FALSE;
@@ -2549,6 +2562,8 @@ XBoard square size (hint): %d\n\
     }
 
     XtAppMainLoop(appContext);
+    if (appData.debugMode) fclose(debugFP);
+    
     return 0;
 }
 
@@ -2802,6 +2817,12 @@ Enables userThinkingEnables[] = {
 void SetICSMode()
 {
   SetMenuEnables(icsEnables);
+
+ #ifdef ZIPPY
+  /* icsEngineAnalyze */
+  if (appData.zippyPlay && !appData.noChessProgram) 
+     XtSetSensitive(XtNameToWidget(menuBarWidget, "menuMode.Analysis Mode"), True);
+ #endif
 }
 
 void
@@ -5019,6 +5040,8 @@ void AnalysisPopDown()
     XtPopdown(analysisShell);
     XSync(xDisplay, False);
     analysisUp = False;
+    /* icsEngineAnalyze */
+    if (appData.icsEngineAnalyze) ExitAnalyzeMode();
 }
 
 
@@ -5029,7 +5052,7 @@ void FileNamePopUp(label, def, proc, openMode)
      char *openMode;
 {
     Arg args[16];
-    Widget popup, layout, dialog, edit, b_ok, b_cancel;
+    Widget popup, layout, dialog, edit;
     Window root, child;
     int x, y, i;
     int win_x, win_y;
@@ -5472,7 +5495,6 @@ void ModeHighlight()
                   gameMode == Training || gameMode == PlayFromGameFile);
 }
 
-
 /*
  * Button/menu procedures
  */
@@ -5853,15 +5875,41 @@ void AnalyzeModeProc(w, event, prms, nprms)
      String *prms;
      Cardinal *nprms;
 {
+    char buf[MSG_SIZ];
+    
     if (!first.analysisSupport) {
-      char buf[MSG_SIZ];
       sprintf(buf, _("%s does not support analysis"), first.tidy);
       DisplayError(buf, 0);
       return;
     }
+    /* icsEngineAnalyze */
+    if (appData.icsActive) {
+      if (gameMode != IcsObserving) {
+        sprintf(buf,_("You are not observing a game"));
+       DisplayError(buf, 0);
+       /* secure check */
+       if (appData.icsEngineAnalyze) {
+         if (appData.debugMode)
+           fprintf(debugFP, _("Found unexpected active ICS engine analyze \n"));
+           ExitAnalyzeMode();
+           ModeHighlight();
+           return;
+       }
+       return;
+     } else {
+        /* if enable, use want disable icsEngineAnalyze */
+       if (appData.icsEngineAnalyze) {
+          ExitAnalyzeMode();
+          ModeHighlight();
+          return;
+        }
+        appData.icsEngineAnalyze = TRUE;
+        if (appData.debugMode)
+          fprintf(debugFP, "ICS engine analyze starting... \n");
+      }
+   }   
     if (!appData.showThinking)
       ShowThinkingProc(w,event,prms,nprms);
-
     AnalyzeModeEvent();
 }
 
@@ -7323,7 +7371,8 @@ AnalysisClockCallback(arg, id)
      XtPointer arg;
      XtIntervalId *id;
 {
-    if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
+    if (gameMode == AnalyzeMode || gameMode == AnalyzeFile 
+         || appData.icsEngineAnalyze) {
        AnalysisPeriodicEvent(0);
        StartAnalysisClock();
     }