2 * menus.c -- platform-indendent menu handling code for XBoard
4 * Copyright 1991 by Digital Equipment Corporation, Maynard,
7 * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
8 * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
10 * The following terms apply to Digital Equipment Corporation's copyright
12 * ------------------------------------------------------------------------
15 * Permission to use, copy, modify, and distribute this software and its
16 * documentation for any purpose and without fee is hereby granted,
17 * provided that the above copyright notice appear in all copies and that
18 * both that copyright notice and this permission notice appear in
19 * supporting documentation, and that the name of Digital not be
20 * used in advertising or publicity pertaining to distribution of the
21 * software without specific, written prior permission.
23 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
25 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
26 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
30 * ------------------------------------------------------------------------
32 * The following terms apply to the enhanced version of XBoard
33 * distributed by the Free Software Foundation:
34 * ------------------------------------------------------------------------
36 * GNU XBoard is free software: you can redistribute it and/or modify
37 * it under the terms of the GNU General Public License as published by
38 * the Free Software Foundation, either version 3 of the License, or (at
39 * your option) any later version.
41 * GNU XBoard is distributed in the hope that it will be useful, but
42 * WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 * General Public License for more details.
46 * You should have received a copy of the GNU General Public License
47 * along with this program. If not, see http://www.gnu.org/licenses/. *
49 *------------------------------------------------------------------------
50 ** See the file ChangeLog for a revision history. */
60 #include <sys/types.h>
68 #else /* not STDC_HEADERS */
69 extern char *getenv();
72 # else /* not HAVE_STRING_H */
74 # endif /* not HAVE_STRING_H */
75 #endif /* not STDC_HEADERS */
85 // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
93 #include "xedittags.h"
98 # define _(s) gettext (s)
99 # define N_(s) gettext_noop (s)
106 * Button/menu procedures
109 char *gameCopyFilename, *gamePasteFilename;
110 Boolean saveSettingsOnExit;
111 char *settingsFileName;
114 LoadGamePopUp (FILE *f, int gameNumber, char *title)
116 cmailMsgLoaded = FALSE;
117 if (gameNumber == 0) {
118 int error = GameListBuild(f);
120 DisplayError(_("Cannot build game list"), error);
121 } else if (!ListEmpty(&gameList) &&
122 ((ListGame *) gameList.tailPred)->number > 1) {
123 GameListPopUp(f, title);
129 return LoadGame(f, gameNumber, title, FALSE);
135 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
138 FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb");
160 LoadNextPositionProc ()
166 LoadPrevPositionProc ()
172 ReloadPositionProc ()
180 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
183 FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
189 FileNamePopUp(_("Save game file name?"),
190 DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
191 appData.oldSaveStyle ? ".game" : ".pgn",
198 FileNamePopUp(_("Save position file name?"),
199 DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
200 appData.oldSaveStyle ? ".pos" : ".fen",
205 ReloadCmailMsgProc ()
207 ReloadCmailMsgEvent(FALSE);
211 CopyFENToClipboard ()
212 { // wrapper to make call from back-end possible
219 static char *selected_fen_position=NULL;
220 if(gameMode == EditPosition) EditPositionDone(TRUE);
221 if (selected_fen_position) free(selected_fen_position);
222 selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
223 if (!selected_fen_position) return;
224 CopySomething(selected_fen_position);
232 ret = SaveGameToFile(gameCopyFilename, FALSE);
241 if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
263 if (!first.analysisSupport) {
264 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
265 DisplayError(buf, 0);
268 /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */
269 if (appData.icsActive) {
270 if (gameMode != IcsObserving) {
271 snprintf(buf, MSG_SIZ, _("You are not observing a game"));
272 DisplayError(buf, 0);
274 if (appData.icsEngineAnalyze) {
275 if (appData.debugMode)
276 fprintf(debugFP, _("Found unexpected active ICS engine analyze \n"));
282 /* if enable, use want disable icsEngineAnalyze */
283 if (appData.icsEngineAnalyze) {
288 appData.icsEngineAnalyze = TRUE;
289 if (appData.debugMode)
290 fprintf(debugFP, _("ICS engine analyze starting... \n"));
292 #ifndef OPTIONSDIALOG
293 if (!appData.showThinking)
303 if (!first.analysisSupport) {
305 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
306 DisplayError(buf, 0);
309 // Reset(FALSE, TRUE);
310 #ifndef OPTIONSDIALOG
311 if (!appData.showThinking)
315 // FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb");
316 AnalysisPeriodicEvent(1);
328 UserAdjudicationEvent(+1);
334 UserAdjudicationEvent(-1);
340 UserAdjudicationEvent(0);
358 if(twoBoards) { partnerUp = 1; DrawPosition(True, NULL); partnerUp = 0; }
359 flipView = !flipView;
360 DrawPosition(True, NULL);
366 saveSettingsOnExit = !saveSettingsOnExit;
368 MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
374 SaveSettings(settingsFileName);
381 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
390 snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen);
398 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
406 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
414 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
421 char buf[2 * MSG_SIZ];
423 char *zippy = _(" (with Zippy code)");
427 snprintf(buf, sizeof(buf),
429 "Copyright 1991 Digital Equipment Corporation\n"
430 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
431 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
432 "%s is free software and carries NO WARRANTY;"
433 "see the file COPYING for more information.\n\n"
434 "Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
435 "Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
436 "Report bugs via email at: <bug-xboard@gnu.org>\n\n"
438 programVersion, zippy, PACKAGE);
439 ErrorPopUp(_("About XBoard"), buf, FALSE);
445 appData.debugMode = !appData.debugMode;
446 if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed
447 if(!appData.debugMode) fclose(debugFP);
449 debugFP = fopen(appData.nameOfDebugFile, "w");
450 if(debugFP == NULL) debugFP = stderr;
451 else setbuf(debugFP, NULL);
462 # define MARK_MENU_ITEM(X,Y)
464 # define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
468 PonderNextMoveProc ()
470 PonderNextMoveEvent(!appData.ponderNextMove);
471 MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
477 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
478 MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen);
482 AnimateDraggingProc ()
484 appData.animateDragging = !appData.animateDragging;
486 if (appData.animateDragging) CreateAnimVars();
487 MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging);
493 appData.animate = !appData.animate;
494 if (appData.animate) CreateAnimVars();
495 MARK_MENU_ITEM("Options.AnimateMoving", appData.animate);
501 appData.autoCallFlag = !appData.autoCallFlag;
502 MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag);
508 appData.autoFlipView = !appData.autoFlipView;
509 MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView);
515 appData.blindfold = !appData.blindfold;
516 MARK_MENU_ITEM("Options.Blindfold", appData.blindfold);
517 DrawPosition(True, NULL);
523 appData.testLegality = !appData.testLegality;
524 MARK_MENU_ITEM("Options.TestLegality", appData.testLegality);
531 if (appData.flashCount == 0) {
532 appData.flashCount = 3;
534 appData.flashCount = -appData.flashCount;
536 MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0);
541 HighlightDraggingProc ()
543 appData.highlightDragging = !appData.highlightDragging;
544 MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging);
549 HighlightLastMoveProc ()
551 appData.highlightLastMove = !appData.highlightLastMove;
552 MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove);
556 HighlightArrowProc ()
558 appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
559 MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow);
565 appData.icsAlarm = !appData.icsAlarm;
566 // MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm);
572 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
573 MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves);
579 appData.oneClick = !appData.oneClick;
580 MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick);
584 PeriodicUpdatesProc ()
586 PeriodicUpdatesEvent(!appData.periodicUpdates);
587 MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates);
591 PopupExitMessageProc ()
593 appData.popupExitMessage = !appData.popupExitMessage;
594 MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage);
598 PopupMoveErrorsProc ()
600 appData.popupMoveErrors = !appData.popupMoveErrors;
601 MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors);
607 appData.premove = !appData.premove;
608 // MARK_MENU_ITEM("Options.Premove", appData.premove);
614 appData.showCoords = !appData.showCoords;
615 MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords);
616 DrawPosition(True, NULL);
622 appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
629 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
632 MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
636 * Menu definition tables
639 MenuItem fileMenu[] = {
640 {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent},
641 {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc},
642 {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet
643 {"----", NULL, NothingProc},
644 {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc},
645 {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc},
646 // {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc},
647 // {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc},
648 // {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc},
649 {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc},
650 {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc},
651 {"----", NULL, NothingProc},
652 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
653 {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc},
654 {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc},
655 {"----", NULL, NothingProc},
656 {N_("Mail Move"), "MailMove", MailMoveEvent},
657 {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc},
658 {"----", NULL, NothingProc},
659 {N_("Quit Ctr+Q"), "Quit", QuitProc},
663 MenuItem editMenu[] = {
664 {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc},
665 {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc},
666 {N_("Copy Game List"), "CopyGameList", CopyGameListProc},
667 {"----", NULL, NothingProc},
668 {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc},
669 {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc},
670 {"----", NULL, NothingProc},
671 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
672 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
673 {N_("Edit Tags"), "EditTags", EditTagsProc},
674 {N_("Edit Comment"), "EditComment", EditCommentProc},
675 {N_("Edit Book"), "EditBook", EditBookEvent},
676 {"----", NULL, NothingProc},
677 {N_("Revert Home"), "Revert", RevertProc},
678 {N_("Annotate"), "Annotate", AnnotateProc},
679 {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent},
680 {"----", NULL, NothingProc},
681 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
682 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
683 {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent},
684 {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent},
688 MenuItem viewMenu[] = {
689 {N_("Flip View F2"), "FlipView", FlipViewProc},
690 {"----", NULL, NothingProc},
691 {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc},
692 {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code
693 {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc},
694 {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc},
695 {N_("ICS text menu"), "ICStextmenu", IcsTextProc},
696 {"----", NULL, NothingProc},
697 {N_("Tags"), "Tags", EditTagsProc},
698 {N_("Comments"), "Comments", EditCommentProc},
699 {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc},
700 {N_("Open Chat Window"), "OpenChatWindow", ChatProc},
701 {"----", NULL, NothingProc},
702 {N_("Board..."), "Board", BoardOptionsProc},
703 {N_("Game List Tags..."), "GameListTags", GameListOptionsProc},
707 MenuItem modeMenu[] = {
708 {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent},
709 {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent},
710 {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent},
711 {N_("Analysis Mode Ctrl+A"), "AnalysisMode", AnalyzeModeProc},
712 {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileProc },
713 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
714 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
715 {N_("Training"), "Training", TrainingEvent},
716 {N_("ICS Client"), "ICSClient", IcsClientEvent},
717 {"----", NULL, NothingProc},
718 {N_("Machine Match"), "MachineMatch", MatchProc},
719 {N_("Pause Pause"), "Pause", PauseEvent},
723 MenuItem actionMenu[] = {
724 {N_("Accept F3"), "Accept", AcceptEvent},
725 {N_("Decline F4"), "Decline", DeclineEvent},
726 {N_("Rematch F12"), "Rematch", RematchEvent},
727 {"----", NULL, NothingProc},
728 {N_("Call Flag F5"), "CallFlag", CallFlagEvent},
729 {N_("Draw F6"), "Draw", DrawEvent},
730 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
731 {N_("Abort F8"),"Abort", AbortEvent},
732 {N_("Resign F9"), "Resign", ResignEvent},
733 {"----", NULL, NothingProc},
734 {N_("Stop Observing F10"), "StopObserving", StopObservingEvent},
735 {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent},
736 {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent},
737 {"----", NULL, NothingProc},
738 {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc},
739 {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc},
740 {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc},
744 MenuItem engineMenu[] = {
745 {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc},
746 {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc},
747 {"----", NULL, NothingProc},
748 {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc},
749 {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc},
750 {"----", NULL, NothingProc},
751 {N_("Hint"), "Hint", HintEvent},
752 {N_("Book"), "Book", BookEvent},
753 {"----", NULL, NothingProc},
754 {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent},
755 {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent},
759 MenuItem optionsMenu[] = {
761 {N_("General ..."), "General", OptionsProc},
763 {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc},
764 {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", UciMenuProc},
765 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
766 {N_("ICS ..."), "ICS", IcsOptionsProc},
767 {N_("Match ..."), "Match", MatchOptionsProc},
768 {N_("Load Game ..."), "LoadGame", LoadOptionsProc},
769 {N_("Save Game ..."), "SaveGame", SaveOptionsProc},
770 // {N_(" ..."), "", OptionsProc},
771 {N_("Game List ..."), "GameList", GameListOptionsProc},
772 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
773 {"----", NULL, NothingProc},
774 #ifndef OPTIONSDIALOG
775 {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc},
776 {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc},
777 {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc},
778 {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc},
779 {N_("Auto Flip View"), "AutoFlipView", AutoflipProc},
780 {N_("Blindfold"), "Blindfold", BlindfoldProc},
781 {N_("Flash Moves"), "FlashMoves", FlashMovesProc},
783 {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc},
785 {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc},
786 {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc},
787 {N_("Move Sound"), "MoveSound", MoveSoundProc},
788 // {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc},
789 {N_("One-Click Moving"), "OneClickMoving", OneClickProc},
790 {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc},
791 {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc},
792 {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc},
793 {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc},
794 // {N_("Premove"), "Premove", PremoveProc},
795 {N_("Show Coords"), "ShowCoords", ShowCoordsProc},
796 {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc},
797 {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc},
798 {"----", NULL, NothingProc},
800 {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc},
801 {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc},
805 MenuItem helpMenu[] = {
806 {N_("Info XBoard"), "InfoXBoard", InfoProc},
807 {N_("Man XBoard F1"), "ManXBoard", ManProc},
808 {"----", NULL, NothingProc},
809 {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc},
810 {N_("On-line User Guide"), "On-lineUserGuide", GuideProc},
811 {N_("Development News"), "DevelopmentNews", NewsPageProc},
812 {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc},
813 {"----", NULL, NothingProc},
814 {N_("About XBoard"), "AboutXBoard", AboutProc},
818 MenuItem noMenu[] = {
819 { "", "LoadNextGame", LoadNextGameProc },
820 { "", "LoadPrevGame", LoadPrevGameProc },
821 { "", "ReloadGame", ReloadGameProc },
822 { "", "ReloadPosition", ReloadPositionProc },
823 #ifndef OPTIONSDIALOG
824 { "", "AlwaysQueen", AlwaysQueenProc },
825 { "", "AnimateDragging", AnimateDraggingProc },
826 { "", "AnimateMoving", AnimateMovingProc },
827 { "", "Autoflag", AutoflagProc },
828 { "", "Autoflip", AutoflipProc },
829 { "", "Blindfold", BlindfoldProc },
830 { "", "FlashMoves", FlashMovesProc },
832 { "", "HighlightDragging", HighlightDraggingProc },
834 { "", "HighlightLastMove", HighlightLastMoveProc },
835 // { "", "IcsAlarm", IcsAlarmProc },
836 { "", "MoveSound", MoveSoundProc },
837 { "", "PeriodicUpdates", PeriodicUpdatesProc },
838 { "", "PopupExitMessage", PopupExitMessageProc },
839 { "", "PopupMoveErrors", PopupMoveErrorsProc },
840 // { "", "Premove", PremoveProc },
841 { "", "ShowCoords", ShowCoordsProc },
842 { "", "ShowThinking", ShowThinkingProc },
843 { "", "HideThinking", HideThinkingProc },
844 { "", "TestLegality", TestLegalityProc },
846 { "", "AboutGame", AboutGameEvent },
847 { "", "DebugProc", DebugProc },
848 { "", "Nothing", NothingProc },
853 {N_("File"), "File", fileMenu},
854 {N_("Edit"), "Edit", editMenu},
855 {N_("View"), "View", viewMenu},
856 {N_("Mode"), "Mode", modeMenu},
857 {N_("Action"), "Action", actionMenu},
858 {N_("Engine"), "Engine", engineMenu},
859 {N_("Options"), "Options", optionsMenu},
860 {N_("Help"), "Help", helpMenu},
865 MenuNameToItem (char *menuName)
868 char buf[MSG_SIZ], *p;
870 static MenuItem a = { NULL, NULL, NothingProc };
871 extern Option mainOptions[];
872 safeStrCpy(buf, menuName, MSG_SIZ);
873 p = strchr(buf, '.');
874 if(!p) menuTab = noMenu, p = menuName; else {
876 for(i=0; menuBar[i].name; i++)
877 if(!strcmp(buf, menuBar[i].name)) break;
878 if(!menuBar[i].name) return NULL; // main menu not found
879 menuTab = menuBar[i].mi;
881 if(*p == NULLCHAR) { a.handle = mainOptions[i+1].handle; return &a; } // main menu bar
882 for(i=0; menuTab[i].string; i++)
883 if(menuTab[i].ref && !strcmp(p, menuTab[i].ref)) return menuTab + i;
884 return NULL; // item not found
888 AppendEnginesToMenu (char *list)
892 if(appData.icsActive || appData.recentEngines <= 0) return;
893 recentEngines = strdup(list);
895 p = strchr(list, '\n'); if(p == NULL) break;
896 if(i == 0) AppendMenuItem("----", 0); // at least one valid item to add
898 AppendMenuItem(list, i);
899 i++; *p = '\n'; list = p + 1;
903 Enables icsEnables[] = {
904 { "File.MailMove", False },
905 { "File.ReloadCMailMessage", False },
906 { "Mode.MachineBlack", False },
907 { "Mode.MachineWhite", False },
908 { "Mode.AnalysisMode", False },
909 { "Mode.AnalyzeFile", False },
910 { "Mode.TwoMachines", False },
911 { "Mode.MachineMatch", False },
913 { "Engine.Hint", False },
914 { "Engine.Book", False },
915 { "Engine.MoveNow", False },
916 #ifndef OPTIONSDIALOG
917 { "PeriodicUpdates", False },
918 { "HideThinking", False },
919 { "PonderNextMove", False },
922 { "Engine.Engine#1Settings", False },
923 { "Engine.Engine#2Settings", False },
924 { "Engine.Load1stEngine", False },
925 { "Engine.Load2ndEngine", False },
926 { "Edit.Annotate", False },
927 { "Options.Match", False },
931 Enables ncpEnables[] = {
932 { "File.MailMove", False },
933 { "File.ReloadCMailMessage", False },
934 { "Mode.MachineWhite", False },
935 { "Mode.MachineBlack", False },
936 { "Mode.AnalysisMode", False },
937 { "Mode.AnalyzeFile", False },
938 { "Mode.TwoMachines", False },
939 { "Mode.MachineMatch", False },
940 { "Mode.ICSClient", False },
941 { "View.ICStextmenu", False },
942 { "View.ICSInputBox", False },
943 { "View.OpenChatWindow", False },
944 { "Action.", False },
945 { "Edit.Revert", False },
946 { "Edit.Annotate", False },
947 { "Engine.Engine#1Settings", False },
948 { "Engine.Engine#2Settings", False },
949 { "Engine.MoveNow", False },
950 { "Engine.RetractMove", False },
951 { "Options.ICS", False },
952 #ifndef OPTIONSDIALOG
953 { "Options.AutoFlag", False },
954 { "Options.AutoFlip View", False },
955 // { "Options.ICSAlarm", False },
956 { "Options.MoveSound", False },
957 { "Options.HideThinking", False },
958 { "Options.PeriodicUpdates", False },
959 { "Options.PonderNextMove", False },
961 { "Engine.Hint", False },
962 { "Engine.Book", False },
966 Enables gnuEnables[] = {
967 { "Mode.ICSClient", False },
968 { "View.ICStextmenu", False },
969 { "View.ICSInputBox", False },
970 { "View.OpenChatWindow", False },
971 { "Action.Accept", False },
972 { "Action.Decline", False },
973 { "Action.Rematch", False },
974 { "Action.Adjourn", False },
975 { "Action.StopExamining", False },
976 { "Action.StopObserving", False },
977 { "Action.UploadtoExamine", False },
978 { "Edit.Revert", False },
979 { "Edit.Annotate", False },
980 { "Options.ICS", False },
982 /* The next two options rely on SetCmailMode being called *after* */
983 /* SetGNUMode so that when GNU is being used to give hints these */
984 /* menu options are still available */
986 { "File.MailMove", False },
987 { "File.ReloadCMailMessage", False },
988 // [HGM] The following have been added to make a switch from ncp to GNU mode possible
989 { "Mode.MachineWhite", True },
990 { "Mode.MachineBlack", True },
991 { "Mode.AnalysisMode", True },
992 { "Mode.AnalyzeFile", True },
993 { "Mode.TwoMachines", True },
994 { "Mode.MachineMatch", True },
995 { "Engine.Engine#1Settings", True },
996 { "Engine.Engine#2Settings", True },
997 { "Engine.Hint", True },
998 { "Engine.Book", True },
999 { "Engine.MoveNow", True },
1000 { "Engine.RetractMove", True },
1001 { "Action.", True },
1005 Enables cmailEnables[] = {
1006 { "Action.", True },
1007 { "Action.CallFlag", False },
1008 { "Action.Draw", True },
1009 { "Action.Adjourn", False },
1010 { "Action.Abort", False },
1011 { "Action.StopObserving", False },
1012 { "Action.StopExamining", False },
1013 { "File.MailMove", True },
1014 { "File.ReloadCMailMessage", True },
1018 Enables trainingOnEnables[] = {
1019 { "Edit.EditComment", False },
1020 { "Mode.Pause", False },
1021 { "Edit.Forward", False },
1022 { "Edit.Backward", False },
1023 { "Edit.ForwardtoEnd", False },
1024 { "Edit.BacktoStart", False },
1025 { "Engine.MoveNow", False },
1026 { "Edit.TruncateGame", False },
1030 Enables trainingOffEnables[] = {
1031 { "Edit.EditComment", True },
1032 { "Mode.Pause", True },
1033 { "Edit.Forward", True },
1034 { "Edit.Backward", True },
1035 { "Edit.ForwardtoEnd", True },
1036 { "Edit.BacktoStart", True },
1037 { "Engine.MoveNow", True },
1038 { "Engine.TruncateGame", True },
1042 Enables machineThinkingEnables[] = {
1043 { "File.LoadGame", False },
1044 // { "LoadNextGame", False },
1045 // { "LoadPreviousGame", False },
1046 // { "ReloadSameGame", False },
1047 { "Edit.PasteGame", False },
1048 { "File.LoadPosition", False },
1049 // { "LoadNextPosition", False },
1050 // { "LoadPreviousPosition", False },
1051 // { "ReloadSamePosition", False },
1052 { "Edit.PastePosition", False },
1053 { "Mode.MachineWhite", False },
1054 { "Mode.MachineBlack", False },
1055 { "Mode.TwoMachines", False },
1056 // { "MachineMatch", False },
1057 { "Engine.RetractMove", False },
1061 Enables userThinkingEnables[] = {
1062 { "File.LoadGame", True },
1063 // { "LoadNextGame", True },
1064 // { "LoadPreviousGame", True },
1065 // { "ReloadSameGame", True },
1066 { "Edit.PasteGame", True },
1067 { "File.LoadPosition", True },
1068 // { "LoadNextPosition", True },
1069 // { "LoadPreviousPosition", True },
1070 // { "ReloadSamePosition", True },
1071 { "Edit.PastePosition", True },
1072 { "Mode.MachineWhite", True },
1073 { "Mode.MachineBlack", True },
1074 { "Mode.TwoMachines", True },
1075 // { "MachineMatch", True },
1076 { "Engine.RetractMove", True },
1083 SetMenuEnables(icsEnables);
1086 if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
1087 EnableNamedMenuItem("Mode.AnalysisMode", True);
1088 EnableNamedMenuItem("Engine.Engine#1Settings", True);
1096 SetMenuEnables(ncpEnables);
1102 SetMenuEnables(gnuEnables);
1108 SetMenuEnables(cmailEnables);
1112 SetTrainingModeOn ()
1114 SetMenuEnables(trainingOnEnables);
1115 if (appData.showButtonBar) {
1116 EnableButtonBar(False);
1122 SetTrainingModeOff ()
1124 SetMenuEnables(trainingOffEnables);
1125 if (appData.showButtonBar) {
1126 EnableButtonBar(True);
1131 SetUserThinkingEnables ()
1133 if (appData.noChessProgram) return;
1134 SetMenuEnables(userThinkingEnables);
1138 SetMachineThinkingEnables ()
1140 if (appData.noChessProgram) return;
1141 SetMenuEnables(machineThinkingEnables);
1143 case MachinePlaysBlack:
1144 case MachinePlaysWhite:
1145 case TwoMachinesPlay:
1146 EnableNamedMenuItem(ModeToWidgetName(gameMode), True);
1154 GreyRevert (Boolean grey)
1156 MarkMenuItem("Edit.Revert", !grey);
1157 MarkMenuItem("Edit.Annotate", !grey);
1161 ModeToWidgetName (GameMode mode)
1164 case BeginningOfGame:
1165 if (appData.icsActive)
1166 return "Mode.ICSClient";
1167 else if (appData.noChessProgram ||
1168 *appData.cmailGameName != NULLCHAR)
1169 return "Mode.EditGame";
1171 return "Mode.MachineBlack";
1172 case MachinePlaysBlack:
1173 return "Mode.MachineBlack";
1174 case MachinePlaysWhite:
1175 return "Mode.MachineWhite";
1177 return "Mode.AnalysisMode";
1179 return "Mode.AnalyzeFile";
1180 case TwoMachinesPlay:
1181 return "Mode.TwoMachines";
1183 return "Mode.EditGame";
1184 case PlayFromGameFile:
1185 return "File.LoadGame";
1187 return "Mode.EditPosition";
1189 return "Mode.Training";
1190 case IcsPlayingWhite:
1191 case IcsPlayingBlack:
1195 return "Mode.ICSClient";
1205 #ifndef OPTIONSDIALOG
1206 if (appData.alwaysPromoteToQueen) {
1207 MarkMenuItem("Options.Always Queen", True);
1209 if (appData.animateDragging) {
1210 MarkMenuItem("Options.Animate Dragging", True);
1212 if (appData.animate) {
1213 MarkMenuItem("Options.Animate Moving", True);
1215 if (appData.autoCallFlag) {
1216 MarkMenuItem("Options.Auto Flag", True);
1218 if (appData.autoFlipView) {
1219 XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True);
1221 if (appData.blindfold) {
1222 MarkMenuItem("Options.Blindfold", True);
1224 if (appData.flashCount > 0) {
1225 MarkMenuItem("Options.Flash Moves", True);
1228 if (appData.highlightDragging) {
1229 MarkMenuItem("Options.Highlight Dragging", True);
1232 if (appData.highlightLastMove) {
1233 MarkMenuItem("Options.Highlight Last Move", True);
1235 if (appData.highlightMoveWithArrow) {
1236 MarkMenuItem("Options.Arrow", True);
1238 // if (appData.icsAlarm) {
1239 // MarkMenuItem("Options.ICS Alarm", True);
1241 if (appData.ringBellAfterMoves) {
1242 MarkMenuItem("Options.Move Sound", True);
1244 if (appData.oneClick) {
1245 MarkMenuItem("Options.OneClick", True);
1247 if (appData.periodicUpdates) {
1248 MarkMenuItem("Options.Periodic Updates", True);
1250 if (appData.ponderNextMove) {
1251 MarkMenuItem("Options.Ponder Next Move", True);
1253 if (appData.popupExitMessage) {
1254 MarkMenuItem("Options.Popup Exit Message", True);
1256 if (appData.popupMoveErrors) {
1257 MarkMenuItem("Options.Popup Move Errors", True);
1259 // if (appData.premove) {
1260 // MarkMenuItem("Options.Premove", True);
1262 if (appData.showCoords) {
1263 MarkMenuItem("Options.Show Coords", True);
1265 if (appData.hideThinkingFromHuman) {
1266 MarkMenuItem("Options.Hide Thinking", True);
1268 if (appData.testLegality) {
1269 MarkMenuItem("Options.Test Legality", True);
1272 if (saveSettingsOnExit) {
1273 MarkMenuItem("Options.SaveSettingsonExit", True);