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 &",
388 { // called from menu
389 ManInner(NULL, NULL, NULL, NULL);
396 snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen);
404 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
412 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
420 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
427 char buf[2 * MSG_SIZ];
429 char *zippy = _(" (with Zippy code)");
433 snprintf(buf, sizeof(buf),
435 "Copyright 1991 Digital Equipment Corporation\n"
436 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
437 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
438 "%s is free software and carries NO WARRANTY;"
439 "see the file COPYING for more information.\n\n"
440 "Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
441 "Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
442 "Report bugs via email at: <bug-xboard@gnu.org>\n\n"
444 programVersion, zippy, PACKAGE);
445 ErrorPopUp(_("About XBoard"), buf, FALSE);
451 appData.debugMode = !appData.debugMode;
452 if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed
453 if(!appData.debugMode) fclose(debugFP);
455 debugFP = fopen(appData.nameOfDebugFile, "w");
456 if(debugFP == NULL) debugFP = stderr;
457 else setbuf(debugFP, NULL);
468 # define MARK_MENU_ITEM(X,Y)
470 # define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
474 PonderNextMoveProc ()
476 PonderNextMoveEvent(!appData.ponderNextMove);
477 MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
483 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
484 MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen);
488 AnimateDraggingProc ()
490 appData.animateDragging = !appData.animateDragging;
492 if (appData.animateDragging) CreateAnimVars();
493 MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging);
499 appData.animate = !appData.animate;
500 if (appData.animate) CreateAnimVars();
501 MARK_MENU_ITEM("Options.AnimateMoving", appData.animate);
507 appData.autoCallFlag = !appData.autoCallFlag;
508 MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag);
514 appData.autoFlipView = !appData.autoFlipView;
515 MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView);
521 appData.blindfold = !appData.blindfold;
522 MARK_MENU_ITEM("Options.Blindfold", appData.blindfold);
523 DrawPosition(True, NULL);
529 appData.testLegality = !appData.testLegality;
530 MARK_MENU_ITEM("Options.TestLegality", appData.testLegality);
537 if (appData.flashCount == 0) {
538 appData.flashCount = 3;
540 appData.flashCount = -appData.flashCount;
542 MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0);
547 HighlightDraggingProc ()
549 appData.highlightDragging = !appData.highlightDragging;
550 MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging);
555 HighlightLastMoveProc ()
557 appData.highlightLastMove = !appData.highlightLastMove;
558 MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove);
562 HighlightArrowProc ()
564 appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
565 MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow);
571 appData.icsAlarm = !appData.icsAlarm;
572 // MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm);
578 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
579 MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves);
585 appData.oneClick = !appData.oneClick;
586 MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick);
590 PeriodicUpdatesProc ()
592 PeriodicUpdatesEvent(!appData.periodicUpdates);
593 MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates);
597 PopupExitMessageProc ()
599 appData.popupExitMessage = !appData.popupExitMessage;
600 MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage);
604 PopupMoveErrorsProc ()
606 appData.popupMoveErrors = !appData.popupMoveErrors;
607 MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors);
613 appData.premove = !appData.premove;
614 // MARK_MENU_ITEM("Options.Premove", appData.premove);
620 appData.showCoords = !appData.showCoords;
621 MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords);
622 DrawPosition(True, NULL);
628 appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
635 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
638 MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
642 * Menu definition tables
645 MenuItem fileMenu[] = {
646 {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent},
647 {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc},
648 {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet
649 {"----", NULL, NothingProc},
650 {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc},
651 {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc},
652 // {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc},
653 // {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc},
654 // {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc},
655 {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc},
656 {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc},
657 {"----", NULL, NothingProc},
658 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
659 {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc},
660 {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc},
661 {"----", NULL, NothingProc},
662 {N_("Mail Move"), "MailMove", MailMoveEvent},
663 {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc},
664 {"----", NULL, NothingProc},
665 {N_("Quit Ctr+Q"), "Quit", QuitProc},
669 MenuItem editMenu[] = {
670 {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc},
671 {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc},
672 {N_("Copy Game List"), "CopyGameList", CopyGameListProc},
673 {"----", NULL, NothingProc},
674 {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc},
675 {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc},
676 {"----", NULL, NothingProc},
677 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
678 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
679 {N_("Edit Tags"), "EditTags", EditTagsProc},
680 {N_("Edit Comment"), "EditComment", EditCommentProc},
681 {N_("Edit Book"), "EditBook", EditBookEvent},
682 {"----", NULL, NothingProc},
683 {N_("Revert Home"), "Revert", RevertProc},
684 {N_("Annotate"), "Annotate", AnnotateProc},
685 {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent},
686 {"----", NULL, NothingProc},
687 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
688 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
689 {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent},
690 {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent},
694 MenuItem viewMenu[] = {
695 {N_("Flip View F2"), "FlipView", FlipViewProc},
696 {"----", NULL, NothingProc},
697 {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc},
698 {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code
699 {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc},
700 {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc},
701 {N_("ICS text menu"), "ICStextmenu", IcsTextProc},
702 {"----", NULL, NothingProc},
703 {N_("Tags"), "Tags", EditTagsProc},
704 {N_("Comments"), "Comments", EditCommentProc},
705 {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc},
706 {"----", NULL, NothingProc},
707 {N_("Board..."), "Board", BoardOptionsProc},
708 {N_("Game List Tags..."), "GameListTags", GameListOptionsProc},
712 MenuItem modeMenu[] = {
713 {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent},
714 {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent},
715 {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent},
716 {N_("Analysis Mode Ctrl+A"), "AnalysisMode", AnalyzeModeProc},
717 {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileProc },
718 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
719 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
720 {N_("Training"), "Training", TrainingEvent},
721 {N_("ICS Client"), "ICSClient", IcsClientEvent},
722 {"----", NULL, NothingProc},
723 {N_("Machine Match"), "MachineMatch", MatchProc},
724 {N_("Pause Pause"), "Pause", PauseEvent},
728 MenuItem actionMenu[] = {
729 {N_("Accept F3"), "Accept", AcceptEvent},
730 {N_("Decline F4"), "Decline", DeclineEvent},
731 {N_("Rematch F12"), "Rematch", RematchEvent},
732 {"----", NULL, NothingProc},
733 {N_("Call Flag F5"), "CallFlag", CallFlagEvent},
734 {N_("Draw F6"), "Draw", DrawEvent},
735 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
736 {N_("Abort F8"),"Abort", AbortEvent},
737 {N_("Resign F9"), "Resign", ResignEvent},
738 {"----", NULL, NothingProc},
739 {N_("Stop Observing F10"), "StopObserving", StopObservingEvent},
740 {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent},
741 {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent},
742 {"----", NULL, NothingProc},
743 {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc},
744 {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc},
745 {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc},
749 MenuItem engineMenu[] = {
750 {N_("Load New 1st Engine ..."), "LoadEngine", LoadEngine1Proc},
751 {N_("Load New 2nd Engine ..."), "LoadEngine", LoadEngine2Proc},
752 {"----", NULL, NothingProc},
753 {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc},
754 {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc},
755 {"----", NULL, NothingProc},
756 {N_("Hint"), "Hint", HintEvent},
757 {N_("Book"), "Book", BookEvent},
758 {"----", NULL, NothingProc},
759 {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent},
760 {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent},
764 MenuItem optionsMenu[] = {
766 {N_("General ..."), "General", OptionsProc},
768 {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc},
769 {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", UciMenuProc},
770 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
771 {N_("ICS ..."), "ICS", IcsOptionsProc},
772 {N_("Match ..."), "Match", MatchOptionsProc},
773 {N_("Load Game ..."), "LoadGame", LoadOptionsProc},
774 {N_("Save Game ..."), "SaveGame", SaveOptionsProc},
775 // {N_(" ..."), "", OptionsProc},
776 {N_("Game List ..."), "GameList", GameListOptionsProc},
777 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
778 {"----", NULL, NothingProc},
779 #ifndef OPTIONSDIALOG
780 {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc},
781 {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc},
782 {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc},
783 {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc},
784 {N_("Auto Flip View"), "AutoFlipView", AutoflipProc},
785 {N_("Blindfold"), "Blindfold", BlindfoldProc},
786 {N_("Flash Moves"), "FlashMoves", FlashMovesProc},
788 {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc},
790 {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc},
791 {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc},
792 {N_("Move Sound"), "MoveSound", MoveSoundProc},
793 // {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc},
794 {N_("One-Click Moving"), "OneClickMoving", OneClickProc},
795 {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc},
796 {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc},
797 {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc},
798 {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc},
799 // {N_("Premove"), "Premove", PremoveProc},
800 {N_("Show Coords"), "ShowCoords", ShowCoordsProc},
801 {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc},
802 {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc},
803 {"----", NULL, NothingProc},
805 {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc},
806 {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc},
810 MenuItem helpMenu[] = {
811 {N_("Info XBoard"), "InfoXBoard", InfoProc},
812 {N_("Man XBoard F1"), "ManXBoard", ManProc},
813 {"----", NULL, NothingProc},
814 {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc},
815 {N_("On-line User Guide"), "On-lineUserGuide", GuideProc},
816 {N_("Development News"), "DevelopmentNews", NewsPageProc},
817 {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc},
818 {"----", NULL, NothingProc},
819 {N_("About XBoard"), "AboutXBoard", AboutProc},
823 MenuItem noMenu[] = {
824 { "", "LoadNextGame", LoadNextGameProc },
825 { "", "LoadPrevGame", LoadPrevGameProc },
826 { "", "ReloadGame", ReloadGameProc },
827 { "", "ReloadPosition", ReloadPositionProc },
828 #ifndef OPTIONSDIALOG
829 { "", "AlwaysQueen", AlwaysQueenProc },
830 { "", "AnimateDragging", AnimateDraggingProc },
831 { "", "AnimateMoving", AnimateMovingProc },
832 { "", "Autoflag", AutoflagProc },
833 { "", "Autoflip", AutoflipProc },
834 { "", "Blindfold", BlindfoldProc },
835 { "", "FlashMoves", FlashMovesProc },
837 { "", "HighlightDragging", HighlightDraggingProc },
839 { "", "HighlightLastMove", HighlightLastMoveProc },
840 // { "", "IcsAlarm", IcsAlarmProc },
841 { "", "MoveSound", MoveSoundProc },
842 { "", "PeriodicUpdates", PeriodicUpdatesProc },
843 { "", "PopupExitMessage", PopupExitMessageProc },
844 { "", "PopupMoveErrors", PopupMoveErrorsProc },
845 // { "", "Premove", PremoveProc },
846 { "", "ShowCoords", ShowCoordsProc },
847 { "", "ShowThinking", ShowThinkingProc },
848 { "", "HideThinking", HideThinkingProc },
849 { "", "TestLegality", TestLegalityProc },
851 { "", "AboutGame", AboutGameEvent },
852 { "", "Debug", DebugProc },
853 { "", "Nothing", NothingProc },
858 {N_("File"), "File", fileMenu},
859 {N_("Edit"), "Edit", editMenu},
860 {N_("View"), "View", viewMenu},
861 {N_("Mode"), "Mode", modeMenu},
862 {N_("Action"), "Action", actionMenu},
863 {N_("Engine"), "Engine", engineMenu},
864 {N_("Options"), "Options", optionsMenu},
865 {N_("Help"), "Help", helpMenu},
870 MenuNameToItem (char *menuName)
873 char buf[MSG_SIZ], *p;
875 static MenuItem a = { NULL, NULL, NothingProc };
876 extern Option mainOptions[];
877 safeStrCpy(buf, menuName, MSG_SIZ);
878 p = strchr(buf, '.');
879 if(!p) menuTab = noMenu; else {
881 for(i=0; menuBar[i].name; i++)
882 if(!strcmp(buf, menuBar[i].name)) break;
883 if(!menuBar[i].name) return NULL; // main menu not found
884 menuTab = menuBar[i].mi;
886 if(*p == NULLCHAR) { a.handle = mainOptions[i+1].handle; return &a; } // main menu bar
887 for(i=0; menuTab[i].string; i++)
888 if(menuTab[i].ref && !strcmp(p, menuTab[i].ref)) return menuTab + i;
889 return NULL; // item not found
893 AppendEnginesToMenu (char *list)
897 if(appData.icsActive || appData.recentEngines <= 0) return;
898 recentEngines = strdup(list);
900 p = strchr(list, '\n'); if(p == NULL) break;
901 if(i == 0) AppendMenuItem("----", 0); // at least one valid item to add
903 AppendMenuItem(list, i);
904 i++; *p = '\n'; list = p + 1;
908 Enables icsEnables[] = {
909 { "File.MailMove", False },
910 { "File.ReloadCMailMessage", False },
911 { "Mode.MachineBlack", False },
912 { "Mode.MachineWhite", False },
913 { "Mode.AnalysisMode", False },
914 { "Mode.AnalyzeFile", False },
915 { "Mode.TwoMachines", False },
916 { "Mode.MachineMatch", False },
918 { "Engine.Hint", False },
919 { "Engine.Book", False },
920 { "Engine.MoveNow", False },
921 #ifndef OPTIONSDIALOG
922 { "PeriodicUpdates", False },
923 { "HideThinking", False },
924 { "PonderNextMove", False },
927 { "Engine.Engine#1Settings", False },
928 { "Engine.Engine#2Settings", False },
929 { "Engine.LoadEngine", False },
930 { "Edit.Annotate", False },
931 { "Options.Match", False },
935 Enables ncpEnables[] = {
936 { "File.MailMove", False },
937 { "File.ReloadCMailMessage", False },
938 { "Mode.MachineWhite", False },
939 { "Mode.MachineBlack", False },
940 { "Mode.AnalysisMode", False },
941 { "Mode.AnalyzeFile", False },
942 { "Mode.TwoMachines", False },
943 { "Mode.MachineMatch", False },
944 { "Mode.ICSClient", False },
945 { "View.ICStextmenu", False },
946 { "View.ICSInputBox", False },
947 { "Action.", False },
948 { "Edit.Revert", False },
949 { "Edit.Annotate", False },
950 { "Engine.Engine#1Settings", False },
951 { "Engine.Engine#2Settings", False },
952 { "Engine.MoveNow", False },
953 { "Engine.RetractMove", False },
954 { "Options.ICS", False },
955 #ifndef OPTIONSDIALOG
956 { "Options.AutoFlag", False },
957 { "Options.AutoFlip View", False },
958 // { "Options.ICSAlarm", False },
959 { "Options.MoveSound", False },
960 { "Options.HideThinking", False },
961 { "Options.PeriodicUpdates", False },
962 { "Options.PonderNextMove", False },
964 { "Engine.Hint", False },
965 { "Engine.Book", False },
969 Enables gnuEnables[] = {
970 { "Mode.ICSClient", False },
971 { "View.ICStextmenu", False },
972 { "View.ICSInputBox", False },
973 { "Action.Accept", False },
974 { "Action.Decline", False },
975 { "Action.Rematch", False },
976 { "Action.Adjourn", False },
977 { "Action.StopExamining", False },
978 { "Action.StopObserving", False },
979 { "Action.UploadtoExamine", False },
980 { "Edit.Revert", False },
981 { "Edit.Annotate", False },
982 { "Options.ICS", False },
984 /* The next two options rely on SetCmailMode being called *after* */
985 /* SetGNUMode so that when GNU is being used to give hints these */
986 /* menu options are still available */
988 { "File.MailMove", False },
989 { "File.ReloadCMailMessage", False },
990 // [HGM] The following have been added to make a switch from ncp to GNU mode possible
991 { "Mode.MachineWhite", True },
992 { "Mode.MachineBlack", True },
993 { "Mode.AnalysisMode", True },
994 { "Mode.AnalyzeFile", True },
995 { "Mode.TwoMachines", True },
996 { "Mode.MachineMatch", True },
997 { "Engine.Engine#1Settings", True },
998 { "Engine.Engine#2Settings", True },
999 { "Engine.Hint", True },
1000 { "Engine.Book", True },
1001 { "Engine.MoveNow", True },
1002 { "Engine.RetractMove", True },
1003 { "Action.", True },
1007 Enables cmailEnables[] = {
1008 { "Action.", True },
1009 { "Action.CallFlag", False },
1010 { "Action.Draw", True },
1011 { "Action.Adjourn", False },
1012 { "Action.Abort", False },
1013 { "Action.StopObserving", False },
1014 { "Action.StopExamining", False },
1015 { "File.MailMove", True },
1016 { "File.ReloadCMailMessage", True },
1020 Enables trainingOnEnables[] = {
1021 { "Edit.EditComment", False },
1022 { "Mode.Pause", False },
1023 { "Edit.Forward", False },
1024 { "Edit.Backward", False },
1025 { "Edit.ForwardtoEnd", False },
1026 { "Edit.BacktoStart", False },
1027 { "Engine.MoveNow", False },
1028 { "Edit.TruncateGame", False },
1032 Enables trainingOffEnables[] = {
1033 { "Edit.EditComment", True },
1034 { "Mode.Pause", True },
1035 { "Edit.Forward", True },
1036 { "Edit.Backward", True },
1037 { "Edit.ForwardtoEnd", True },
1038 { "Edit.BacktoStart", True },
1039 { "Engine.MoveNow", True },
1040 { "Engine.TruncateGame", True },
1044 Enables machineThinkingEnables[] = {
1045 { "File.LoadGame", False },
1046 // { "LoadNextGame", False },
1047 // { "LoadPreviousGame", False },
1048 // { "ReloadSameGame", False },
1049 { "Edit.PasteGame", False },
1050 { "File.LoadPosition", False },
1051 // { "LoadNextPosition", False },
1052 // { "LoadPreviousPosition", False },
1053 // { "ReloadSamePosition", False },
1054 { "Edit.PastePosition", False },
1055 { "Mode.MachineWhite", False },
1056 { "Mode.MachineBlack", False },
1057 { "Mode.TwoMachines", False },
1058 // { "MachineMatch", False },
1059 { "Engine.RetractMove", False },
1063 Enables userThinkingEnables[] = {
1064 { "File.LoadGame", True },
1065 // { "LoadNextGame", True },
1066 // { "LoadPreviousGame", True },
1067 // { "ReloadSameGame", True },
1068 { "Edit.PasteGame", True },
1069 { "File.LoadPosition", True },
1070 // { "LoadNextPosition", True },
1071 // { "LoadPreviousPosition", True },
1072 // { "ReloadSamePosition", True },
1073 { "Edit.PastePosition", True },
1074 { "Mode.MachineWhite", True },
1075 { "Mode.MachineBlack", True },
1076 { "Mode.TwoMachines", True },
1077 // { "MachineMatch", True },
1078 { "Engine.RetractMove", True },
1085 SetMenuEnables(icsEnables);
1088 if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
1089 EnableMenuItem("Analysis Mode", True);
1090 EnableMenuItem("Engine #1 Settings", True);
1098 SetMenuEnables(ncpEnables);
1104 SetMenuEnables(gnuEnables);
1110 SetMenuEnables(cmailEnables);
1114 SetTrainingModeOn ()
1116 SetMenuEnables(trainingOnEnables);
1117 if (appData.showButtonBar) {
1118 EnableButtonBar(False);
1124 SetTrainingModeOff ()
1126 SetMenuEnables(trainingOffEnables);
1127 if (appData.showButtonBar) {
1128 EnableButtonBar(True);
1133 SetUserThinkingEnables ()
1135 if (appData.noChessProgram) return;
1136 SetMenuEnables(userThinkingEnables);
1140 SetMachineThinkingEnables ()
1142 if (appData.noChessProgram) return;
1143 SetMenuEnables(machineThinkingEnables);
1145 case MachinePlaysBlack:
1146 case MachinePlaysWhite:
1147 case TwoMachinesPlay:
1148 EnableMenuItem(ModeToWidgetName(gameMode), True);
1156 GreyRevert (Boolean grey)
1158 MarkMenuItem("Edit.Revert", !grey);
1159 MarkMenuItem("Edit.Annotate", !grey);
1163 ModeToWidgetName (GameMode mode)
1166 case BeginningOfGame:
1167 if (appData.icsActive)
1168 return "Mode.ICSClient";
1169 else if (appData.noChessProgram ||
1170 *appData.cmailGameName != NULLCHAR)
1171 return "Mode.EditGame";
1173 return "Mode.MachineBlack";
1174 case MachinePlaysBlack:
1175 return "Mode.MachineBlack";
1176 case MachinePlaysWhite:
1177 return "Mode.MachineWhite";
1179 return "Mode.AnalysisMode";
1181 return "Mode.AnalyzeFile";
1182 case TwoMachinesPlay:
1183 return "Mode.TwoMachines";
1185 return "Mode.EditGame";
1186 case PlayFromGameFile:
1187 return "File.LoadGame";
1189 return "Mode.EditPosition";
1191 return "Mode.Training";
1192 case IcsPlayingWhite:
1193 case IcsPlayingBlack:
1197 return "Mode.ICSClient";
1207 #ifndef OPTIONSDIALOG
1208 if (appData.alwaysPromoteToQueen) {
1209 MarkMenuItem("Options.Always Queen", True);
1211 if (appData.animateDragging) {
1212 MarkMenuItem("Options.Animate Dragging", True);
1214 if (appData.animate) {
1215 MarkMenuItem("Options.Animate Moving", True);
1217 if (appData.autoCallFlag) {
1218 MarkMenuItem("Options.Auto Flag", True);
1220 if (appData.autoFlipView) {
1221 XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True);
1223 if (appData.blindfold) {
1224 MarkMenuItem("Options.Blindfold", True);
1226 if (appData.flashCount > 0) {
1227 MarkMenuItem("Options.Flash Moves", True);
1230 if (appData.highlightDragging) {
1231 MarkMenuItem("Options.Highlight Dragging", True);
1234 if (appData.highlightLastMove) {
1235 MarkMenuItem("Options.Highlight Last Move", True);
1237 if (appData.highlightMoveWithArrow) {
1238 MarkMenuItem("Options.Arrow", True);
1240 // if (appData.icsAlarm) {
1241 // MarkMenuItem("Options.ICS Alarm", True);
1243 if (appData.ringBellAfterMoves) {
1244 MarkMenuItem("Options.Move Sound", True);
1246 if (appData.oneClick) {
1247 MarkMenuItem("Options.OneClick", True);
1249 if (appData.periodicUpdates) {
1250 MarkMenuItem("Options.Periodic Updates", True);
1252 if (appData.ponderNextMove) {
1253 MarkMenuItem("Options.Ponder Next Move", True);
1255 if (appData.popupExitMessage) {
1256 MarkMenuItem("Options.Popup Exit Message", True);
1258 if (appData.popupMoveErrors) {
1259 MarkMenuItem("Options.Popup Move Errors", True);
1261 // if (appData.premove) {
1262 // MarkMenuItem("Options.Premove", True);
1264 if (appData.showCoords) {
1265 MarkMenuItem("Options.Show Coords", True);
1267 if (appData.hideThinkingFromHuman) {
1268 MarkMenuItem("Options.Hide Thinking", True);
1270 if (appData.testLegality) {
1271 MarkMenuItem("Options.Test Legality", True);
1274 if (saveSettingsOnExit) {
1275 MarkMenuItem("Options.SaveSettingsonExit", True);