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.
94 # define _(s) gettext (s)
95 # define N_(s) gettext_noop (s)
102 * Button/menu procedures
105 char *gameCopyFilename, *gamePasteFilename;
106 Boolean saveSettingsOnExit;
107 char *settingsFileName;
110 LoadGamePopUp (FILE *f, int gameNumber, char *title)
112 cmailMsgLoaded = FALSE;
113 if (gameNumber == 0) {
114 int error = GameListBuild(f);
116 DisplayError(_("Cannot build game list"), error);
117 } else if (!ListEmpty(&gameList) &&
118 ((ListGame *) gameList.tailPred)->number > 1) {
119 GameListPopUp(f, title);
125 return LoadGame(f, gameNumber, title, FALSE);
131 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
134 FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb");
156 LoadNextPositionProc ()
162 LoadPrevPositionProc ()
168 ReloadPositionProc ()
176 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
179 FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
185 FileNamePopUp(_("Save game file name?"),
186 DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
187 appData.oldSaveStyle ? ".game" : ".pgn",
194 FileNamePopUp(_("Save position file name?"),
195 DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
196 appData.oldSaveStyle ? ".pos" : ".fen",
201 ReloadCmailMsgProc ()
203 ReloadCmailMsgEvent(FALSE);
207 CopyFENToClipboard ()
208 { // wrapper to make call from back-end possible
215 static char *selected_fen_position=NULL;
216 if(gameMode == EditPosition) EditPositionDone(TRUE);
217 if (selected_fen_position) free(selected_fen_position);
218 selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
219 if (!selected_fen_position) return;
220 CopySomething(selected_fen_position);
228 ret = SaveGameToFile(gameCopyFilename, FALSE);
237 if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
263 UserAdjudicationEvent(+1);
269 UserAdjudicationEvent(-1);
275 UserAdjudicationEvent(0);
293 if(twoBoards) { partnerUp = 1; DrawPosition(True, NULL); partnerUp = 0; }
294 flipView = !flipView;
295 DrawPosition(True, NULL);
301 saveSettingsOnExit = !saveSettingsOnExit;
303 MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
309 SaveSettings(settingsFileName);
316 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
325 snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen);
333 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
341 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
349 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
356 char buf[2 * MSG_SIZ];
358 char *zippy = _(" (with Zippy code)");
362 snprintf(buf, sizeof(buf),
364 "Copyright 1991 Digital Equipment Corporation\n"
365 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
366 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
367 "%s is free software and carries NO WARRANTY;"
368 "see the file COPYING for more information.\n\n"
369 "Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
370 "Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
371 "Report bugs via email at: <bug-xboard@gnu.org>\n\n"
373 programVersion, zippy, PACKAGE);
374 ErrorPopUp(_("About XBoard"), buf, FALSE);
380 appData.debugMode = !appData.debugMode;
381 if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed
382 if(!appData.debugMode) fclose(debugFP);
384 debugFP = fopen(appData.nameOfDebugFile, "w");
385 if(debugFP == NULL) debugFP = stderr;
386 else setbuf(debugFP, NULL);
397 # define MARK_MENU_ITEM(X,Y)
399 # define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
403 PonderNextMoveProc ()
405 PonderNextMoveEvent(!appData.ponderNextMove);
406 MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
412 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
413 MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen);
417 AnimateDraggingProc ()
419 appData.animateDragging = !appData.animateDragging;
421 if (appData.animateDragging) CreateAnimVars();
422 MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging);
428 appData.animate = !appData.animate;
429 if (appData.animate) CreateAnimVars();
430 MARK_MENU_ITEM("Options.AnimateMoving", appData.animate);
436 appData.autoCallFlag = !appData.autoCallFlag;
437 MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag);
443 appData.autoFlipView = !appData.autoFlipView;
444 MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView);
450 appData.blindfold = !appData.blindfold;
451 MARK_MENU_ITEM("Options.Blindfold", appData.blindfold);
452 DrawPosition(True, NULL);
458 appData.testLegality = !appData.testLegality;
459 MARK_MENU_ITEM("Options.TestLegality", appData.testLegality);
466 if (appData.flashCount == 0) {
467 appData.flashCount = 3;
469 appData.flashCount = -appData.flashCount;
471 MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0);
476 HighlightDraggingProc ()
478 appData.highlightDragging = !appData.highlightDragging;
479 MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging);
484 HighlightLastMoveProc ()
486 appData.highlightLastMove = !appData.highlightLastMove;
487 MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove);
491 HighlightArrowProc ()
493 appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
494 MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow);
500 appData.icsAlarm = !appData.icsAlarm;
501 // MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm);
507 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
508 MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves);
514 appData.oneClick = !appData.oneClick;
515 MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick);
519 PeriodicUpdatesProc ()
521 PeriodicUpdatesEvent(!appData.periodicUpdates);
522 MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates);
526 PopupExitMessageProc ()
528 appData.popupExitMessage = !appData.popupExitMessage;
529 MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage);
533 PopupMoveErrorsProc ()
535 appData.popupMoveErrors = !appData.popupMoveErrors;
536 MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors);
542 appData.premove = !appData.premove;
543 // MARK_MENU_ITEM("Options.Premove", appData.premove);
549 appData.showCoords = !appData.showCoords;
550 MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords);
551 DrawPosition(True, NULL);
557 appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
564 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
567 MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
571 * Menu definition tables
574 MenuItem fileMenu[] = {
575 {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent},
576 {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc},
577 {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet
578 {"----", NULL, NothingProc},
579 {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc, CHECK},
580 {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc},
581 // {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc},
582 // {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc},
583 // {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc},
584 {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc},
585 {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc},
586 {"----", NULL, NothingProc},
587 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
588 {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc},
589 {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc},
590 {"----", NULL, NothingProc},
591 {N_("Mail Move"), "MailMove", MailMoveEvent},
592 {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc},
593 {"----", NULL, NothingProc},
594 {N_("Quit Ctr+Q"), "Quit", QuitProc},
598 MenuItem editMenu[] = {
599 {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc},
600 {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc},
601 {N_("Copy Game List"), "CopyGameList", CopyGameListProc},
602 {"----", NULL, NothingProc},
603 {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc},
604 {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc},
605 {"----", NULL, NothingProc},
606 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
607 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
608 {N_("Edit Tags"), "EditTags", EditTagsProc},
609 {N_("Edit Comment"), "EditComment", EditCommentProc},
610 {N_("Edit Book"), "EditBook", EditBookEvent},
611 {"----", NULL, NothingProc},
612 {N_("Revert Home"), "Revert", RevertProc},
613 {N_("Annotate"), "Annotate", AnnotateProc},
614 {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent},
615 {"----", NULL, NothingProc},
616 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
617 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
618 {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent},
619 {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent},
623 MenuItem viewMenu[] = {
624 {N_("Flip View F2"), "FlipView", FlipViewProc, CHECK},
625 {"----", NULL, NothingProc},
626 {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc, CHECK},
627 {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc, CHECK}, // [HGM] hist: activate 4.2.7 code
628 {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc, CHECK},
629 {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc, CHECK},
630 {N_("ICS text menu"), "ICStextmenu", IcsTextProc, CHECK},
631 {"----", NULL, NothingProc},
632 {N_("Tags"), "Tags", EditTagsProc, CHECK},
633 {N_("Comments"), "Comments", EditCommentProc, CHECK},
634 {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc, CHECK},
635 {N_("Open Chat Window"), "OpenChatWindow", ChatProc, CHECK},
636 {"----", NULL, NothingProc},
637 {N_("Board..."), "Board", BoardOptionsProc},
638 {N_("Game List Tags..."), "GameListTags", GameListOptionsProc},
642 MenuItem modeMenu[] = {
643 {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent, RADIO },
644 {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent, RADIO },
645 {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent, RADIO },
646 {N_("Analysis Mode Ctrl+A"), "AnalysisMode", (MenuProc*) AnalyzeModeEvent, RADIO},
647 {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileEvent, RADIO },
648 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent, RADIO },
649 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent, RADIO },
650 {N_("Training"), "Training", TrainingEvent, RADIO },
651 {N_("ICS Client"), "ICSClient", IcsClientEvent, RADIO },
652 {"----", NULL, NothingProc},
653 {N_("Machine Match"), "MachineMatch", MatchProc, CHECK },
654 {N_("Pause Pause"), "Pause", PauseEvent, CHECK },
658 MenuItem actionMenu[] = {
659 {N_("Accept F3"), "Accept", AcceptEvent},
660 {N_("Decline F4"), "Decline", DeclineEvent},
661 {N_("Rematch F12"), "Rematch", RematchEvent},
662 {"----", NULL, NothingProc},
663 {N_("Call Flag F5"), "CallFlag", CallFlagEvent},
664 {N_("Draw F6"), "Draw", DrawEvent},
665 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
666 {N_("Abort F8"),"Abort", AbortEvent},
667 {N_("Resign F9"), "Resign", ResignEvent},
668 {"----", NULL, NothingProc},
669 {N_("Stop Observing F10"), "StopObserving", StopObservingEvent},
670 {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent},
671 {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent},
672 {"----", NULL, NothingProc},
673 {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc},
674 {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc},
675 {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc},
679 MenuItem engineMenu[100] = {
680 {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc},
681 {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc},
682 {"----", NULL, NothingProc},
683 {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc},
684 {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc},
685 {"----", NULL, NothingProc},
686 {N_("Hint"), "Hint", HintEvent},
687 {N_("Book"), "Book", BookEvent},
688 {"----", NULL, NothingProc},
689 {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent},
690 {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent},
694 MenuItem optionsMenu[] = {
696 {N_("General ..."), "General", OptionsProc},
698 {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc},
699 {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", UciMenuProc},
700 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
701 {N_("ICS ..."), "ICS", IcsOptionsProc},
702 {N_("Match ..."), "Match", MatchOptionsProc},
703 {N_("Load Game ..."), "LoadGame", LoadOptionsProc},
704 {N_("Save Game ..."), "SaveGame", SaveOptionsProc},
705 // {N_(" ..."), "", OptionsProc},
706 {N_("Game List ..."), "GameList", GameListOptionsProc},
707 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
708 {"----", NULL, NothingProc},
709 #ifndef OPTIONSDIALOG
710 {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc},
711 {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc},
712 {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc},
713 {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc},
714 {N_("Auto Flip View"), "AutoFlipView", AutoflipProc},
715 {N_("Blindfold"), "Blindfold", BlindfoldProc},
716 {N_("Flash Moves"), "FlashMoves", FlashMovesProc},
718 {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc},
720 {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc},
721 {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc},
722 {N_("Move Sound"), "MoveSound", MoveSoundProc},
723 // {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc},
724 {N_("One-Click Moving"), "OneClickMoving", OneClickProc},
725 {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc},
726 {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc},
727 {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc},
728 {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc},
729 // {N_("Premove"), "Premove", PremoveProc},
730 {N_("Show Coords"), "ShowCoords", ShowCoordsProc},
731 {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc},
732 {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc},
733 {"----", NULL, NothingProc},
735 {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc},
736 {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc, CHECK },
740 MenuItem helpMenu[] = {
741 {N_("Info XBoard"), "InfoXBoard", InfoProc},
742 {N_("Man XBoard F1"), "ManXBoard", ManProc},
743 {"----", NULL, NothingProc},
744 {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc},
745 {N_("On-line User Guide"), "On-lineUserGuide", GuideProc},
746 {N_("Development News"), "DevelopmentNews", NewsPageProc},
747 {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc},
748 {"----", NULL, NothingProc},
749 {N_("About XBoard"), "AboutXBoard", AboutProc},
753 MenuItem noMenu[] = {
754 { "", "LoadNextGame", LoadNextGameProc },
755 { "", "LoadPrevGame", LoadPrevGameProc },
756 { "", "ReloadGame", ReloadGameProc },
757 { "", "ReloadPosition", ReloadPositionProc },
758 #ifndef OPTIONSDIALOG
759 { "", "AlwaysQueen", AlwaysQueenProc },
760 { "", "AnimateDragging", AnimateDraggingProc },
761 { "", "AnimateMoving", AnimateMovingProc },
762 { "", "Autoflag", AutoflagProc },
763 { "", "Autoflip", AutoflipProc },
764 { "", "Blindfold", BlindfoldProc },
765 { "", "FlashMoves", FlashMovesProc },
767 { "", "HighlightDragging", HighlightDraggingProc },
769 { "", "HighlightLastMove", HighlightLastMoveProc },
770 // { "", "IcsAlarm", IcsAlarmProc },
771 { "", "MoveSound", MoveSoundProc },
772 { "", "PeriodicUpdates", PeriodicUpdatesProc },
773 { "", "PopupExitMessage", PopupExitMessageProc },
774 { "", "PopupMoveErrors", PopupMoveErrorsProc },
775 // { "", "Premove", PremoveProc },
776 { "", "ShowCoords", ShowCoordsProc },
777 { "", "ShowThinking", ShowThinkingProc },
778 { "", "HideThinking", HideThinkingProc },
779 { "", "TestLegality", TestLegalityProc },
781 { "", "AboutGame", AboutGameEvent },
782 { "", "DebugProc", DebugProc },
783 { "", "Nothing", NothingProc },
788 {N_("File"), "File", fileMenu},
789 {N_("Edit"), "Edit", editMenu},
790 {N_("View"), "View", viewMenu},
791 {N_("Mode"), "Mode", modeMenu},
792 {N_("Action"), "Action", actionMenu},
793 {N_("Engine"), "Engine", engineMenu},
794 {N_("Options"), "Options", optionsMenu},
795 {N_("Help"), "Help", helpMenu},
800 MenuNameToItem (char *menuName)
803 char buf[MSG_SIZ], *p;
805 static MenuItem a = { NULL, NULL, NothingProc };
806 extern Option mainOptions[];
807 safeStrCpy(buf, menuName, MSG_SIZ);
808 p = strchr(buf, '.');
809 if(!p) menuTab = noMenu, p = menuName; else {
811 for(i=0; menuBar[i].name; i++)
812 if(!strcmp(buf, menuBar[i].name)) break;
813 if(!menuBar[i].name) return NULL; // main menu not found
814 menuTab = menuBar[i].mi;
816 if(*p == NULLCHAR) { a.handle = mainOptions[i+1].handle; return &a; } // main menu bar
817 for(i=0; menuTab[i].string; i++)
818 if(menuTab[i].ref && !strcmp(p, menuTab[i].ref)) return menuTab + i;
819 return NULL; // item not found
825 AppendEnginesToMenu (char *list)
829 if(appData.icsActive || appData.recentEngines <= 0) return;
830 for(firstEngineItem=0; engineMenu[firstEngineItem].string; firstEngineItem++);
831 recentEngines = strdup(list);
833 p = strchr(list, '\n'); if(p == NULL) break;
834 if(i == 0) engineMenu[firstEngineItem++].string = "----"; // at least one valid item to add
836 if(firstEngineItem + i < 99)
837 engineMenu[firstEngineItem+i].string = strdup(list); // just set name; MenuProc stays NULL
838 i++; *p = '\n'; list = p + 1;
842 Enables icsEnables[] = {
843 { "File.MailMove", False },
844 { "File.ReloadCMailMessage", False },
845 { "Mode.MachineBlack", False },
846 { "Mode.MachineWhite", False },
847 { "Mode.AnalysisMode", False },
848 { "Mode.AnalyzeFile", False },
849 { "Mode.TwoMachines", False },
850 { "Mode.MachineMatch", False },
852 { "Engine.Hint", False },
853 { "Engine.Book", False },
854 { "Engine.MoveNow", False },
855 #ifndef OPTIONSDIALOG
856 { "PeriodicUpdates", False },
857 { "HideThinking", False },
858 { "PonderNextMove", False },
861 { "Engine.Engine#1Settings", False },
862 { "Engine.Engine#2Settings", False },
863 { "Engine.Load1stEngine", False },
864 { "Engine.Load2ndEngine", False },
865 { "Edit.Annotate", False },
866 { "Options.Match", False },
870 Enables ncpEnables[] = {
871 { "File.MailMove", False },
872 { "File.ReloadCMailMessage", False },
873 { "Mode.MachineWhite", False },
874 { "Mode.MachineBlack", False },
875 { "Mode.AnalysisMode", False },
876 { "Mode.AnalyzeFile", False },
877 { "Mode.TwoMachines", False },
878 { "Mode.MachineMatch", False },
879 { "Mode.ICSClient", False },
880 { "View.ICStextmenu", False },
881 { "View.ICSInputBox", False },
882 { "View.OpenChatWindow", False },
883 { "Action.", False },
884 { "Edit.Revert", False },
885 { "Edit.Annotate", False },
886 { "Engine.Engine#1Settings", False },
887 { "Engine.Engine#2Settings", False },
888 { "Engine.MoveNow", False },
889 { "Engine.RetractMove", False },
890 { "Options.ICS", False },
891 #ifndef OPTIONSDIALOG
892 { "Options.AutoFlag", False },
893 { "Options.AutoFlip View", False },
894 // { "Options.ICSAlarm", False },
895 { "Options.MoveSound", False },
896 { "Options.HideThinking", False },
897 { "Options.PeriodicUpdates", False },
898 { "Options.PonderNextMove", False },
900 { "Engine.Hint", False },
901 { "Engine.Book", False },
905 Enables gnuEnables[] = {
906 { "Mode.ICSClient", False },
907 { "View.ICStextmenu", False },
908 { "View.ICSInputBox", False },
909 { "View.OpenChatWindow", False },
910 { "Action.Accept", False },
911 { "Action.Decline", False },
912 { "Action.Rematch", False },
913 { "Action.Adjourn", False },
914 { "Action.StopExamining", False },
915 { "Action.StopObserving", False },
916 { "Action.UploadtoExamine", False },
917 { "Edit.Revert", False },
918 { "Edit.Annotate", False },
919 { "Options.ICS", False },
921 /* The next two options rely on SetCmailMode being called *after* */
922 /* SetGNUMode so that when GNU is being used to give hints these */
923 /* menu options are still available */
925 { "File.MailMove", False },
926 { "File.ReloadCMailMessage", False },
927 // [HGM] The following have been added to make a switch from ncp to GNU mode possible
928 { "Mode.MachineWhite", True },
929 { "Mode.MachineBlack", True },
930 { "Mode.AnalysisMode", True },
931 { "Mode.AnalyzeFile", True },
932 { "Mode.TwoMachines", True },
933 { "Mode.MachineMatch", True },
934 { "Engine.Engine#1Settings", True },
935 { "Engine.Engine#2Settings", True },
936 { "Engine.Hint", True },
937 { "Engine.Book", True },
938 { "Engine.MoveNow", True },
939 { "Engine.RetractMove", True },
944 Enables cmailEnables[] = {
946 { "Action.CallFlag", False },
947 { "Action.Draw", True },
948 { "Action.Adjourn", False },
949 { "Action.Abort", False },
950 { "Action.StopObserving", False },
951 { "Action.StopExamining", False },
952 { "File.MailMove", True },
953 { "File.ReloadCMailMessage", True },
957 Enables trainingOnEnables[] = {
958 { "Edit.EditComment", False },
959 { "Mode.Pause", False },
960 { "Edit.Forward", False },
961 { "Edit.Backward", False },
962 { "Edit.ForwardtoEnd", False },
963 { "Edit.BacktoStart", False },
964 { "Engine.MoveNow", False },
965 { "Edit.TruncateGame", False },
969 Enables trainingOffEnables[] = {
970 { "Edit.EditComment", True },
971 { "Mode.Pause", True },
972 { "Edit.Forward", True },
973 { "Edit.Backward", True },
974 { "Edit.ForwardtoEnd", True },
975 { "Edit.BacktoStart", True },
976 { "Engine.MoveNow", True },
977 { "Engine.TruncateGame", True },
981 Enables machineThinkingEnables[] = {
982 { "File.LoadGame", False },
983 // { "LoadNextGame", False },
984 // { "LoadPreviousGame", False },
985 // { "ReloadSameGame", False },
986 { "Edit.PasteGame", False },
987 { "File.LoadPosition", False },
988 // { "LoadNextPosition", False },
989 // { "LoadPreviousPosition", False },
990 // { "ReloadSamePosition", False },
991 { "Edit.PastePosition", False },
992 { "Mode.MachineWhite", False },
993 { "Mode.MachineBlack", False },
994 { "Mode.TwoMachines", False },
995 // { "MachineMatch", False },
996 { "Engine.RetractMove", False },
1000 Enables userThinkingEnables[] = {
1001 { "File.LoadGame", True },
1002 // { "LoadNextGame", True },
1003 // { "LoadPreviousGame", True },
1004 // { "ReloadSameGame", True },
1005 { "Edit.PasteGame", True },
1006 { "File.LoadPosition", True },
1007 // { "LoadNextPosition", True },
1008 // { "LoadPreviousPosition", True },
1009 // { "ReloadSamePosition", True },
1010 { "Edit.PastePosition", True },
1011 { "Mode.MachineWhite", True },
1012 { "Mode.MachineBlack", True },
1013 { "Mode.TwoMachines", True },
1014 // { "MachineMatch", True },
1015 { "Engine.RetractMove", True },
1022 SetMenuEnables(icsEnables);
1025 if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
1026 EnableNamedMenuItem("Mode.AnalysisMode", True);
1027 EnableNamedMenuItem("Engine.Engine#1Settings", True);
1035 SetMenuEnables(ncpEnables);
1041 SetMenuEnables(gnuEnables);
1047 SetMenuEnables(cmailEnables);
1051 SetTrainingModeOn ()
1053 SetMenuEnables(trainingOnEnables);
1054 if (appData.showButtonBar) {
1055 EnableButtonBar(False);
1061 SetTrainingModeOff ()
1063 SetMenuEnables(trainingOffEnables);
1064 if (appData.showButtonBar) {
1065 EnableButtonBar(True);
1070 SetUserThinkingEnables ()
1072 if (appData.noChessProgram) return;
1073 SetMenuEnables(userThinkingEnables);
1077 SetMachineThinkingEnables ()
1079 if (appData.noChessProgram) return;
1080 SetMenuEnables(machineThinkingEnables);
1082 case MachinePlaysBlack:
1083 case MachinePlaysWhite:
1084 case TwoMachinesPlay:
1085 EnableNamedMenuItem(ModeToWidgetName(gameMode), True);
1093 GreyRevert (Boolean grey)
1095 MarkMenuItem("Edit.Revert", !grey);
1096 MarkMenuItem("Edit.Annotate", !grey);
1100 ModeToWidgetName (GameMode mode)
1103 case BeginningOfGame:
1104 if (appData.icsActive)
1105 return "Mode.ICSClient";
1106 else if (appData.noChessProgram ||
1107 *appData.cmailGameName != NULLCHAR)
1108 return "Mode.EditGame";
1110 return "Mode.MachineBlack";
1111 case MachinePlaysBlack:
1112 return "Mode.MachineBlack";
1113 case MachinePlaysWhite:
1114 return "Mode.MachineWhite";
1116 return "Mode.AnalysisMode";
1118 return "Mode.AnalyzeFile";
1119 case TwoMachinesPlay:
1120 return "Mode.TwoMachines";
1122 return "Mode.EditGame";
1123 case PlayFromGameFile:
1124 return "File.LoadGame";
1126 return "Mode.EditPosition";
1128 return "Mode.Training";
1129 case IcsPlayingWhite:
1130 case IcsPlayingBlack:
1134 return "Mode.ICSClient";
1144 #ifndef OPTIONSDIALOG
1145 if (appData.alwaysPromoteToQueen) {
1146 MarkMenuItem("Options.Always Queen", True);
1148 if (appData.animateDragging) {
1149 MarkMenuItem("Options.Animate Dragging", True);
1151 if (appData.animate) {
1152 MarkMenuItem("Options.Animate Moving", True);
1154 if (appData.autoCallFlag) {
1155 MarkMenuItem("Options.Auto Flag", True);
1157 if (appData.autoFlipView) {
1158 XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True);
1160 if (appData.blindfold) {
1161 MarkMenuItem("Options.Blindfold", True);
1163 if (appData.flashCount > 0) {
1164 MarkMenuItem("Options.Flash Moves", True);
1167 if (appData.highlightDragging) {
1168 MarkMenuItem("Options.Highlight Dragging", True);
1171 if (appData.highlightLastMove) {
1172 MarkMenuItem("Options.Highlight Last Move", True);
1174 if (appData.highlightMoveWithArrow) {
1175 MarkMenuItem("Options.Arrow", True);
1177 // if (appData.icsAlarm) {
1178 // MarkMenuItem("Options.ICS Alarm", True);
1180 if (appData.ringBellAfterMoves) {
1181 MarkMenuItem("Options.Move Sound", True);
1183 if (appData.oneClick) {
1184 MarkMenuItem("Options.OneClick", True);
1186 if (appData.periodicUpdates) {
1187 MarkMenuItem("Options.Periodic Updates", True);
1189 if (appData.ponderNextMove) {
1190 MarkMenuItem("Options.Ponder Next Move", True);
1192 if (appData.popupExitMessage) {
1193 MarkMenuItem("Options.Popup Exit Message", True);
1195 if (appData.popupMoveErrors) {
1196 MarkMenuItem("Options.Popup Move Errors", True);
1198 // if (appData.premove) {
1199 // MarkMenuItem("Options.Premove", True);
1201 if (appData.showCoords) {
1202 MarkMenuItem("Options.Show Coords", True);
1204 if (appData.hideThinkingFromHuman) {
1205 MarkMenuItem("Options.Hide Thinking", True);
1207 if (appData.testLegality) {
1208 MarkMenuItem("Options.Test Legality", True);
1211 if (saveSettingsOnExit) {
1212 MarkMenuItem("Options.SaveSettingsonExit", True);