-
Notifications
You must be signed in to change notification settings - Fork 5
/
menus.c
1343 lines (1218 loc) · 41.3 KB
/
menus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* menus.c -- platform-indendent menu handling code for XBoard
*
* Copyright 1991 by Digital Equipment Corporation, Maynard,
* Massachusetts.
*
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
* 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free
* Software Foundation, Inc.
*
* The following terms apply to Digital Equipment Corporation's copyright
* interest in XBoard:
* ------------------------------------------------------------------------
* All Rights Reserved
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Digital not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* ------------------------------------------------------------------------
*
* The following terms apply to the enhanced version of XBoard
* distributed by the Free Software Foundation:
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* GNU XBoard is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/. *
*
*------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
#define HIGHDRAG 1
#include "config.h"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <math.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else /* not STDC_HEADERS */
extern char *getenv();
# if HAVE_STRING_H
# include <string.h>
# else /* not HAVE_STRING_H */
# include <strings.h>
# endif /* not HAVE_STRING_H */
#endif /* not STDC_HEADERS */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#if ENABLE_NLS
#include <locale.h>
#endif
// [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
#include "common.h"
#include "frontend.h"
#include "backend.h"
#include "menus.h"
#include "gettext.h"
#ifdef ENABLE_NLS
# define _(s) gettext (s)
# define N_(s) gettext_noop (s)
#else
# define _(s) (s)
# define N_(s) s
#endif
/*
* Button/menu procedures
*/
char *gameCopyFilename, *gamePasteFilename;
Boolean saveSettingsOnExit;
char *settingsFileName;
char gamesDir[MSG_SIZ], positionsDir[MSG_SIZ], textureDir[MSG_SIZ], bookDir[MSG_SIZ], piecesDir[MSG_SIZ];
static int
LoadGamePopUp (FILE *f, int gameNumber, char *title)
{
cmailMsgLoaded = FALSE;
if (gameNumber == 0) {
int error = GameListBuild(f);
if (error) {
DisplayError(_("Cannot build game list"), error);
} else if (!ListEmpty(&gameList) &&
((ListGame *) gameList.tailPred)->number > 1) {
GameListPopUp(f, title);
return TRUE;
}
GameListDestroy();
gameNumber = 1;
}
return LoadGame(f, gameNumber, title, FALSE);
}
void
LoadGameProc ()
{
if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
Reset(FALSE, TRUE);
}
FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb");
}
void
LoadNextGameProc ()
{
ReloadGame(1);
}
void
LoadPrevGameProc ()
{
ReloadGame(-1);
}
void
ReloadGameProc ()
{
ReloadGame(0);
}
void
LoadNextPositionProc ()
{
ReloadPosition(1);
}
void
LoadPrevPositionProc ()
{
ReloadPosition(-1);
}
void
ReloadPositionProc ()
{
ReloadPosition(0);
}
void
LoadPositionProc()
{
static char buf[MSG_SIZ];
if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
Reset(FALSE, TRUE);
}
snprintf(buf, MSG_SIZ, "%s/", appData.positionDir);
FileNamePopUp(_("Load position file name?"), buf, ".fen .epd .pos", LoadPosition, "rb");
}
void
SaveGameProc ()
{
FileNamePopUp(_("Save game file name?"),
DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
appData.oldSaveStyle ? ".game" : ".pgn",
SaveGame, "a");
}
void
SavePositionProc ()
{
FileNamePopUp(_("Save position file name?"),
DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
appData.oldSaveStyle ? ".pos" : ".fen",
SavePosition, "a");
}
void
ReloadCmailMsgProc ()
{
ReloadCmailMsgEvent(FALSE);
}
void
CopyFENToClipboard ()
{ // wrapper to make call from back-end possible
CopyPositionProc();
}
void
CopyPositionProc ()
{
static char *selected_fen_position=NULL;
if(gameMode == EditPosition) EditPositionDone(TRUE);
if (selected_fen_position) free(selected_fen_position);
selected_fen_position = (char *)PositionToFEN(currentMove, NULL, 1);
if (!selected_fen_position) return;
CopySomething(selected_fen_position);
}
void
CopyGameProc ()
{
int ret;
ret = SaveGameToFile(gameCopyFilename, FALSE);
if (!ret) return;
CopySomething(NULL);
}
void
CopyGameListProc ()
{
if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
CopySomething(NULL);
}
void
AutoSaveGame ()
{
SaveGameProc();
}
void
QuitProc ()
{
ExitEvent(0);
}
void
MatchProc ()
{
static Enables matchOff[] = { { "Mode.MachineMatch", False }, { NULL, False } };
if(matchMode) SetMenuEnables(matchOff);
MatchEvent(2);
}
void
AdjuWhiteProc ()
{
UserAdjudicationEvent(+1);
}
void
AdjuBlackProc ()
{
UserAdjudicationEvent(-1);
}
void
AdjuDrawProc ()
{
UserAdjudicationEvent(0);
}
void
RevertProc ()
{
RevertEvent(False);
}
void
AnnotateProc ()
{
RevertEvent(True);
}
void
FlipViewProc ()
{
if(twoBoards) { partnerUp = 1; DrawPosition(True, NULL); partnerUp = 0; }
flipView = !flipView;
DrawPosition(True, NULL);
}
void
SaveOnExitProc ()
{
saveSettingsOnExit = !saveSettingsOnExit;
MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
}
void
SaveSettingsProc ()
{
SaveSettings(settingsFileName);
}
void
BugReportProc ()
{
char buf[MSG_SIZ];
snprintf(buf, MSG_SIZ, "%s mailto:[email protected]", appData.sysOpen);
system(buf);
}
void
GuideProc ()
{
char buf[MSG_SIZ];
snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
system(buf);
}
void
HomePageProc ()
{
char buf[MSG_SIZ];
snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
system(buf);
}
void
NewsPageProc ()
{
char buf[MSG_SIZ];
snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
system(buf);
}
void
AboutProc ()
{
char buf[2 * MSG_SIZ];
#if ZIPPY
char *zippy = _(" (with Zippy code)");
#else
char *zippy = "";
#endif
snprintf(buf, sizeof(buf),
_("%s%s\n\n"
"Copyright 1991 Digital Equipment Corporation\n"
"Enhancements Copyright 1992-2016 Free Software Foundation\n"
"Enhancements Copyright 2005 Alessandro Scotti\n\n"
"%s is free software and carries NO WARRANTY;"
"see the file COPYING for more information.\n\n"
"Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
"Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
"Report bugs via email at: <[email protected]>\n\n"
),
programVersion, zippy, PACKAGE);
ErrorPopUp(_("About XBoard"), buf, FALSE);
}
void
DebugProc ()
{
appData.debugMode = !appData.debugMode;
if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed
if(!appData.debugMode) fclose(debugFP);
else {
debugFP = fopen(appData.nameOfDebugFile, "w");
if(debugFP == NULL) debugFP = stderr;
else setbuf(debugFP, NULL);
}
}
void
EditEngineProc ()
{
EditAnyPopUp(firstChessProgramNames, &firstChessProgramNames, _("Registered Engines"));
}
void
EditThemesProc ()
{
EditAnyPopUp(appData.themeNames, &appData.themeNames, _("Predefined Themes"));
}
void
EditMenuProc ()
{
EditAnyPopUp(icsTextMenuString, &icsTextMenuString, _("ICS Text-Menu Definition"));
}
void
MuteProc ()
{
mute = !mute;
MarkMenuItem("Options.Mute", mute);
}
void
NothingProc ()
{
return;
}
#ifdef OPTIONSDIALOG
# define MARK_MENU_ITEM(X,Y)
#else
# define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
#endif
void
PonderNextMoveProc ()
{
PonderNextMoveEvent(!appData.ponderNextMove);
MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
}
void
AlwaysQueenProc ()
{
appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen);
}
void
AnimateDraggingProc ()
{
appData.animateDragging = !appData.animateDragging;
if (appData.animateDragging) CreateAnimVars();
MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging);
}
void
AnimateMovingProc ()
{
appData.animate = !appData.animate;
if (appData.animate) CreateAnimVars();
MARK_MENU_ITEM("Options.AnimateMoving", appData.animate);
}
void
AutoflagProc ()
{
appData.autoCallFlag = !appData.autoCallFlag;
MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag);
}
void
AutoflipProc ()
{
appData.autoFlipView = !appData.autoFlipView;
MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView);
}
void
BlindfoldProc ()
{
appData.blindfold = !appData.blindfold;
MARK_MENU_ITEM("Options.Blindfold", appData.blindfold);
DrawPosition(True, NULL);
}
void
TestLegalityProc ()
{
appData.testLegality = !appData.testLegality;
MARK_MENU_ITEM("Options.TestLegality", appData.testLegality);
}
void
FlashMovesProc ()
{
if (appData.flashCount == 0) {
appData.flashCount = 3;
} else {
appData.flashCount = -appData.flashCount;
}
MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0);
}
#if HIGHDRAG
void
HighlightDraggingProc ()
{
appData.highlightDragging = !appData.highlightDragging;
MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging);
}
#endif
void
HighlightLastMoveProc ()
{
appData.highlightLastMove = !appData.highlightLastMove;
MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove);
}
void
HighlightArrowProc ()
{
appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow);
}
void
IcsAlarmProc ()
{
appData.icsAlarm = !appData.icsAlarm;
// MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm);
}
void
MoveSoundProc ()
{
appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves);
}
void
OneClickProc ()
{
appData.oneClick = !appData.oneClick;
MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick);
}
void
PeriodicUpdatesProc ()
{
PeriodicUpdatesEvent(!appData.periodicUpdates);
MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates);
}
void
PopupExitMessageProc ()
{
appData.popupExitMessage = !appData.popupExitMessage;
MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage);
}
void
PopupMoveErrorsProc ()
{
appData.popupMoveErrors = !appData.popupMoveErrors;
MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors);
}
void
PremoveProc ()
{
appData.premove = !appData.premove;
// MARK_MENU_ITEM("Options.Premove", appData.premove);
}
void
ShowCoordsProc ()
{
appData.showCoords = !appData.showCoords;
MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords);
DrawPosition(True, NULL);
}
void
ShowThinkingProc ()
{
appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
ShowThinkingEvent();
}
void
HideThinkingProc ()
{
appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
ShowThinkingEvent();
MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
}
void
CreateBookDelayed ()
{
ScheduleDelayedEvent(CreateBookEvent, 50);
}
void
SaveSelectedProc ()
{
FileNamePopUp(_("Save game file name?"),
"",
".pgn",
SaveSelected, "a");
}
/*
* Menu definition tables
*/
MenuItem fileMenu[] = {
{N_("New Game"), "<Ctrl>n", "NewGame", ResetGameEvent},
{N_("New Shuffle Game..."), NULL, "NewShuffleGame", ShuffleMenuProc},
{N_("New Variant..."), "<Alt><Shift>v", "NewVariant", NewVariantProc},// [HGM] variant: not functional yet
{"----", NULL, NULL, NothingProc},
{N_("Load Game"), "<Ctrl>o", "LoadGame", LoadGameProc, CHECK},
{N_("Load Position"), "<Ctrl><Shift>o", "LoadPosition", LoadPositionProc},
{N_("Next Position"), "<Shift>Page_Down", "LoadNextPosition", LoadNextPositionProc},
{N_("Prev Position"), "<Shift>Page_Up", "LoadPreviousPosition", LoadPrevPositionProc},
{"----", NULL, NULL, NothingProc},
{N_("Save Game"), "<Ctrl>s", "SaveGame", SaveGameProc},
{N_("Save Position"), "<Ctrl><Shift>s", "SavePosition", SavePositionProc},
{N_("Save Selected Games"), NULL, "SaveSelected", SaveSelectedProc},
{N_("Save Games as Book"), NULL, "CreateBook", CreateBookDelayed},
{"----", NULL, NULL, NothingProc},
{N_("Mail Move"), NULL, "MailMove", MailMoveEvent},
{N_("Reload CMail Message"), NULL, "ReloadCMailMessage", ReloadCmailMsgProc},
{"----", NULL, NULL, NothingProc},
{N_("Quit "), "<Ctrl>q", "Quit", QuitProc},
{NULL, NULL, NULL, NULL}
};
MenuItem editMenu[] = {
{N_("Copy Game"), "<Ctrl>c", "CopyGame", CopyGameProc},
{N_("Copy Position"), "<Ctrl><Shift>c", "CopyPosition", CopyPositionProc},
{N_("Copy Game List"), NULL, "CopyGameList", CopyGameListProc},
{"----", NULL, NULL, NothingProc},
{N_("Paste Game"), "<Ctrl>v", "PasteGame", PasteGameProc},
{N_("Paste Position"), "<Ctrl><Shift>v", "PastePosition", PastePositionProc},
{"----", NULL, NULL, NothingProc},
{N_("Edit Game"), "<Ctrl>e", "EditGame", EditGameEvent},
{N_("Edit Position"), "<Ctrl><Shift>e", "EditPosition", EditPositionEvent},
{N_("Edit Tags"), NULL, "EditTags", EditTagsProc},
{N_("Edit Comment"), NULL, "EditComment", EditCommentProc},
{N_("Edit Book"), NULL, "EditBook", EditBookEvent},
{"----", NULL, NULL, NothingProc},
{N_("Revert"), "Home", "Revert", RevertProc},
{N_("Annotate"), NULL, "Annotate", AnnotateProc},
{N_("Truncate Game"), "End", "TruncateGame", TruncateGameEvent},
{"----", NULL, NULL, NothingProc},
{N_("Backward"), "<Alt>Left", "Backward", BackwardEvent},
{N_("Forward"), "<Alt>Right", "Forward", ForwardEvent},
{N_("Back to Start"), "<Alt>Home", "BacktoStart", ToStartEvent},
{N_("Forward to End"), "<Alt>End", "ForwardtoEnd", ToEndEvent},
{NULL, NULL, NULL, NULL}
};
MenuItem viewMenu[] = {
{N_("Flip View"), "F2", "FlipView", FlipViewProc, CHECK},
{"----", NULL, NULL, NothingProc},
{N_("Engine Output"), "<Alt><Shift>o", "EngineOutput", EngineOutputProc, CHECK},
{N_("Move History"), "<Alt><Shift>h", "MoveHistory", HistoryShowProc, CHECK}, // [HGM] hist: activate 4.2.7 code
{N_("Evaluation Graph"), "<Alt><Shift>e", "EvaluationGraph", EvalGraphProc, CHECK},
{N_("Game List"), "<Alt><Shift>g", "GameList", ShowGameListProc, CHECK},
{"----", NULL, NULL, NothingProc},
{N_("Tags"), NULL, "Tags", EditTagsProc, CHECK},
{N_("Comments"), NULL, "Comments", EditCommentProc, CHECK},
{N_("ICS Input Box"), NULL, "ICSInputBox", IcsInputBoxProc, CHECK},
{N_("ICS/Chat Console"), NULL, "OpenChatWindow", ChatProc, CHECK},
{N_("ICS text menu"), NULL, "ICStextmenu", IcsTextProc, CHECK},
{N_("Edit ICS menu..."), NULL, "EditTextMenu", EditMenuProc},
{"----", NULL, NULL, NothingProc},
{N_("Edit Theme List..."), NULL, "EditThemeList", EditThemesProc},
{N_("Board..."), NULL, "Board", BoardOptionsProc},
{N_("Fonts..."), NULL, "Fonts", FontsProc},
{N_("Game List Tags..."), NULL, "GameListTags", GameListOptionsProc},
{NULL, NULL, NULL, NULL}
};
MenuItem modeMenu[] = {
{N_("Machine White"), "<Ctrl>w", "MachineWhite", MachineWhiteEvent, RADIO },
{N_("Machine Black"), "<Ctrl>b", "MachineBlack", MachineBlackEvent, RADIO },
{N_("Two Machines"), "<Ctrl>t", "TwoMachines", TwoMachinesEvent, RADIO },
{N_("Analysis Mode"), "<Ctrl>a", "AnalysisMode", (MenuProc*) AnalyzeModeEvent, RADIO },
{N_("Analyze Game"), "<Ctrl>g", "AnalyzeFile", AnalyzeFileEvent, RADIO },
{N_("Edit Game"), "<Ctrl>e", "EditGame", EditGameEvent, RADIO },
{N_("Edit Position"), "<Ctrl><Shift>e", "EditPosition", EditPositionEvent, RADIO },
{N_("Training"), NULL, "Training", TrainingEvent, RADIO },
{N_("ICS Client"), NULL, "ICSClient", IcsClientEvent, RADIO },
{"----", NULL, NULL, NothingProc},
{N_("Machine Match"), NULL, "MachineMatch", MatchProc, CHECK },
{N_("Pause"), "Pause", "Pause", PauseEvent, CHECK },
{NULL, NULL, NULL, NULL}
};
MenuItem actionMenu[] = {
{N_("Accept"), "F3", "Accept", AcceptEvent},
{N_("Decline"), "F4", "Decline", DeclineEvent},
{N_("Rematch"), "F12", "Rematch", RematchEvent},
{"----", NULL, NULL, NothingProc},
{N_("Call Flag"), "F5", "CallFlag", CallFlagEvent},
{N_("Draw"), "F6", "Draw", DrawEvent},
{N_("Adjourn"), "F7", "Adjourn", AdjournEvent},
{N_("Abort"), "F8", "Abort", AbortEvent},
{N_("Resign"), "F9", "Resign", ResignEvent},
{"----", NULL, NULL, NothingProc},
{N_("Stop Observing"), "F10", "StopObserving", StopObservingEvent},
{N_("Stop Examining"), "F11", "StopExamining", StopExaminingEvent},
{N_("Upload to Examine"), NULL, "UploadtoExamine", UploadGameEvent},
{"----", NULL, NULL, NothingProc},
{N_("Adjudicate to White"), NULL, "AdjudicatetoWhite", AdjuWhiteProc},
{N_("Adjudicate to Black"), NULL, "AdjudicatetoBlack", AdjuBlackProc},
{N_("Adjudicate Draw"), NULL, "AdjudicateDraw", AdjuDrawProc},
{NULL, NULL, NULL, NULL}
};
MenuItem engineMenu[100] = {
{N_("Edit Engine List..."), NULL, "EditEngList", EditEngineProc},
{"----", NULL, NULL, NothingProc},
{N_("Load New 1st Engine..."), NULL, "LoadNew1stEngine", LoadEngine1Proc},
{N_("Load New 2nd Engine..."), NULL, "LoadNew2ndEngine", LoadEngine2Proc},
{"----", NULL, NULL, NothingProc},
{N_("Engine #1 Settings..."), NULL, "Engine#1Settings", FirstSettingsProc},
{N_("Engine #2 Settings..."), NULL, "Engine#2Settings", SecondSettingsProc},
{N_("Common Settings..."), "<Alt><Shift>u","CommonEngine", UciMenuProc},
{"----", NULL, NULL, NothingProc},
{N_("Hint"), NULL, "Hint", HintEvent},
{N_("Book"), NULL, "Book", BookEvent},
{"----", NULL, NULL, NothingProc},
{N_("Move Now"), "<Ctrl>m", "MoveNow", MoveNowEvent},
{N_("Retract Move"), "<Ctrl>x", "RetractMove", RetractMoveEvent},
{NULL, NULL, NULL, NULL}
};
MenuItem optionsMenu[] = {
{N_("Mute all Sounds"), NULL, "Mute", MuteProc, CHECK},
{"----", NULL, NULL, NothingProc},
#ifdef OPTIONSDIALOG
{N_("General..."), NULL, "General", OptionsProc},
#endif
{N_("Time Control..."), "<Alt><Shift>t", "TimeControl", TimeControlProc},
{N_("Adjudications..."), "<Alt><Shift>j", "Adjudications", EngineMenuProc},
{N_("ICS..."), NULL, "ICS", IcsOptionsProc},
{N_("Tournament..."), NULL, "Match", MatchOptionsProc},
{N_("Load Game..."), NULL, "LoadGame", LoadOptionsProc},
{N_("Save Game..."), NULL, "SaveGame", SaveOptionsProc},
{N_("Game List..."), NULL, "GameList", GameListOptionsProc},
{N_("Sounds..."), NULL, "Sounds", SoundOptionsProc},
{"----", NULL, NULL, NothingProc},
#ifndef OPTIONSDIALOG
{N_("Always Queen"), "<Ctrl><Shift>q", "AlwaysQueen", AlwaysQueenProc},
{N_("Animate Dragging"), NULL, "AnimateDragging", AnimateDraggingProc},
{N_("Animate Moving"), "<Ctrl><Shift>a", "AnimateMoving", AnimateMovingProc},
{N_("Auto Flag"), "<Ctrl><Shift>f", "AutoFlag", AutoflagProc},
{N_("Auto Flip View"), NULL, "AutoFlipView", AutoflipProc},
{N_("Blindfold"), NULL, "Blindfold", BlindfoldProc},
{N_("Flash Moves"), NULL, "FlashMoves", FlashMovesProc},
#if HIGHDRAG
{N_("Highlight Dragging"), NULL, "HighlightDragging", HighlightDraggingProc},
#endif
{N_("Highlight Last Move"), NULL, "HighlightLastMove", HighlightLastMoveProc},
{N_("Highlight With Arrow"), NULL, "HighlightWithArrow", HighlightArrowProc},
{N_("Move Sound"), NULL, "MoveSound", MoveSoundProc},
{N_("One-Click Moving"), NULL, "OneClickMoving", OneClickProc},
{N_("Periodic Updates"), NULL, "PeriodicUpdates", PeriodicUpdatesProc},
{N_("Ponder Next Move"), "<Ctrl><Shift>p", "PonderNextMove", PonderNextMoveProc},
{N_("Popup Exit Message"), NULL, "PopupExitMessage", PopupExitMessageProc},
{N_("Popup Move Errors"), NULL, "PopupMoveErrors", PopupMoveErrorsProc},
{N_("Show Coords"), NULL, "ShowCoords", ShowCoordsProc},
{N_("Hide Thinking"), "<Ctrl><Shift>h", "HideThinking", HideThinkingProc},
{N_("Test Legality"), "<Ctrl><Shift>l", "TestLegality", TestLegalityProc},
{"----", NULL, NULL, NothingProc},
#endif
{N_("Save Settings Now"), NULL, "SaveSettingsNow", SaveSettingsProc},
{N_("Save Settings on Exit"), NULL, "SaveSettingsonExit", SaveOnExitProc, CHECK },
{NULL, NULL, NULL, NULL}
};
MenuItem helpMenu[] = {
{N_("Info XBoard"), NULL, "InfoXBoard", InfoProc},
{N_("Man XBoard"), "F1", "ManXBoard", ManProc},
{"----", NULL, NULL, NothingProc},
{N_("XBoard Home Page"), NULL, "XBoardHomePage", HomePageProc},
{N_("On-line User Guide"), NULL, "On-lineUserGuide", GuideProc},
{N_("Development News"), NULL, "DevelopmentNews", NewsPageProc},
{N_("e-Mail Bug Report"), NULL, "e-MailBugReport", BugReportProc},
{"----", NULL, NULL, NothingProc},
{N_("About XBoard"), NULL, "AboutXBoard", AboutProc},
{NULL, NULL, NULL, NULL}
};
MenuItem noMenu[] = {
{ "", "<Alt>Next" ,"LoadNextGame", LoadNextGameProc },
{ "", "<Alt>Prior" ,"LoadPrevGame", LoadPrevGameProc },
{ "", NULL,"ReloadGame", ReloadGameProc },
{ "", NULL,"ReloadPosition", ReloadPositionProc },
#ifndef OPTIONSDIALOG
{ "", NULL,"AlwaysQueen", AlwaysQueenProc },
{ "", NULL,"AnimateDragging", AnimateDraggingProc },
{ "", NULL,"AnimateMoving", AnimateMovingProc },
{ "", NULL,"Autoflag", AutoflagProc },
{ "", NULL,"Autoflip", AutoflipProc },
{ "", NULL,"Blindfold", BlindfoldProc },
{ "", NULL,"FlashMoves", FlashMovesProc },
#if HIGHDRAG
{ "", NULL,"HighlightDragging", HighlightDraggingProc },
#endif
{ "", NULL,"HighlightLastMove", HighlightLastMoveProc },
{ "", NULL,"MoveSound", MoveSoundProc },
{ "", NULL,"PeriodicUpdates", PeriodicUpdatesProc },
{ "", NULL,"PopupExitMessage", PopupExitMessageProc },
{ "", NULL,"PopupMoveErrors", PopupMoveErrorsProc },
{ "", NULL,"ShowCoords", ShowCoordsProc },
{ "", NULL,"ShowThinking", ShowThinkingProc },
{ "", NULL,"HideThinking", HideThinkingProc },
{ "", NULL,"TestLegality", TestLegalityProc },
#endif
{ "", NULL,"AboutGame", AboutGameEvent },
{ "", "<Ctrl>d" ,"DebugProc", DebugProc },
{ "", NULL,"Nothing", NothingProc },
{NULL, NULL, NULL, NULL}
};
Menu menuBar[] = {
{N_("File"), "File", fileMenu},
{N_("Edit"), "Edit", editMenu},
{N_("View"), "View", viewMenu},
{N_("Mode"), "Mode", modeMenu},
{N_("Action"), "Action", actionMenu},
{N_("Engine"), "Engine", engineMenu},
{N_("Options"), "Options", optionsMenu},
{N_("Help"), "Help", helpMenu},
{NULL, NULL, NULL},
{ "", "None", noMenu}
};
MenuItem *
MenuNameToItem (char *menuName)
{
int i=0;
char buf[MSG_SIZ], *p;
MenuItem *menuTab;
static MenuItem a = { NULL, NULL, NULL, NothingProc };
extern Option mainOptions[];
safeStrCpy(buf, menuName, MSG_SIZ);
p = strchr(buf, '.');
if(!p) menuTab = noMenu, p = menuName; else {
*p++ = NULLCHAR;
for(i=0; menuBar[i].name; i++)
if(!strcmp(buf, menuBar[i].name)) break;
if(!menuBar[i].name) return NULL; // main menu not found
menuTab = menuBar[i].mi;
}
if(*p == NULLCHAR) { a.handle = mainOptions[i+1].handle; return &a; } // main menu bar
for(i=0; menuTab[i].string; i++)
if(menuTab[i].ref && !strcmp(p, menuTab[i].ref)) return menuTab + i;
return NULL; // item not found
}
int firstEngineItem;
void
AppendEnginesToMenu (char *list)
{
int i=0;
char *p;
if(appData.icsActive || appData.recentEngines <= 0) return;
for(firstEngineItem=0; engineMenu[firstEngineItem].string; firstEngineItem++);
recentEngines = strdup(list);
while (*list) {
p = strchr(list, '\n'); if(p == NULL) break;
if(i == 0) engineMenu[firstEngineItem++].string = "----"; // at least one valid item to add
*p = 0;
if(firstEngineItem + i < 99)
engineMenu[firstEngineItem+i].string = strdup(list); // just set name; MenuProc stays NULL
i++; *p = '\n'; list = p + 1;
}
}
Enables icsEnables[] = {
{ "File.MailMove", False },
{ "File.ReloadCMailMessage", False },
{ "Mode.MachineBlack", False },
{ "Mode.MachineWhite", False },
{ "Mode.AnalysisMode", False },
{ "Mode.AnalyzeFile", False },
{ "Mode.TwoMachines", False },
{ "Mode.MachineMatch", False },
#if !ZIPPY
{ "Engine.Hint", False },
{ "Engine.Book", False },
{ "Engine.MoveNow", False },
#ifndef OPTIONSDIALOG
{ "PeriodicUpdates", False },
{ "HideThinking", False },
{ "PonderNextMove", False },
#endif
#endif
{ "Engine.Engine#1Settings", False },
{ "Engine.Engine#2Settings", False },
{ "Engine.Load1stEngine", False },
{ "Engine.Load2ndEngine", False },
{ "Edit.Annotate", False },
{ "Options.Match", False },
{ NULL, False }
};
Enables ncpEnables[] = {
{ "File.MailMove", False },
{ "File.ReloadCMailMessage", False },
{ "Mode.MachineWhite", False },
{ "Mode.MachineBlack", False },
{ "Mode.AnalysisMode", False },
{ "Mode.AnalyzeFile", False },
{ "Mode.TwoMachines", False },
{ "Mode.MachineMatch", False },
{ "Mode.ICSClient", False },
{ "View.ICStextmenu", False },
{ "View.ICSInputBox", False },
{ "View.OpenChatWindow", False },
{ "Action.", False },
{ "Edit.Revert", False },
{ "Edit.Annotate", False },
{ "Engine.Engine#1Settings", False },
{ "Engine.Engine#2Settings", False },
{ "Engine.MoveNow", False },
{ "Engine.RetractMove", False },
{ "Options.ICS", False },
#ifndef OPTIONSDIALOG
{ "Options.AutoFlag", False },
{ "Options.AutoFlip View", False },
// { "Options.ICSAlarm", False },
{ "Options.MoveSound", False },
{ "Options.HideThinking", False },
{ "Options.PeriodicUpdates", False },
{ "Options.PonderNextMove", False },
#endif
{ "Engine.Hint", False },
{ "Engine.Book", False },
{ NULL, False }
};
Enables gnuEnables[] = {
{ "Mode.ICSClient", False },
{ "View.ICStextmenu", False },
{ "View.ICSInputBox", False },
{ "View.OpenChatWindow", False },
{ "Action.Accept", False },
{ "Action.Decline", False },
{ "Action.Rematch", False },
{ "Action.Adjourn", False },
{ "Action.StopExamining", False },
{ "Action.StopObserving", False },
{ "Action.UploadtoExamine", False },
{ "Edit.Revert", False },
{ "Edit.Annotate", False },
{ "Options.ICS", False },
/* The next two options rely on SetCmailMode being called *after* */
/* SetGNUMode so that when GNU is being used to give hints these */
/* menu options are still available */
{ "File.MailMove", False },
{ "File.ReloadCMailMessage", False },
// [HGM] The following have been added to make a switch from ncp to GNU mode possible
{ "Mode.MachineWhite", True },
{ "Mode.MachineBlack", True },
{ "Mode.AnalysisMode", True },
{ "Mode.AnalyzeFile", True },
{ "Mode.TwoMachines", True },
{ "Mode.MachineMatch", True },
{ "Engine.Engine#1Settings", True },
{ "Engine.Engine#2Settings", True },
{ "Engine.Hint", True },
{ "Engine.Book", True },
{ "Engine.MoveNow", True },
{ "Engine.RetractMove", True },
{ "Action.", True },
{ NULL, False }
};
Enables cmailEnables[] = {
{ "Action.", True },
{ "Action.CallFlag", False },
{ "Action.Draw", True },
{ "Action.Adjourn", False },
{ "Action.Abort", False },
{ "Action.StopObserving", False },
{ "Action.StopExamining", False },
{ "File.MailMove", True },
{ "File.ReloadCMailMessage", True },
{ NULL, False }
};
Enables trainingOnEnables[] = {
{ "Edit.EditComment", False },
{ "Mode.Pause", False },
{ "Edit.Forward", False },
{ "Edit.Backward", False },
{ "Edit.ForwardtoEnd", False },