Move MarkMenuItem to xoptions.c
[xboard.git] / menus.c
diff --git a/menus.c b/menus.c
index d5744f7..23e09ea 100644 (file)
--- a/menus.c
+++ b/menus.c
@@ -87,8 +87,6 @@ extern char *getenv();
 
 #include "frontend.h"
 #include "backend.h"
-#include "backendz.h"
-#include "moves.h"
 #include "xhistory.h"
 #include "xedittags.h"
 #include "menus.h"
@@ -256,67 +254,6 @@ QuitProc ()
 }
 
 void
-AnalyzeModeProc ()
-{
-    char buf[MSG_SIZ];
-
-    if (!first.analysisSupport) {
-      snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
-      DisplayError(buf, 0);
-      return;
-    }
-    /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */
-    if (appData.icsActive) {
-        if (gameMode != IcsObserving) {
-         snprintf(buf, MSG_SIZ, _("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;
-        }
-        /* 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"));
-    }
-#ifndef OPTIONSDIALOG
-    if (!appData.showThinking)
-      ShowThinkingProc();
-#endif
-
-    AnalyzeModeEvent();
-}
-
-void
-AnalyzeFileProc ()
-{
-    if (!first.analysisSupport) {
-      char buf[MSG_SIZ];
-      snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
-      DisplayError(buf, 0);
-      return;
-    }
-//    Reset(FALSE, TRUE);
-#ifndef OPTIONSDIALOG
-    if (!appData.showThinking)
-      ShowThinkingProc();
-#endif
-    AnalyzeFileEvent();
-//    FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb");
-    AnalysisPeriodicEvent(1);
-}
-
-void
 MatchProc ()
 {
     MatchEvent(2);
@@ -384,12 +321,6 @@ InfoProc ()
 }
 
 void
-ManProc ()
-{   // called from menu
-    ManInner(NULL, NULL, NULL, NULL);
-}
-
-void
 BugReportProc ()
 {
     char buf[MSG_SIZ];
@@ -703,6 +634,7 @@ MenuItem viewMenu[] = {
     {N_("Tags"),             "Tags", EditTagsProc},
     {N_("Comments"),         "Comments", EditCommentProc},
     {N_("ICS Input Box"),    "ICSInputBox", IcsInputBoxProc},
+    {N_("Open Chat Window"), "OpenChatWindow", ChatProc},
     {"----", NULL, NothingProc},
     {N_("Board..."),          "Board", BoardOptionsProc},
     {N_("Game List Tags..."), "GameListTags", GameListOptionsProc},
@@ -713,8 +645,8 @@ MenuItem modeMenu[] = {
     {N_("Machine White  Ctrl+W"), "MachineWhite", MachineWhiteEvent},
     {N_("Machine Black  Ctrl+B"), "MachineBlack", MachineBlackEvent},
     {N_("Two Machines   Ctrl+T"), "TwoMachines", TwoMachinesEvent},
-    {N_("Analysis Mode  Ctrl+A"), "AnalysisMode", AnalyzeModeProc},
-    {N_("Analyze Game   Ctrl+G"), "AnalyzeFile", AnalyzeFileProc },
+    {N_("Analysis Mode  Ctrl+A"), "AnalysisMode", (MenuProc*) AnalyzeModeEvent},
+    {N_("Analyze Game   Ctrl+G"), "AnalyzeFile", AnalyzeFileEvent },
     {N_("Edit Game         Ctrl+E"), "EditGame", EditGameEvent},
     {N_("Edit Position      Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
     {N_("Training"),      "Training", TrainingEvent},
@@ -747,8 +679,8 @@ MenuItem actionMenu[] = {
 };
 
 MenuItem engineMenu[] = {
-    {N_("Load New 1st Engine ..."), "LoadEngine", LoadEngine1Proc},
-    {N_("Load New 2nd Engine ..."), "LoadEngine", LoadEngine2Proc},
+    {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc},
+    {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc},
     {"----", NULL, NothingProc},
     {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc},
     {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc},
@@ -849,7 +781,7 @@ MenuItem noMenu[] = {
     { "", "TestLegality", TestLegalityProc },
 #endif
     { "", "AboutGame", AboutGameEvent },
-    { "", "Debug", DebugProc },
+    { "", "DebugProc", DebugProc },
     { "", "Nothing", NothingProc },
     {NULL, NULL, NULL}
 };
@@ -869,14 +801,14 @@ Menu menuBar[] = {
 MenuItem *
 MenuNameToItem (char *menuName)
 {
-    int i;
+    int i=0;
     char buf[MSG_SIZ], *p;
     MenuItem *menuTab;
     static MenuItem a = { NULL, NULL, NothingProc };
     extern Option mainOptions[];
     safeStrCpy(buf, menuName, MSG_SIZ);
     p = strchr(buf, '.');
-    if(!p) menuTab = noMenu; else {
+    if(!p) menuTab = noMenu, p = menuName; else {
        *p++ = NULLCHAR;
        for(i=0; menuBar[i].name; i++)
            if(!strcmp(buf, menuBar[i].name)) break;
@@ -926,7 +858,8 @@ Enables icsEnables[] = {
 #endif
     { "Engine.Engine#1Settings", False },
     { "Engine.Engine#2Settings", False },
-    { "Engine.LoadEngine", False },
+    { "Engine.Load1stEngine", False },
+    { "Engine.Load2ndEngine", False },
     { "Edit.Annotate", False },
     { "Options.Match", False },
     { NULL, False }
@@ -944,6 +877,7 @@ Enables ncpEnables[] = {
     { "Mode.ICSClient", False },
     { "View.ICStextmenu", False },
     { "View.ICSInputBox", False },
+    { "View.OpenChatWindow", False },
     { "Action.", False },
     { "Edit.Revert", False },
     { "Edit.Annotate", False },
@@ -970,6 +904,7 @@ Enables gnuEnables[] = {
     { "Mode.ICSClient", False },
     { "View.ICStextmenu", False },
     { "View.ICSInputBox", False },
+    { "View.OpenChatWindow", False },
     { "Action.Accept", False },
     { "Action.Decline", False },
     { "Action.Rematch", False },
@@ -1086,8 +1021,8 @@ SetICSMode ()
 
 #if ZIPPY
   if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
-     EnableMenuItem("Analysis Mode", True);
-     EnableMenuItem("Engine #1 Settings", True);
+     EnableNamedMenuItem("Mode.AnalysisMode", True);
+     EnableNamedMenuItem("Engine.Engine#1Settings", True);
   }
 #endif
 }
@@ -1145,7 +1080,7 @@ SetMachineThinkingEnables ()
   case MachinePlaysBlack:
   case MachinePlaysWhite:
   case TwoMachinesPlay:
-    EnableMenuItem(ModeToWidgetName(gameMode), True);
+    EnableNamedMenuItem(ModeToWidgetName(gameMode), True);
     break;
   default:
     break;