X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=1f17046185bfb2b38b50365983015d54f308c3b6;hb=fa76217dec3666d46e537483a60ea7b9e9568e33;hp=ca743136fb5904fb3dadaa3dd356477d4a819a7e;hpb=86517e539f33650be656c482020a878fec0723c9;p=xboard.git diff --git a/xboard.c b/xboard.c index ca74313..1f17046 100644 --- a/xboard.c +++ b/xboard.c @@ -193,6 +193,15 @@ extern char *getenv(); #include "xgamelist.h" #include "xhistory.h" #include "xedittags.h" +#include "gettext.h" + +// must be moved to xengineoutput.h + +void EngineOutputProc P((Widget w, XEvent *event, + String *prms, Cardinal *nprms)); + +void EngineOutputPopDown(); + #ifdef __EMX__ #ifndef HAVE_USLEEP @@ -201,6 +210,14 @@ extern char *getenv(); #define usleep(t) _sleep2(((t)+500)/1000) #endif +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + typedef struct { String string; XtActionProc proc; @@ -385,6 +402,8 @@ void ShowCoordsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void ShowThinkingProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void HideThinkingProc P((Widget w, XEvent *event, String *prms, + Cardinal *nprms)); void TestLegalityProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void InfoProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); @@ -409,7 +428,20 @@ static void DragPieceMove P((int x, int y)); static void DragPieceEnd P((int x, int y)); static void DrawDragPiece P((void)); char *ModeToWidgetName P((GameMode mode)); - +void EngineOutputUpdate( FrontEndProgramStats * stats ); +void ShuffleMenuProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void EngineMenuProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void UciMenuProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void TimeControlProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void NewVariantProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void FirstSettingsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void SecondSettingsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void ShufflePopDown P(()); +void EnginePopDown P(()); +void UciPopDown P(()); +void TimeControlPopDown P(()); +void NewVariantPopDown P(()); +void SettingsPopDown P(()); /* * XBoard depends on Xt R4 or higher */ @@ -422,7 +454,7 @@ Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, jailSquareColor, highlightSquareColor, premoveHighlightColor; GC lightSquareGC, darkSquareGC, jailSquareGC, lineGC, wdPieceGC, wlPieceGC, bdPieceGC, blPieceGC, wbPieceGC, bwPieceGC, coordGC, highlineGC, - wjPieceGC, bjPieceGC, prelineGC; + wjPieceGC, bjPieceGC, prelineGC, countGC; Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap; Widget shellWidget, layoutWidget, formWidget, boardWidget, messageWidget, whiteTimerWidget, blackTimerWidget, titleWidget, widgetList[16], @@ -431,19 +463,21 @@ Widget shellWidget, layoutWidget, formWidget, boardWidget, messageWidget, ICSInputShell, fileNameShell, askQuestionShell; XSegment gridSegments[(BOARD_SIZE + 1) * 2]; XSegment jailGridSegments[(BOARD_SIZE + 3) * 2]; -Font clockFontID, coordFontID; -XFontStruct *clockFontStruct, *coordFontStruct; +Font clockFontID, coordFontID, countFontID; +XFontStruct *clockFontStruct, *coordFontStruct, *countFontStruct; XtAppContext appContext; char *layoutName; char *oldICSInteractionTitle; FileProc fileProc; char *fileOpenMode; +char installDir[] = "."; // [HGM] UCI: needed for UCI; probably needs run-time initializtion Position commentX = -1, commentY = -1; Dimension commentW, commentH; int squareSize, smallLayout = 0, tinyLayout = 0, + marginW, marginH, // [HGM] for run-time resizing fromX = -1, fromY = -1, toX, toY, commentUp = False, analysisUp = False, ICSInputBoxUp = False, askQuestionUp = False, filenameUp = False, promotionUp = False, pmFromX = -1, pmFromY = -1, @@ -501,137 +535,149 @@ static Pixmap xpmMask[BlackKing + 1]; SizeDefaults sizeDefaults[] = SIZE_DEFAULTS; MenuItem fileMenu[] = { - {"Reset Game", ResetProc}, + {N_("New Game"), ResetProc}, + {N_("New Shuffle Game ..."), ShuffleMenuProc}, + {N_("New Variant ..."), NewVariantProc}, // [HGM] variant: not functional yet {"----", NothingProc}, - {"Load Game", LoadGameProc}, - {"Load Next Game", LoadNextGameProc}, - {"Load Previous Game", LoadPrevGameProc}, - {"Reload Same Game", ReloadGameProc}, - {"Save Game", SaveGameProc}, + {N_("Load Game"), LoadGameProc}, + {N_("Load Next Game"), LoadNextGameProc}, + {N_("Load Previous Game"), LoadPrevGameProc}, + {N_("Reload Same Game"), ReloadGameProc}, + {N_("Save Game"), SaveGameProc}, {"----", NothingProc}, - {"Copy Game", CopyGameProc}, - {"Paste Game", PasteGameProc}, + {N_("Copy Game"), CopyGameProc}, + {N_("Paste Game"), PasteGameProc}, {"----", NothingProc}, - {"Load Position", LoadPositionProc}, - {"Load Next Position", LoadNextPositionProc}, - {"Load Previous Position", LoadPrevPositionProc}, - {"Reload Same Position", ReloadPositionProc}, - {"Save Position", SavePositionProc}, + {N_("Load Position"), LoadPositionProc}, + {N_("Load Next Position"), LoadNextPositionProc}, + {N_("Load Previous Position"), LoadPrevPositionProc}, + {N_("Reload Same Position"), ReloadPositionProc}, + {N_("Save Position"), SavePositionProc}, {"----", NothingProc}, - {"Copy Position", CopyPositionProc}, - {"Paste Position", PastePositionProc}, + {N_("Copy Position"), CopyPositionProc}, + {N_("Paste Position"), PastePositionProc}, {"----", NothingProc}, - {"Mail Move", MailMoveProc}, - {"Reload CMail Message", ReloadCmailMsgProc}, + {N_("Mail Move"), MailMoveProc}, + {N_("Reload CMail Message"), ReloadCmailMsgProc}, {"----", NothingProc}, - {"Exit", QuitProc}, + {N_("Exit"), QuitProc}, {NULL, NULL} }; MenuItem modeMenu[] = { - {"Machine White", MachineWhiteProc}, - {"Machine Black", MachineBlackProc}, - {"Two Machines", TwoMachinesProc}, - {"Analysis Mode", AnalyzeModeProc}, - {"Analyze File", AnalyzeFileProc }, - {"ICS Client", IcsClientProc}, - {"Edit Game", EditGameProc}, - {"Edit Position", EditPositionProc}, - {"Training", TrainingProc}, + {N_("Machine White"), MachineWhiteProc}, + {N_("Machine Black"), MachineBlackProc}, + {N_("Two Machines"), TwoMachinesProc}, + {N_("Analysis Mode"), AnalyzeModeProc}, + {N_("Analyze File"), AnalyzeFileProc }, + {N_("ICS Client"), IcsClientProc}, + {N_("Edit Game"), EditGameProc}, + {N_("Edit Position"), EditPositionProc}, + {N_("Training"), TrainingProc}, + {"----", NothingProc}, + {N_("Show Engine Output"), EngineOutputProc}, + {N_("Show Evaluation Graph"), NothingProc}, // [HGM] evalgr: not functional yet + {N_("Show Game List"), ShowGameListProc}, + {"Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code {"----", NothingProc}, - {"Show Game List", ShowGameListProc}, - {"Show Move List", HistoryShowProc}, - {"Edit Tags", EditTagsProc}, - {"Edit Comment", EditCommentProc}, - {"ICS Input Box", IcsInputBoxProc}, - {"Pause", PauseProc}, + {N_("Edit Tags"), EditTagsProc}, + {N_("Edit Comment"), EditCommentProc}, + {N_("ICS Input Box"), IcsInputBoxProc}, + {N_("Pause"), PauseProc}, {NULL, NULL} }; MenuItem actionMenu[] = { - {"Accept", AcceptProc}, - {"Decline", DeclineProc}, - {"Rematch", RematchProc}, + {N_("Accept"), AcceptProc}, + {N_("Decline"), DeclineProc}, + {N_("Rematch"), RematchProc}, {"----", NothingProc}, - {"Call Flag", CallFlagProc}, - {"Draw", DrawProc}, - {"Adjourn", AdjournProc}, - {"Abort", AbortProc}, - {"Resign", ResignProc}, + {N_("Call Flag"), CallFlagProc}, + {N_("Draw"), DrawProc}, + {N_("Adjourn"), AdjournProc}, + {N_("Abort"), AbortProc}, + {N_("Resign"), ResignProc}, {"----", NothingProc}, - {"Stop Observing", StopObservingProc}, - {"Stop Examining", StopExaminingProc}, + {N_("Stop Observing"), StopObservingProc}, + {N_("Stop Examining"), StopExaminingProc}, {NULL, NULL} }; MenuItem stepMenu[] = { - {"Backward", BackwardProc}, - {"Forward", ForwardProc}, - {"Back to Start", ToStartProc}, - {"Forward to End", ToEndProc}, - {"Revert", RevertProc}, - {"Truncate Game", TruncateGameProc}, + {N_("Backward"), BackwardProc}, + {N_("Forward"), ForwardProc}, + {N_("Back to Start"), ToStartProc}, + {N_("Forward to End"), ToEndProc}, + {N_("Revert"), RevertProc}, + {N_("Truncate Game"), TruncateGameProc}, {"----", NothingProc}, - {"Move Now", MoveNowProc}, - {"Retract Move", RetractMoveProc}, + {N_("Move Now"), MoveNowProc}, + {N_("Retract Move"), RetractMoveProc}, {NULL, NULL} }; MenuItem optionsMenu[] = { - {"Always Queen", AlwaysQueenProc}, - {"Animate Dragging", AnimateDraggingProc}, - {"Animate Moving", AnimateMovingProc}, - {"Auto Comment", AutocommProc}, - {"Auto Flag", AutoflagProc}, - {"Auto Flip View", AutoflipProc}, - {"Auto Observe", AutobsProc}, - {"Auto Raise Board", AutoraiseProc}, - {"Auto Save", AutosaveProc}, - {"Blindfold", BlindfoldProc}, - {"Flash Moves", FlashMovesProc}, - {"Flip View", FlipViewProc}, - {"Get Move List", GetMoveListProc}, + {N_("Flip View"), FlipViewProc}, + {"----", NothingProc}, + {N_("Adjudications ..."), EngineMenuProc}, + {N_("General Settings ..."), UciMenuProc}, + {N_("Engine #1 Settings ..."), FirstSettingsProc}, + {N_("Engine #2 Settings ..."), SecondSettingsProc}, + {N_("Time Control ..."), TimeControlProc}, + {"----", NothingProc}, + {N_("Always Queen"), AlwaysQueenProc}, + {N_("Animate Dragging"), AnimateDraggingProc}, + {N_("Animate Moving"), AnimateMovingProc}, + {N_("Auto Comment"), AutocommProc}, + {N_("Auto Flag"), AutoflagProc}, + {N_("Auto Flip View"), AutoflipProc}, + {N_("Auto Observe"), AutobsProc}, + {N_("Auto Raise Board"), AutoraiseProc}, + {N_("Auto Save"), AutosaveProc}, + {N_("Blindfold"), BlindfoldProc}, + {N_("Flash Moves"), FlashMovesProc}, + {N_("Get Move List"), GetMoveListProc}, #if HIGHDRAG - {"Highlight Dragging", HighlightDraggingProc}, + {N_("Highlight Dragging"), HighlightDraggingProc}, #endif - {"Highlight Last Move", HighlightLastMoveProc}, - {"Move Sound", MoveSoundProc}, - {"ICS Alarm", IcsAlarmProc}, - {"Old Save Style", OldSaveStyleProc}, - {"Periodic Updates", PeriodicUpdatesProc}, - {"Ponder Next Move", PonderNextMoveProc}, - {"Popup Exit Message", PopupExitMessageProc}, - {"Popup Move Errors", PopupMoveErrorsProc}, - {"Premove", PremoveProc}, - {"Quiet Play", QuietPlayProc}, - {"Show Coords", ShowCoordsProc}, - {"Show Thinking", ShowThinkingProc}, - {"Test Legality", TestLegalityProc}, + {N_("Highlight Last Move"), HighlightLastMoveProc}, + {N_("Move Sound"), MoveSoundProc}, + {N_("ICS Alarm"), IcsAlarmProc}, + {N_("Old Save Style"), OldSaveStyleProc}, + {N_("Periodic Updates"), PeriodicUpdatesProc}, + {N_("Ponder Next Move"), PonderNextMoveProc}, + {N_("Popup Exit Message"), PopupExitMessageProc}, + {N_("Popup Move Errors"), PopupMoveErrorsProc}, + {N_("Premove"), PremoveProc}, + {N_("Quiet Play"), QuietPlayProc}, + {N_("Show Coords"), ShowCoordsProc}, + {N_("Hide Thinking"), HideThinkingProc}, + {N_("Test Legality"), TestLegalityProc}, {NULL, NULL} }; MenuItem helpMenu[] = { - {"Info XBoard", InfoProc}, - {"Man XBoard", ManProc}, + {N_("Info XBoard"), InfoProc}, + {N_("Man XBoard"), ManProc}, {"----", NothingProc}, - {"Hint", HintProc}, - {"Book", BookProc}, + {N_("Hint"), HintProc}, + {N_("Book"), BookProc}, {"----", NothingProc}, - {"About XBoard", AboutProc}, + {N_("About XBoard"), AboutProc}, {NULL, NULL} }; Menu menuBar[] = { - {"File", fileMenu}, - {"Mode", modeMenu}, - {"Action", actionMenu}, - {"Step", stepMenu}, - {"Options", optionsMenu}, - {"Help", helpMenu}, + {N_("File"), fileMenu}, + {N_("Mode"), modeMenu}, + {N_("Action"), actionMenu}, + {N_("Step"), stepMenu}, + {N_("Options"), optionsMenu}, + {N_("Help"), helpMenu}, {NULL, NULL} }; -#define PAUSE_BUTTON "P" +#define PAUSE_BUTTON N_("P") MenuItem buttonBar[] = { {"<<", ToStartProc}, {"<", BackwardProc}, @@ -643,11 +689,11 @@ MenuItem buttonBar[] = { #define PIECE_MENU_SIZE 11 String pieceMenuStrings[2][PIECE_MENU_SIZE] = { - { "White", "----", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King", - "----", "Empty square", "Clear board" }, - { "Black", "----", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King", - "----", "Empty square", "Clear board" }, - }; + { N_("White"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), + N_("Queen"), N_("King"), "----", N_("Empty square"), N_("Clear board") }, + { N_("Black"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), + N_("Queen"), N_("King"), "----", N_("Empty square"), N_("Clear board") }, +}; /* must be in same order as PieceMenuStrings! */ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { { WhitePlay, (ChessSquare) 0, WhitePawn, WhiteKnight, WhiteBishop, @@ -660,7 +706,7 @@ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { #define DROP_MENU_SIZE 6 String dropMenuStrings[DROP_MENU_SIZE] = { - "----", "Pawn", "Knight", "Bishop", "Rook", "Queen" + "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), N_("Queen") }; /* must be in same order as PieceMenuStrings! */ ChessSquare dropMenuTranslation[DROP_MENU_SIZE] = { @@ -777,9 +823,9 @@ XtResource clientResources[] = { { "secondHost", "secondHost", XtRString, sizeof(String), XtOffset(AppDataPtr, secondHost), XtRString, SECOND_HOST }, { "firstDirectory", "firstDirectory", XtRString, sizeof(String), - XtOffset(AppDataPtr, firstDirectory), XtRString, FIRST_DIRECTORY }, + XtOffset(AppDataPtr, firstDirectory), XtRString, "." }, { "secondDirectory", "secondDirectory", XtRString, sizeof(String), - XtOffset(AppDataPtr, secondDirectory), XtRString, SECOND_DIRECTORY }, + XtOffset(AppDataPtr, secondDirectory), XtRString, "." }, { "bitmapDirectory", "bitmapDirectory", XtRString, sizeof(String), XtOffset(AppDataPtr, bitmapDirectory), XtRString, "" }, @@ -892,7 +938,7 @@ XtResource clientResources[] = { (XtPointer) 0 }, { "showThinking", "showThinking", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, showThinking), XtRImmediate, - (XtPointer) False }, + (XtPointer) True }, { "ponderNextMove", "ponderNextMove", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, ponderNextMove), XtRImmediate, (XtPointer) True }, @@ -1138,6 +1184,9 @@ XtResource clientResources[] = { { "showButtonBar", "showButtonBar", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, showButtonBar), XtRImmediate, (XtPointer) True }, + {"icsEngineAnalyze", "icsEngineAnalyze", XtRBoolean, /* [DM] icsEngineAnalyze */ + sizeof(Boolean), XtOffset(AppDataPtr, icsEngineAnalyze), + XtRImmediate, (XtPointer) False }, { "firstScoreAbs", "firstScoreAbs", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, firstScoreIsAbsolute), XtRImmediate, (XtPointer) False }, @@ -1149,16 +1198,16 @@ XtResource clientResources[] = { XtRImmediate, (XtPointer) False }, { "hideThinkingFromHuman", "hideThinkingFromHuman", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, hideThinkingFromHuman), - XtRImmediate, (XtPointer) False }, + XtRImmediate, (XtPointer) True }, { "adjudicateLossThreshold", "adjudicateLossThreshold", XtRInt, sizeof(int), XtOffset(AppDataPtr, adjudicateLossThreshold), XtRImmediate, (XtPointer) 0}, { "pgnEventHeader", "pgnEventHeader", XtRString, sizeof(String), XtOffset(AppDataPtr, pgnEventHeader), XtRImmediate, (XtPointer) "Computer Chess Game" }, - { "defaultFrcPosition", "defaultFrcPosition", XtRInt, - sizeof(int), XtOffset(AppDataPtr, defaultFrcPosition), - XtRImmediate, (XtPointer) -1 }, + { "defaultFrcPosition", "defaultFrcPositon", XtRInt, + sizeof(int), XtOffset(AppDataPtr, defaultFrcPosition), + XtRImmediate, (XtPointer) -1}, // [HGM] 4.3.xx options { "boardWidth", "boardWidth", XtRInt, @@ -1187,13 +1236,13 @@ XtResource clientResources[] = { XtRImmediate, (XtPointer) False}, { "testClaims", "testClaims", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, testClaims), - XtRImmediate, (XtPointer) False}, + XtRImmediate, (XtPointer) True}, { "checkMates", "checkMates", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, checkMates), - XtRImmediate, (XtPointer) False}, + XtRImmediate, (XtPointer) True}, { "materialDraws", "materialDraws", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, materialDraws), - XtRImmediate, (XtPointer) False}, + XtRImmediate, (XtPointer) True}, { "trivialDraws", "trivialDraws", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, trivialDraws), XtRImmediate, (XtPointer) False}, @@ -1242,6 +1291,68 @@ XtResource clientResources[] = { { "suppressLoadMoves", "suppressLoadMoves", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, suppressLoadMoves), XtRImmediate, (XtPointer) False}, + { "userName", "userName", XtRString, + sizeof(String), XtOffset(AppDataPtr, userName), + XtRImmediate, (XtPointer) 0}, + { "egtFormats", "egtFormats", XtRString, + sizeof(String), XtOffset(AppDataPtr, egtFormats), + XtRImmediate, (XtPointer) 0}, + { "rewindIndex", "rewindIndex", XtRInt, + sizeof(int), XtOffset(AppDataPtr, rewindIndex), + XtRImmediate, (XtPointer) 0}, + { "sameColorGames", "sameColorGames", XtRInt, + sizeof(int), XtOffset(AppDataPtr, sameColorGames), + XtRImmediate, (XtPointer) 0}, + { "smpCores", "smpCores", XtRInt, + sizeof(int), XtOffset(AppDataPtr, smpCores), + XtRImmediate, (XtPointer) 1}, + { "niceEngines", "niceEngines", XtRInt, + sizeof(int), XtOffset(AppDataPtr, niceEngines), + XtRImmediate, (XtPointer) 0}, + + // [HGM] Winboard_x UCI options + { "firstIsUCI", "firstIsUCI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, firstIsUCI), + XtRImmediate, (XtPointer) False}, + { "secondIsUCI", "secondIsUCI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, secondIsUCI), + XtRImmediate, (XtPointer) False}, + { "firstHasOwnBookUCI", "firstHasOwnBookUCI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, firstHasOwnBookUCI), + XtRImmediate, (XtPointer) True}, + { "secondHasOwnBookUCI", "secondHasOwnBookUCI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, secondHasOwnBookUCI), + XtRImmediate, (XtPointer) True}, + { "usePolyglotBook", "usePolyglotBook", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, usePolyglotBook), + XtRImmediate, (XtPointer) False}, + { "defaultHashSize", "defaultHashSize", XtRInt, + sizeof(int), XtOffset(AppDataPtr, defaultHashSize), + XtRImmediate, (XtPointer) 64}, + { "defaultCacheSizeEGTB", "defaultCacheSizeEGTB", XtRInt, + sizeof(int), XtOffset(AppDataPtr, defaultCacheSizeEGTB), + XtRImmediate, (XtPointer) 4}, + { "polyglotDir", "polyglotDir", XtRString, + sizeof(String), XtOffset(AppDataPtr, polyglotDir), + XtRImmediate, (XtPointer) "." }, + { "polyglotBook", "polyglotBook", XtRString, + sizeof(String), XtOffset(AppDataPtr, polyglotBook), + XtRImmediate, (XtPointer) "" }, + { "defaultPathEGTB", "defaultPathEGTB", XtRString, + sizeof(String), XtOffset(AppDataPtr, defaultPathEGTB), + XtRImmediate, (XtPointer) "/usr/local/share/egtb"}, + { "delayBeforeQuit", "delayBeforeQuit", XtRInt, + sizeof(int), XtOffset(AppDataPtr, delayBeforeQuit), + XtRImmediate, (XtPointer) 0}, + { "delayAfterQuit", "delayAfterQuit", XtRInt, + sizeof(int), XtOffset(AppDataPtr, delayAfterQuit), + XtRImmediate, (XtPointer) 0}, + { "nameOfDebugFile", "nameOfDebugFile", XtRString, + sizeof(String), XtOffset(AppDataPtr, nameOfDebugFile), + XtRImmediate, (XtPointer) "xboard.debug"}, + { "noGUI", "noGUI", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, noGUI), + XtRImmediate, (XtPointer) 0}, }; XrmOptionDescRec shellOptions[] = { @@ -1539,6 +1650,20 @@ XrmOptionDescRec shellOptions[] = { { "-hideThinkingFromHuman", "hideThinkingFromHuman", XrmoptionSepArg, NULL }, { "-adjudicateLossThreshold", "adjudicateLossThreshold", XrmoptionSepArg, NULL }, { "-pgnEventHeader", "pgnEventHeader", XrmoptionSepArg, NULL }, + { "-firstIsUCI", "firstIsUCI", XrmoptionSepArg, NULL }, + { "-secondIsUCI", "secondIsUCI", XrmoptionSepArg, NULL }, + { "-fUCI", "firstIsUCI", XrmoptionNoArg, "True" }, + { "-sUCI", "secondIsUCI", XrmoptionNoArg, "True" }, + { "-firstHasOwnBookUCI", "firstHasOwnBookUCI", XrmoptionSepArg, NULL }, + { "-secondHasOwnBookUCI", "secondHasOwnBookUCI", XrmoptionSepArg, NULL }, + { "-fNoOwnBookUCI", "firstHasOwnBookUCI", XrmoptionNoArg, "False" }, + { "-sNoOwnBookUCI", "secondHasOwnBookUCI", XrmoptionNoArg, "False" }, + { "-polyglotDir", "polyglotDir", XrmoptionSepArg, NULL }, + { "-usePolyglotBook", "usePolyglotBook", XrmoptionSepArg, NULL }, + { "-polyglotBook", "polyglotBook", XrmoptionSepArg, NULL }, + { "-defaultHashSize", "defaultHashSize", XrmoptionSepArg, NULL }, + { "-defaultCacheSizeEGTB", "defaultCacheSizeEGTB", XrmoptionSepArg, NULL }, + { "-defaultPathEGTB", "defaultPathEGTB", XrmoptionSepArg, NULL }, { "-defaultFrcPosition", "defaultFrcPosition", XrmoptionSepArg, NULL }, // [HGM] I am sure AS added many more options, but we have to fish them out, from the list in winboard.c @@ -1572,6 +1697,16 @@ XrmOptionDescRec shellOptions[] = { { "-serverMoves", "serverMoves", XrmoptionSepArg, NULL }, { "-serverPause", "serverPause", XrmoptionSepArg, NULL }, { "-suppressLoadMoves", "suppressLoadMoves", XrmoptionSepArg, NULL }, + { "-egtFormats", "egtFormats", XrmoptionSepArg, NULL }, + { "-userName", "userName", XrmoptionSepArg, NULL }, + { "-smpCores", "smpCores", XrmoptionSepArg, NULL }, + { "-sameColorGames", "sameColorGames", XrmoptionSepArg, NULL }, + { "-rewindIndex", "rewindIndex", XrmoptionSepArg, NULL }, + { "-niceEngines", "niceEngines", XrmoptionSepArg, NULL }, + { "-delayBeforeQuit", "delayBeforeQuit", XrmoptionSepArg, NULL }, + { "-delayAfterQuit", "delayAfterQuit", XrmoptionSepArg, NULL }, + { "-nameOfDebugFile", "nameOfDebugFile", XrmoptionSepArg, NULL }, + { "-noGUI", "noGUI", XrmoptionNoArg, "True" }, }; @@ -1614,6 +1749,7 @@ XtActionsRec boardActions[] = { { "EditGameProc", EditGameProc }, { "EditPositionProc", EditPositionProc }, { "TrainingProc", EditPositionProc }, + { "EngineOutputProc", EngineOutputProc}, // [HGM] Winboard_x engine-output window { "ShowGameListProc", ShowGameListProc }, { "ShowMoveListProc", HistoryShowProc}, { "EditTagsProc", EditCommentProc }, @@ -1667,6 +1803,7 @@ XtActionsRec boardActions[] = { { "QuietPlayProc", QuietPlayProc }, { "ShowCoordsProc", ShowCoordsProc }, { "ShowThinkingProc", ShowThinkingProc }, + { "HideThinkingProc", HideThinkingProc }, { "TestLegalityProc", TestLegalityProc }, { "InfoProc", InfoProc }, { "ManProc", ManProc }, @@ -1687,6 +1824,13 @@ XtActionsRec boardActions[] = { { "GameListPopDown", (XtActionProc) GameListPopDown }, { "PromotionPopDown", (XtActionProc) PromotionPopDown }, { "HistoryPopDown", (XtActionProc) HistoryPopDown }, + { "EngineOutputPopDown", (XtActionProc) EngineOutputPopDown }, + { "ShufflePopDown", (XtActionProc) ShufflePopDown }, + { "EnginePopDown", (XtActionProc) EnginePopDown }, + { "UciPopDown", (XtActionProc) UciPopDown }, + { "TimeControlPopDown", (XtActionProc) TimeControlPopDown }, + { "NewVariantPopDown", (XtActionProc) NewVariantPopDown }, + { "SettingsPopDown", (XtActionProc) SettingsPopDown }, }; char globalTranslations[] = @@ -1795,7 +1939,7 @@ xpm_getavail(dirname, ext) dir = opendir(dirname); if (!dir) { - fprintf(stderr, "%s: Can't access XPM directory %s\n", + fprintf(stderr, _("%s: Can't access XPM directory %s\n"), programName, dirname); exit(1); } @@ -1818,7 +1962,7 @@ xpm_print_avail(fp, ext) { int i; - fprintf(fp, "Available `%s' sizes:\n", ext); + fprintf(fp, _("Available `%s' sizes:\n"), ext); for (i=1; i= 1000-2) { printf(_("too many arguments\n")); exit(-1); } +//fprintf(stderr, "arg %s\n", argv[i]); + if(argv[i][0] != '@') argvCopy[j++] = argv[i]; else { + char c; + FILE *f = fopen(argv[i]+1, "rb"); + if(f == NULL) { fprintf(stderr, _("ignore %s\n"), argv[i]); continue; } // do not expand non-existing + argvCopy[j++] = newArgs + k; // get ready for first argument from file + while((c = fgetc(f)) != EOF) { // each line of file inserts 1 argument in the list + if(c == '\n') { + if(j >= 1000-2) { printf(_("too many arguments\n")); exit(-1); } + newArgs[k++] = 0; // terminate current arg + if(k >= 10000-1) { printf(_("too long arguments\n")); exit(-1); } + argvCopy[j++] = newArgs + k; // get ready for next + } else { + if(k >= 10000-1) { printf(_("too long arguments\n")); exit(-1); } + newArgs[k++] = c; + } + } + newArgs[k] = 0; + j--; + fclose(f); + } + } + argvCopy[j] = NULL; + argv = argvCopy; + argc = j; +#if 0 + if(appData.debugMode,1) { // OK, appData is not initialized here yet... + for(i=0; i 1) { - fprintf(stderr, "%s: unrecognized argument %s\n", + fprintf(stderr, _("%s: unrecognized argument %s\n"), programName, argv[1]); exit(2); } @@ -2023,7 +2286,7 @@ main(argc, argv) chessDir = "."; } else { if (chdir(chessDir) != 0) { - fprintf(stderr, "%s: can't cd to CHESSDIR: ", programName); + fprintf(stderr, _("%s: can't cd to CHESSDIR: "), programName); perror(chessDir); exit(1); } @@ -2041,13 +2304,19 @@ main(argc, argv) clientResources, XtNumber(clientResources), NULL, 0); + if (appData.debugMode && appData.nameOfDebugFile && strcmp(appData.nameOfDebugFile, "stderr")) { + /* [DM] debug info to file [HGM] make the filename a command-line option, and allow it to remain stderr */ + if ((debugFP = fopen(appData.nameOfDebugFile, "w")) == NULL) { + printf(_("Failed to open file '%s'\n"), appData.nameOfDebugFile); + exit(errno); + } + setbuf(debugFP, NULL); + } + /* [HGM,HR] make sure board size is acceptable */ if(appData.NrFiles > BOARD_SIZE || appData.NrRanks > BOARD_SIZE ) - DisplayFatalError("Recompile with BOARD_SIZE > 12, to support this size", 0, 2); - - /* [HGM] The following line must be moved to the "New Shuffle Game" menu as soon as there is one! */ - if(appData.defaultFrcPosition != -1) shuffleOpenings = TRUE; + DisplayFatalError(_("Recompile with BOARD_SIZE > 12, to support this size"), 0, 2); #if !HIGHDRAG /* This feature does not work; animation needs a rewrite */ @@ -2083,7 +2352,7 @@ main(argc, argv) &lineGap, &clockFontPxlSize, &coordFontPxlSize, &fontPxlSize, &smallLayout, &tinyLayout); if (i == 0) { - fprintf(stderr, "%s: bad boardSize syntax %s\n", + fprintf(stderr, _("%s: bad boardSize syntax %s\n"), programName, appData.boardSize); exit(2); } @@ -2119,7 +2388,7 @@ main(argc, argv) while (szd->name != NULL && StrCaseCmp(szd->name, appData.boardSize) != 0) szd++; if (szd->name == NULL) { - fprintf(stderr, "%s: unrecognized boardSize name %s\n", + fprintf(stderr, _("%s: unrecognized boardSize name %s\n"), programName, appData.boardSize); exit(2); } @@ -2137,17 +2406,18 @@ main(argc, argv) if (strlen(appData.pixmapDirectory) > 0) { p = ExpandPathName(appData.pixmapDirectory); if (!p) { - fprintf(stderr, "Error expanding path name \"%s\"\n", + fprintf(stderr, _("Error expanding path name \"%s\"\n"), appData.pixmapDirectory); exit(1); } if (appData.debugMode) { - fprintf(stderr, "XBoard square size (hint): %d\n", squareSize); - fprintf(stderr, "%s fulldir:%s:\n", IMAGE_EXT, p); + fprintf(stderr, _("\ +XBoard square size (hint): %d\n\ +%s fulldir:%s:\n"), squareSize, IMAGE_EXT, p); } squareSize = xpm_closest_to(p, squareSize, IMAGE_EXT); if (appData.debugMode) { - fprintf(stderr, "Closest %s size: %d\n", IMAGE_EXT, squareSize); + fprintf(stderr, _("Closest %s size: %d\n"), IMAGE_EXT, squareSize); } } @@ -2180,6 +2450,9 @@ main(argc, argv) coordFontID = XLoadFont(xDisplay, appData.coordFont); coordFontStruct = XQueryFont(xDisplay, coordFontID); appData.font = FindFont(appData.font, fontPxlSize); + countFontID = XLoadFont(xDisplay, appData.coordFont); // [HGM] holdings + countFontStruct = XQueryFont(xDisplay, countFontID); +// appData.font = FindFont(appData.font, fontPxlSize); xdb = XtDatabase(xDisplay); XrmPutStringResource(&xdb, "*font", appData.font); @@ -2261,12 +2534,12 @@ main(argc, argv) } if (forceMono) { - fprintf(stderr, "%s: too few colors available; trying monochrome mode\n", + fprintf(stderr, _("%s: too few colors available; trying monochrome mode\n"), programName); } if (appData.monoMode && appData.debugMode) { - fprintf(stderr, "white pixel = 0x%lx, black pixel = 0x%lx\n", + fprintf(stderr, _("white pixel = 0x%lx, black pixel = 0x%lx\n"), (unsigned long) XWhitePixel(xDisplay, xScreen), (unsigned long) XBlackPixel(xDisplay, xScreen)); } @@ -2284,7 +2557,7 @@ main(argc, argv) { if (appData.colorize) { fprintf(stderr, - "%s: can't parse color names; disabling colorization\n", + _("%s: can't parse color names; disabling colorization\n"), programName); } appData.colorize = FALSE; @@ -2314,36 +2587,54 @@ main(argc, argv) formArgs, XtNumber(formArgs)); XtSetArg(args[0], XtNdefaultDistance, &sep); XtGetValues(formWidget, args, 1); - + j = 0; widgetList[j++] = menuBarWidget = CreateMenuBar(menuBar); + XtSetArg(args[0], XtNtop, XtChainTop); + XtSetArg(args[1], XtNbottom, XtChainTop); + XtSetValues(menuBarWidget, args, 2); widgetList[j++] = whiteTimerWidget = XtCreateWidget("whiteTime", labelWidgetClass, formWidget, timerArgs, XtNumber(timerArgs)); XtSetArg(args[0], XtNfont, clockFontStruct); - XtSetValues(whiteTimerWidget, args, 1); + XtSetArg(args[1], XtNtop, XtChainTop); + XtSetArg(args[2], XtNbottom, XtChainTop); + XtSetValues(whiteTimerWidget, args, 3); widgetList[j++] = blackTimerWidget = XtCreateWidget("blackTime", labelWidgetClass, formWidget, timerArgs, XtNumber(timerArgs)); XtSetArg(args[0], XtNfont, clockFontStruct); - XtSetValues(blackTimerWidget, args, 1); + XtSetArg(args[1], XtNtop, XtChainTop); + XtSetArg(args[2], XtNbottom, XtChainTop); + XtSetValues(blackTimerWidget, args, 3); if (appData.titleInWindow) { widgetList[j++] = titleWidget = XtCreateWidget("title", labelWidgetClass, formWidget, titleArgs, XtNumber(titleArgs)); + XtSetArg(args[0], XtNtop, XtChainTop); + XtSetArg(args[1], XtNbottom, XtChainTop); + XtSetValues(titleWidget, args, 2); } if (appData.showButtonBar) { widgetList[j++] = buttonBarWidget = CreateButtonBar(buttonBar); + XtSetArg(args[0], XtNleft, XtChainRight); // [HGM] glue to right window edge + XtSetArg(args[1], XtNright, XtChainRight); // for good run-time sizing + XtSetArg(args[2], XtNtop, XtChainTop); + XtSetArg(args[3], XtNbottom, XtChainTop); + XtSetValues(buttonBarWidget, args, 4); } widgetList[j++] = messageWidget = XtCreateWidget("message", labelWidgetClass, formWidget, messageArgs, XtNumber(messageArgs)); - + XtSetArg(args[0], XtNtop, XtChainTop); + XtSetArg(args[1], XtNbottom, XtChainTop); + XtSetValues(messageWidget, args, 2); + widgetList[j++] = boardWidget = XtCreateWidget("board", widgetClass, formWidget, boardArgs, XtNumber(boardArgs)); @@ -2438,7 +2729,11 @@ main(argc, argv) } i = 0; XtSetArg(args[0], XtNfromVert, messageWidget); - XtSetValues(boardWidget, args, 1); + XtSetArg(args[1], XtNtop, XtChainTop); + XtSetArg(args[2], XtNbottom, XtChainBottom); + XtSetArg(args[3], XtNleft, XtChainLeft); + XtSetArg(args[4], XtNright, XtChainRight); + XtSetValues(boardWidget, args, 5); XtRealizeWidget(shellWidget); @@ -2448,6 +2743,7 @@ main(argc, argv) * The value "2" is probably larger than needed. */ XawFormDoLayout(formWidget, False); + #define WIDTH_FUDGE 2 i = 0; XtSetArg(args[i], XtNborderWidth, &bor); i++; @@ -2464,7 +2760,7 @@ main(argc, argv) gres = XtMakeResizeRequest(messageWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { - fprintf(stderr, "%s: messageWidget geometry error %d %d %d %d %d\n", + fprintf(stderr, _("%s: messageWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } @@ -2474,10 +2770,13 @@ main(argc, argv) w--; gres = XtMakeResizeRequest(messageWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { - fprintf(stderr, "%s: messageWidget geometry error %d %d %d %d %d\n", + fprintf(stderr, _("%s: messageWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } /* !! end hack */ + XtSetArg(args[0], XtNleft, XtChainLeft); // [HGM] glue ends for good run-time sizing + XtSetArg(args[1], XtNright, XtChainRight); + XtSetValues(messageWidget, args, 2); if (appData.titleInWindow) { i = 0; @@ -2495,7 +2794,7 @@ main(argc, argv) gres = XtMakeResizeRequest(titleWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { fprintf(stderr, - "%s: titleWidget geometry error %d %d %d %d %d\n", + _("%s: titleWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } } @@ -2623,8 +2922,8 @@ main(argc, argv) XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Show Coords"), args, 1); } - if (appData.showThinking) { - XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Show Thinking"), + if (appData.hideThinkingFromHuman) { + XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Hide Thinking"), args, 1); } if (appData.testLegality) { @@ -2660,7 +2959,9 @@ main(argc, argv) shellArgs[4].value = shellArgs[2].value = w; shellArgs[5].value = shellArgs[3].value = h; XtSetValues(shellWidget, &shellArgs[2], 4); - + marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board + marginH = h - boardHeight; + CatchDeleteWindow(shellWidget, "QuitProc"); CreateGCs(); @@ -2716,6 +3017,7 @@ main(argc, argv) InitPosition(TRUE); XtAppMainLoop(appContext); + if (appData.debugMode) fclose(debugFP); // [DM] debug return 0; } @@ -2830,7 +3132,7 @@ Enables icsEnables[] = { { "menuHelp.Book", False }, { "menuStep.Move Now", False }, { "menuOptions.Periodic Updates", False }, - { "menuOptions.Show Thinking", False }, + { "menuOptions.Hide Thinking", False }, { "menuOptions.Ponder Next Move", False }, #endif { NULL, False } @@ -2859,7 +3161,7 @@ Enables ncpEnables[] = { { "menuOptions.ICS Alarm", False }, { "menuOptions.Move Sound", False }, { "menuOptions.Quiet Play", False }, - { "menuOptions.Show Thinking", False }, + { "menuOptions.Hide Thinking", False }, { "menuOptions.Periodic Updates", False }, { "menuOptions.Ponder Next Move", False }, { "menuHelp.Hint", False }, @@ -2969,6 +3271,11 @@ Enables userThinkingEnables[] = { void SetICSMode() { SetMenuEnables(icsEnables); + +#ifdef ZIPPY + if (appData.zippyPlay && !appData.noChessProgram) /* [DM] icsEngineAnalyze */ + XtSetSensitive(XtNameToWidget(menuBarWidget, "menuMode.Analysis Mode"), True); +#endif } void @@ -3050,12 +3357,40 @@ char *FindFont(pattern, targetPxlSize) char **fonts, *p, *best, *scalable, *scalableTail; int i, j, nfonts, minerr, err, pxlSize; +#ifdef ENABLE_NLS + char **missing_list; + int missing_count; + char *def_string, *base_fnt_lst, strInt[3]; + XFontSet fntSet; + XFontStruct **fnt_list; + + base_fnt_lst = calloc(1, strlen(pattern) + 3); + sprintf(strInt, "%d", targetPxlSize); + p = strstr(pattern, "--"); + strncpy(base_fnt_lst, pattern, p - pattern + 2); + strcat(base_fnt_lst, strInt); + strcat(base_fnt_lst, strchr(p + 2, '-')); + + if ((fntSet = XCreateFontSet(xDisplay, + base_fnt_lst, + &missing_list, + &missing_count, + &def_string)) == NULL) { + + fprintf(stderr, _("Unable to create font set.\n")); + exit (2); + } + + nfonts = XFontsOfFontSet(fntSet, &fnt_list, &fonts); +#else fonts = XListFonts(xDisplay, pattern, 999999, &nfonts); if (nfonts < 1) { - fprintf(stderr, "%s: no fonts match pattern %s\n", + fprintf(stderr, _("%s: no fonts match pattern %s\n"), programName, pattern); exit(2); } +#endif + best = fonts[0]; scalable = NULL; minerr = 999999; @@ -3093,10 +3428,16 @@ char *FindFont(pattern, targetPxlSize) strcpy(p, best); } if (appData.debugMode) { - fprintf(debugFP, "resolved %s at pixel size %d\n to %s\n", + fprintf(debugFP, _("resolved %s at pixel size %d\n to %s\n"), pattern, targetPxlSize, p); } - XFreeFontNames(fonts); +#ifdef ENABLE_NLS + if (missing_count > 0) + XFreeStringList(missing_list); + XFreeFontSet(xDisplay, fntSet); +#else + XFreeFontNames(fonts); +#endif return p; } @@ -3121,6 +3462,12 @@ void CreateGCs() coordGC = XtGetGC(shellWidget, value_mask, &gc_values); XSetFont(xDisplay, coordGC, coordFontID); + // [HGM] make font for holdings counts (white on black0 + gc_values.foreground = XWhitePixel(xDisplay, xScreen); + gc_values.background = XBlackPixel(xDisplay, xScreen); + countGC = XtGetGC(shellWidget, value_mask, &gc_values); + XSetFont(xDisplay, countGC, countFontID); + if (appData.monoMode) { gc_values.foreground = XWhitePixel(xDisplay, xScreen); gc_values.background = XWhitePixel(xDisplay, xScreen); @@ -3211,7 +3558,7 @@ void loadXIM(xim, xmask, filename, dest, mask) fp = fopen(filename, "rb"); if (!fp) { - fprintf(stderr, "%s: error loading XIM!\n", programName); + fprintf(stderr, _("%s: error loading XIM!\n"), programName); exit(1); } @@ -3303,11 +3650,11 @@ void CreateXIMPieces() } else { useImages = 1; if (appData.monoMode) { - DisplayFatalError("XIM pieces cannot be used in monochrome mode", + DisplayFatalError(_("XIM pieces cannot be used in monochrome mode"), 0, 2); ExitEvent(2); } - fprintf(stderr, "\nLoading XIMs...\n"); + fprintf(stderr, _("\nLoading XIMs...\n")); /* Load pieces */ for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { fprintf(stderr, "%d", piece+1); @@ -3321,7 +3668,7 @@ void CreateXIMPieces() XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); loadXIM(ximPieceBitmap[kind][piece], ximtemp, buf, &(xpmPieceBitmap[kind][piece]), @@ -3337,26 +3684,26 @@ void CreateXIMPieces() useImageSqs = 0; } else { useImageSqs = 1; - fprintf(stderr, "light square "); + fprintf(stderr, _("light square ")); ximLightSquare= XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); loadXIM(ximLightSquare, NULL, buf, &xpmLightSquare, NULL); - fprintf(stderr, "dark square "); + fprintf(stderr, _("dark square ")); sprintf(buf, "%s/dsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); ximDarkSquare= XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); loadXIM(ximDarkSquare, NULL, buf, &xpmDarkSquare, NULL); xpmJailSquare = xpmLightSquare; } - fprintf(stderr, "Done.\n"); + fprintf(stderr, _("Done.\n")); } XSynchronize(xDisplay, False); /* Work-around for xlib/xt buffering bug */ } @@ -3398,7 +3745,7 @@ void CreateXPMPieces() attr.numsymbols = 4; if (appData.monoMode) { - DisplayFatalError("XPM pieces cannot be used in monochrome mode", + DisplayFatalError(_("XPM pieces cannot be used in monochrome mode"), 0, 2); ExitEvent(2); } @@ -3408,7 +3755,7 @@ void CreateXPMPieces() /* Load pieces */ while (pieces->size != squareSize && pieces->size) pieces++; if (!pieces->size) { - fprintf(stderr, "No builtin XPM pieces of size %d\n", squareSize); + fprintf(stderr, _("No builtin XPM pieces of size %d\n"), squareSize); exit(1); } for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { @@ -3418,7 +3765,7 @@ void CreateXPMPieces() pieces->xpm[piece][kind], &(xpmPieceBitmap[kind][piece]), NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM image \"%s\"\n", + fprintf(stderr, _("Error %d loading XPM image \"%s\"\n"), r, buf); exit(1); } @@ -3429,7 +3776,7 @@ void CreateXPMPieces() } else { useImages = 1; - fprintf(stderr, "\nLoading XPMs...\n"); + fprintf(stderr, _("\nLoading XPMs...\n")); /* Load pieces */ for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { @@ -3440,12 +3787,12 @@ void CreateXPMPieces() ToLower(PieceToChar((ChessSquare)piece)), xpmkind[kind], ss); if (appData.debugMode) { - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); } if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &(xpmPieceBitmap[kind][piece]), NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } @@ -3454,34 +3801,34 @@ void CreateXPMPieces() /* Load light and dark squares */ /* If the LSQ and DSQ pieces don't exist, we will draw them with solid squares. */ - fprintf(stderr, "light square "); + fprintf(stderr, _("light square ")); sprintf(buf, "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss); if (access(buf, 0) != 0) { useImageSqs = 0; } else { useImageSqs = 1; if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &xpmLightSquare, NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", r, buf); + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } - fprintf(stderr, "dark square "); + fprintf(stderr, _("dark square ")); sprintf(buf, "%s/dsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss); if (appData.debugMode) { - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); } if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &xpmDarkSquare, NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", r, buf); + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } } xpmJailSquare = xpmLightSquare; - fprintf(stderr, "Done.\n"); + fprintf(stderr, _("Done.\n")); } XSynchronize(xDisplay, False); /* Work-around for xlib/xt buffering bug */ @@ -3558,25 +3905,25 @@ void ReadBitmap(pm, name, bits, wreq, hreq) if (errcode != BitmapSuccess) { switch (errcode) { case BitmapOpenFailed: - sprintf(msg, "Can't open bitmap file %s", fullname); + sprintf(msg, _("Can't open bitmap file %s"), fullname); break; case BitmapFileInvalid: - sprintf(msg, "Invalid bitmap in file %s", fullname); + sprintf(msg, _("Invalid bitmap in file %s"), fullname); break; case BitmapNoMemory: - sprintf(msg, "Ran out of memory reading bitmap file %s", + sprintf(msg, _("Ran out of memory reading bitmap file %s"), fullname); break; default: - sprintf(msg, "Unknown XReadBitmapFile error %d on file %s", + sprintf(msg, _("Unknown XReadBitmapFile error %d on file %s"), errcode, fullname); break; } - fprintf(stderr, "%s: %s...using built-in\n", + fprintf(stderr, _("%s: %s...using built-in\n"), programName, msg); } else if (w != wreq || h != hreq) { fprintf(stderr, - "%s: Bitmap %s is %dx%d, not %dx%d...using built-in\n", + _("%s: Bitmap %s is %dx%d, not %dx%d...using built-in\n"), programName, fullname, w, h, wreq, hreq); } else { return; @@ -3584,7 +3931,7 @@ void ReadBitmap(pm, name, bits, wreq, hreq) } if (bits == NULL) { #if 0 - fprintf(stderr, "%s: No built-in bitmap for %s; giving up\n", + fprintf(stderr, _("%s: No built-in bitmap for %s; giving up\n"), programName, name); exit(1); #endif @@ -3651,8 +3998,9 @@ void CreateMenuBarPopup(parent, name, mb) entry = XtCreateManagedWidget(mi->string, smeLineObjectClass, menu, args, j); } else { + XtSetArg(args[j], XtNlabel, XtNewString(_(mi->string))); entry = XtCreateManagedWidget(mi->string, smeBSBObjectClass, - menu, args, j); + menu, args, j+1); XtAddCallback(entry, XtNcallback, (XtCallbackProc) MenuBarSelect, (caddr_t) mi->proc); @@ -3683,10 +4031,14 @@ Widget CreateMenuBar(mb) XtSetArg(args[j], XtNmenuName, XtNewString(menuName)); j++; if (tinyLayout) { char shortName[2]; - shortName[0] = mb->name[0]; + shortName[0] = _(mb->name)[0]; shortName[1] = NULLCHAR; XtSetArg(args[j], XtNlabel, XtNewString(shortName)); j++; } + else { + XtSetArg(args[j], XtNlabel, XtNewString(_(mb->name))); j++; + } + XtSetArg(args[j], XtNborderWidth, 0); j++; anchor = XtCreateManagedWidget(mb->name, menuButtonWidgetClass, menuBar, args, j); @@ -3719,6 +4071,7 @@ Widget CreateButtonBar(mi) XtSetArg(args[j], XtNinternalWidth, 2); j++; XtSetArg(args[j], XtNborderWidth, 0); j++; } + XtSetArg(args[j], XtNlabel, XtNewString(_(mi->string))); j++; button = XtCreateManagedWidget(mi->string, commandWidgetClass, buttonBar, args, j); XtAddCallback(button, XtNcallback, @@ -3749,8 +4102,9 @@ CreatePieceMenu(name, color) entry = XtCreateManagedWidget(item, smeLineObjectClass, menu, NULL, 0); } else { + XtSetArg(args[0], XtNlabel, XtNewString(_(item))); entry = XtCreateManagedWidget(item, smeBSBObjectClass, - menu, NULL, 0); + menu, args, 1); selection = pieceMenuTranslation[color][i]; XtAddCallback(entry, XtNcallback, (XtCallbackProc) PieceMenuSelect, @@ -3779,7 +4133,7 @@ CreatePieceMenus() (unsigned)(ButtonPressMask|ButtonReleaseMask), GrabModeAsync, GrabModeAsync); - XtSetArg(args[0], XtNlabel, "Drop"); + XtSetArg(args[0], XtNlabel, _("Drop")); dropMenu = XtCreatePopupShell("menuD", simpleMenuWidgetClass, boardWidget, args, 1); for (i = 0; i < DROP_MENU_SIZE; i++) { @@ -3789,8 +4143,9 @@ CreatePieceMenus() entry = XtCreateManagedWidget(item, smeLineObjectClass, dropMenu, NULL, 0); } else { + XtSetArg(args[0], XtNlabel, XtNewString(_(item))); entry = XtCreateManagedWidget(item, smeBSBObjectClass, - dropMenu, NULL, 0); + dropMenu, args, 1); selection = dropMenuTranslation[i]; XtAddCallback(entry, XtNcallback, (XtCallbackProc) DropMenuSelect, @@ -4207,20 +4562,20 @@ static int SquareColor(row, column) if (gameInfo.variant == VariantXiangqi) { if (column >= 3 && column <= 5 && row >= 0 && row <= 2) { - square_color = 0; - } else if (column >= 3 && column <= 5 && row >= 7 && row <= 9) { square_color = 1; + } else if (column >= 3 && column <= 5 && row >= 7 && row <= 9) { + square_color = 0; } else if (row <= 4) { - square_color = 1; - } else { square_color = 0; + } else { + square_color = 1; } } else { square_color = ((column + row) % 2) == 1; } /* [hgm] holdings: next line makes all holdings squares light */ - if(column < BOARD_LEFT || column >= BOARD_RGHT) square_color = 0; + if(column < BOARD_LEFT || column >= BOARD_RGHT) square_color = 1; return square_color; } @@ -4236,6 +4591,17 @@ void DrawSquare(row, column, piece, do_flash) DrawFunc drawfunc; int flash_delay; + if(gameInfo.variant == VariantShogi) { // [HGM] shogi: in shogi Q is used for Lance + if(piece == WhiteQueen) piece = WhiteLance; else + if(piece == BlackQueen) piece = BlackLance; + } +#ifdef GOTHIC + else if(gameInfo.variant == VariantGothic) { // [HGM] shogi: in Gothic Chancelor has alternative look + if(piece == WhiteMarshall) piece = WhiteSilver; else + if(piece == BlackMarshall) piece = BlackSilver; + } +#endif + /* Calculate delay in milliseconds (2-delays per complete flash) */ flash_delay = 500 / appData.flashRate; @@ -4251,11 +4617,40 @@ void DrawSquare(row, column, piece, do_flash) square_color = SquareColor(row, column); - if ( // [HGM] holdings: next 5 lines blank out area between board and holdings + if ( // [HGM] holdings: blank out area between board and holdings column == BOARD_LEFT-1 || column == BOARD_RGHT || (column == BOARD_LEFT-2 && row < BOARD_HEIGHT-gameInfo.holdingsSize) || (column == BOARD_RGHT+1 && row >= gameInfo.holdingsSize) ) { BlankSquare(x, y, 2, EmptySquare, xBoardWindow); + + // [HGM] print piece counts next to holdings + string[1] = NULLCHAR; + if (column == (flipView ? BOARD_LEFT-1 : BOARD_RGHT) && piece > 1 ) { + string[0] = '0' + piece; + XTextExtents(countFontStruct, string, 1, &direction, + &font_ascent, &font_descent, &overall); + if (appData.monoMode) { + XDrawImageString(xDisplay, xBoardWindow, countGC, + x + squareSize - overall.width - 2, + y + font_ascent + 1, string, 1); + } else { + XDrawString(xDisplay, xBoardWindow, countGC, + x + squareSize - overall.width - 2, + y + font_ascent + 1, string, 1); + } + } + if (column == (flipView ? BOARD_RGHT : BOARD_LEFT-1) && piece > 1) { + string[0] = '0' + piece; + XTextExtents(countFontStruct, string, 1, &direction, + &font_ascent, &font_descent, &overall); + if (appData.monoMode) { + XDrawImageString(xDisplay, xBoardWindow, countGC, + x + 2, y + font_ascent + 1, string, 1); + } else { + XDrawString(xDisplay, xBoardWindow, countGC, + x + 2, y + font_ascent + 1, string, 1); + } + } } else { if (piece == EmptySquare || appData.blindfold) { BlankSquare(x, y, square_color, piece, xBoardWindow); @@ -4278,8 +4673,9 @@ void DrawSquare(row, column, piece, do_flash) } string[1] = NULLCHAR; - if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0)) { - string[0] = 'a' + column; + if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0) + && column >= BOARD_LEFT && column < BOARD_RGHT) { + string[0] = 'a' + column - BOARD_LEFT; XTextExtents(coordFontStruct, string, 1, &direction, &font_ascent, &font_descent, &overall); if (appData.monoMode) { @@ -4292,7 +4688,7 @@ void DrawSquare(row, column, piece, do_flash) y + squareSize - font_descent - 1, string, 1); } } - if (appData.showCoords && column == (flipView ? BOARD_WIDTH-1 : 0)) { + if (appData.showCoords && column == (flipView ? BOARD_RGHT-1 : BOARD_LEFT)) { string[0] = ONE + row; XTextExtents(coordFontStruct, string, 1, &direction, &font_ascent, &font_descent, &overall); @@ -4469,7 +4865,7 @@ void XDrawPosition(w, repaint, board) } else { if (lineGap > 0) XDrawSegments(xDisplay, xBoardWindow, lineGC, - gridSegments, (BOARD_SIZE + 1) * 2); + gridSegments, BOARD_HEIGHT + BOARD_WIDTH + 2); for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) { @@ -4748,7 +5144,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_ok = - XtCreateManagedWidget("ok", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("ok"), commandWidgetClass, form, args, j); XtAddCallback(b_ok, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4759,7 +5155,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_cancel = - XtCreateManagedWidget("cancel", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j); XtAddCallback(b_cancel, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4770,7 +5166,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_clear = - XtCreateManagedWidget("clear", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("clear"), commandWidgetClass, form, args, j); XtAddCallback(b_clear, XtNcallback, callback, (XtPointer) 0); } else { j = 0; @@ -4780,7 +5176,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_close = - XtCreateManagedWidget("close", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j); XtAddCallback(b_close, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4791,7 +5187,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_edit = - XtCreateManagedWidget("edit", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("edit"), commandWidgetClass, form, args, j); XtAddCallback(b_edit, XtNcallback, callback, (XtPointer) 0); } @@ -4992,16 +5388,16 @@ void EditCommentCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "ok") == 0) { + if (strcmp(name, _("ok")) == 0) { edit = XtNameToWidget(editShell, "*form.text"); j = 0; XtSetArg(args[j], XtNstring, &val); j++; XtGetValues(edit, args, j); ReplaceComment(savedIndex, val); EditCommentPopDown(); - } else if (strcmp(name, "cancel") == 0) { + } else if (strcmp(name, _("cancel")) == 0) { EditCommentPopDown(); - } else if (strcmp(name, "clear") == 0) { + } else if (strcmp(name, _("clear")) == 0) { edit = XtNameToWidget(editShell, "*form.text"); XtCallActionProc(edit, "select-all", NULL, NULL, 0); XtCallActionProc(edit, "kill-selection", NULL, NULL, 0); @@ -5033,7 +5429,7 @@ void ICSInputBoxPopUp() Widget edit; Arg args[16]; int j; - char *title = "ICS Input"; + char *title = _("ICS Input"); XtTranslations tr; if (ICSInputShell == NULL) { @@ -5168,9 +5564,9 @@ void CommentCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "close") == 0) { + if (strcmp(name, _("close")) == 0) { CommentPopDown(); - } else if (strcmp(name, "edit") == 0) { + } else if (strcmp(name, _("edit")) == 0) { CommentPopDown(); EditCommentEvent(); } @@ -5200,6 +5596,7 @@ void AnalysisPopDown() XtPopdown(analysisShell); XSync(xDisplay, False); analysisUp = False; + if (appData.icsEngineAnalyze) ExitAnalyzeMode(); /* [DM] icsEngineAnalyze */ } @@ -5222,6 +5619,7 @@ void FileNamePopUp(label, def, proc, openMode) i = 0; XtSetArg(args[i], XtNresizable, True); i++; XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++; + XtSetArg(args[i], XtNtitle, XtNewString(_("File name prompt"))); i++; fileNameShell = popup = XtCreatePopupShell("File name prompt", transientShellWidgetClass, shellWidget, args, i); @@ -5237,8 +5635,8 @@ void FileNamePopUp(label, def, proc, openMode) dialog = XtCreateManagedWidget("fileName", dialogWidgetClass, layout, args, i); - XawDialogAddButton(dialog, "ok", FileNameCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "cancel", FileNameCallback, + XawDialogAddButton(dialog, _("ok"), FileNameCallback, (XtPointer) dialog); + XawDialogAddButton(dialog, _("cancel"), FileNameCallback, (XtPointer) dialog); XtRealizeWidget(popup); @@ -5277,7 +5675,7 @@ void FileNameCallback(w, client_data, call_data) XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { FileNamePopDown(); return; } @@ -5314,12 +5712,12 @@ void FileNameAction(w, event, prms, nprms) } fullname = ExpandPathName(buf); if (!fullname) { - ErrorPopUp("Error", "Can't open file", FALSE); + ErrorPopUp(_("Error"), _("Can't open file"), FALSE); } else { f = fopen(fullname, fileOpenMode); if (f == NULL) { - DisplayError("Failed to open file", errno); + DisplayError(_("Failed to open file"), errno); } else { (void) (*fileProc)(f, index, buf); } @@ -5348,6 +5746,7 @@ void PromotionPopUp() j = 0; XtSetArg(args[j], XtNresizable, True); j++; + XtSetArg(args[j], XtNtitle, XtNewString(_("Promotion"))); j++; promotionShell = XtCreatePopupShell("Promotion", transientShellWidgetClass, shellWidget, args, j); @@ -5356,25 +5755,25 @@ void PromotionPopUp() layoutArgs, XtNumber(layoutArgs)); j = 0; - XtSetArg(args[j], XtNlabel, "Promote pawn to what?"); j++; + XtSetArg(args[j], XtNlabel, _("Promote pawn to what?")); j++; XtSetArg(args[j], XtNborderWidth, 0); j++; dialog = XtCreateManagedWidget("promotion", dialogWidgetClass, layout, args, j); - XawDialogAddButton(dialog, "Queen", PromotionCallback, + XawDialogAddButton(dialog, _("Queen"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Rook", PromotionCallback, + XawDialogAddButton(dialog, _("Rook"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Bishop", PromotionCallback, + XawDialogAddButton(dialog, _("Bishop"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Knight", PromotionCallback, + XawDialogAddButton(dialog, _("Knight"), PromotionCallback, (XtPointer) dialog); if (!appData.testLegality || gameInfo.variant == VariantSuicide || gameInfo.variant == VariantGiveaway) { - XawDialogAddButton(dialog, "King", PromotionCallback, + XawDialogAddButton(dialog, _("King"), PromotionCallback, (XtPointer) dialog); } - XawDialogAddButton(dialog, "cancel", PromotionCallback, + XawDialogAddButton(dialog, _("cancel"), PromotionCallback, (XtPointer) dialog); XtRealizeWidget(promotionShell); @@ -5422,11 +5821,11 @@ void PromotionCallback(w, client_data, call_data) if (fromX == -1) return; - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { fromX = fromY = -1; ClearHighlights(); return; - } else if (strcmp(name, "Knight") == 0) { + } else if (strcmp(name, _("Knight")) == 0) { promoChar = 'n'; } else { promoChar = ToLower(name[0]); @@ -5489,7 +5888,7 @@ void ErrorPopUp(title, label, modal) dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, layout, args, i); - XawDialogAddButton(dialog, "ok", ErrorCallback, (XtPointer) dialog); + XawDialogAddButton(dialog, _("ok"), ErrorCallback, (XtPointer) dialog); XtRealizeWidget(errorShell); CatchDeleteWindow(errorShell, "ErrorPopDown"); @@ -5674,7 +6073,7 @@ int LoadGamePopUp(f, gameNumber, title) if (gameNumber == 0) { int error = GameListBuild(f); if (error) { - DisplayError("Cannot build game list", error); + DisplayError(_("Cannot build game list"), error); } else if (!ListEmpty(&gameList) && ((ListGame *) gameList.tailPred)->number > 1) { GameListPopUp(f, title); @@ -5695,7 +6094,7 @@ void LoadGameProc(w, event, prms, nprms) if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { Reset(FALSE, TRUE); } - FileNamePopUp("Load game file name?", "", LoadGamePopUp, "rb"); + FileNamePopUp(_("Load game file name?"), "", LoadGamePopUp, "rb"); } void LoadNextGameProc(w, event, prms, nprms) @@ -5761,7 +6160,7 @@ void LoadPositionProc(w, event, prms, nprms) if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { Reset(FALSE, TRUE); } - FileNamePopUp("Load position file name?", "", LoadPosition, "rb"); + FileNamePopUp(_("Load position file name?"), "", LoadPosition, "rb"); } void SaveGameProc(w, event, prms, nprms) @@ -5770,7 +6169,7 @@ void SaveGameProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - FileNamePopUp("Save game file name?", + FileNamePopUp(_("Save game file name?"), DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"), SaveGame, "a"); } @@ -5781,7 +6180,7 @@ void SavePositionProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - FileNamePopUp("Save position file name?", + FileNamePopUp(_("Save position file name?"), DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"), SavePosition, "a"); } @@ -5953,7 +6352,7 @@ PasteGameCB(Widget w, XtPointer client_data, Atom *selection, } f = fopen(gamePasteFilename, "w"); if (f == NULL) { - DisplayError("Can't open temp file", errno); + DisplayError(_("Can't open temp file"), errno); return; } fwrite(value, 1, *len, f); @@ -6032,12 +6431,37 @@ void AnalyzeModeProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { + char buf[MSG_SIZ]; + if (!first.analysisSupport) { - char buf[MSG_SIZ]; - sprintf(buf, "%s does not support analysis", first.tidy); + sprintf(buf, _("%s does not support analysis"), first.tidy); DisplayError(buf, 0); return; } + /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */ + if (appData.icsActive) { + if (gameMode != IcsObserving) { + sprintf(buf,_("You are not observing a game")); + DisplayError(buf, 0); + /* secure check */ + if (appData.icsEngineAnalyze) { + if (appData.debugMode) + fprintf(debugFP, _("Found unexpected active ICS engine analyze \n")); + ExitAnalyzeMode(); + ModeHighlight(); + } + return; + } + /* if enable, use want disable icsEngineAnalyze */ + if (appData.icsEngineAnalyze) { + ExitAnalyzeMode(); + ModeHighlight(); + return; + } + appData.icsEngineAnalyze = TRUE; + if (appData.debugMode) + fprintf(debugFP, _("ICS engine analyze starting... \n")); + } if (!appData.showThinking) ShowThinkingProc(w,event,prms,nprms); @@ -6052,7 +6476,7 @@ void AnalyzeFileProc(w, event, prms, nprms) { if (!first.analysisSupport) { char buf[MSG_SIZ]; - sprintf(buf, "%s does not support analysis", first.tidy); + sprintf(buf, _("%s does not support analysis"), first.tidy); DisplayError(buf, 0); return; } @@ -6062,7 +6486,7 @@ void AnalyzeFileProc(w, event, prms, nprms) ShowThinkingProc(w,event,prms,nprms); AnalyzeFileEvent(); - FileNamePopUp("File to analyze", "", LoadGamePopUp, "rb"); + FileNamePopUp(_("File to analyze"), "", LoadGamePopUp, "rb"); AnalysisPeriodicEvent(1); } @@ -6820,8 +7244,10 @@ void ShowThinkingProc(w, event, prms, nprms) { Arg args[16]; - ShowThinkingEvent(!appData.showThinking); - + appData.showThinking = !appData.showThinking; // [HGM] thinking: tken out of ShowThinkingEvent + ShowThinkingEvent(); +#if 0 + // [HGM] thinking: currently no suc menu item; replaced by Hide Thinking (From Human) if (appData.showThinking) { XtSetArg(args[0], XtNleftBitmap, xMarkPixmap); } else { @@ -6829,6 +7255,27 @@ void ShowThinkingProc(w, event, prms, nprms) } XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Show Thinking"), args, 1); +#endif +} + +void HideThinkingProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + Arg args[16]; + + appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: tken out of ShowThinkingEvent + ShowThinkingEvent(); + + if (appData.hideThinkingFromHuman) { + XtSetArg(args[0], XtNleftBitmap, xMarkPixmap); + } else { + XtSetArg(args[0], XtNleftBitmap, None); + } + XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Hide Thinking"), + args, 1); } void InfoProc(w, event, prms, nprms) @@ -6889,13 +7336,15 @@ void AboutProc(w, event, prms, nprms) #else char *zippy = ""; #endif - sprintf(buf, "%s%s\n\n%s\n%s\n\n%s%s\n%s", + sprintf(buf, "%s%s\n\n%s\n%s\n%s\n%s\n\n%s%s\n%s", programVersion, zippy, "Copyright 1991 Digital Equipment Corporation", "Enhancements Copyright 1992-2001 Free Software Foundation", + "Enhancements Copyright 2005 Alessandro Scotti", + "Enhancements Copyright 2007-2008 H.G.Muller", PRODUCT, " is free software and carries NO WARRANTY;", "see the file COPYING for more information."); - ErrorPopUp("About XBoard", buf, FALSE); + ErrorPopUp(_("About XBoard"), buf, FALSE); } void DebugProc(w, event, prms, nprms) @@ -6981,6 +7430,17 @@ void DisplayTitle(text) } else if (appData.cmailGameName[0] != NULLCHAR) { sprintf(icon, "%s", "CMail"); sprintf(title, "%s: %s", programName, "CMail"); +#ifdef GOTHIC + // [HGM] license: This stuff should really be done in back-end, but WinBoard already had a pop-up for it + } else if (gameInfo.variant == VariantGothic) { + strcpy(icon, programName); + strcpy(title, GOTHIC); +#endif +#ifdef FALCON + } else if (gameInfo.variant == VariantFalcon) { + strcpy(icon, programName); + strcpy(title, FALCON); +#endif } else if (appData.noChessProgram) { strcpy(icon, programName); strcpy(title, programName); @@ -7013,7 +7473,7 @@ void DisplayError(message, error) sprintf(buf, "%s: %s", message, strerror(error)); message = buf; } - ErrorPopUp("Error", message, FALSE); + ErrorPopUp(_("Error"), message, FALSE); } @@ -7027,7 +7487,7 @@ void DisplayMoveError(message) fprintf(stderr, "%s: %s\n", programName, message); } if (appData.popupMoveErrors) { - ErrorPopUp("Error", message, FALSE); + ErrorPopUp(_("Error"), message, FALSE); } else { DisplayMessage(message, ""); } @@ -7050,7 +7510,7 @@ void DisplayFatalError(message, error, status) message = buf; } if (appData.popupExitMessage && boardWidget && XtIsRealized(boardWidget)) { - ErrorPopUp(status ? "Fatal Error" : "Exiting", message, TRUE); + ErrorPopUp(status ? _("Fatal Error") : _("Exiting"), message, TRUE); } else { ExitEvent(status); } @@ -7060,14 +7520,14 @@ void DisplayInformation(message) String message; { ErrorPopDown(); - ErrorPopUp("Information", message, TRUE); + ErrorPopUp(_("Information"), message, TRUE); } void DisplayNote(message) String message; { ErrorPopDown(); - ErrorPopUp("Note", message, FALSE); + ErrorPopUp(_("Note"), message, FALSE); } static int @@ -7117,7 +7577,7 @@ void AskQuestionProc(w, event, prms, nprms) Cardinal *nprms; { if (*nprms != 4) { - fprintf(stderr, "AskQuestionProc needed 4 parameters, got %d\n", + fprintf(stderr, _("AskQuestionProc needed 4 parameters, got %d\n"), *nprms); return; } @@ -7150,7 +7610,7 @@ void AskQuestionReplyAction(w, event, prms, nprms) OutputToProcess(pendingReplyPR, buf, strlen(buf), &err); AskQuestionPopDown(); - if (err) DisplayFatalError("Error writing to chess program", err, 0); + if (err) DisplayFatalError(_("Error writing to chess program"), err, 0); } void AskQuestionCallback(w, client_data, call_data) @@ -7163,7 +7623,7 @@ void AskQuestionCallback(w, client_data, call_data) XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { AskQuestionPopDown(); } else { AskQuestionReplyAction(w, NULL, NULL, NULL); @@ -7202,9 +7662,9 @@ void AskQuestion(title, question, replyPrefix, pr) dialog = XtCreateManagedWidget("question", dialogWidgetClass, layout, args, i); - XawDialogAddButton(dialog, "enter", AskQuestionCallback, + XawDialogAddButton(dialog, _("enter"), AskQuestionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "cancel", AskQuestionCallback, + XawDialogAddButton(dialog, _("cancel"), AskQuestionCallback, (XtPointer) dialog); XtRealizeWidget(popup); @@ -7315,7 +7775,7 @@ Colorize(cc, continuation) count = strlen(buf); outCount = OutputToProcess(NoProc, buf, count, &error); if (outCount < count) { - DisplayFatalError("Error writing to display", error, 1); + DisplayFatalError(_("Error writing to display"), error, 1); } if (continuation) return; @@ -7388,7 +7848,7 @@ static char *ExpandPathName(path) pwd = getpwnam(buf); if (!pwd) { - fprintf(stderr, "ERROR: Unknown user %s (in path %s)\n", + fprintf(stderr, _("ERROR: Unknown user %s (in path %s)\n"), buf, path); return NULL; } @@ -7502,7 +7962,8 @@ AnalysisClockCallback(arg, id) XtPointer arg; XtIntervalId *id; { - if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile + || appData.icsEngineAnalyze) { // [DM] AnalysisPeriodicEvent(0); StartAnalysisClock(); } @@ -7589,7 +8050,9 @@ DisplayWhiteClock(timeRemaining, highlight) int highlight; { Arg args[16]; - DisplayTimerLabel(whiteTimerWidget, "White", timeRemaining, highlight); + + if(appData.noGUI) return; + DisplayTimerLabel(whiteTimerWidget, _("White"), timeRemaining, highlight); if (highlight && iconPixmap == bIconPixmap) { iconPixmap = wIconPixmap; XtSetArg(args[0], XtNiconPixmap, iconPixmap); @@ -7603,7 +8066,9 @@ DisplayBlackClock(timeRemaining, highlight) int highlight; { Arg args[16]; - DisplayTimerLabel(blackTimerWidget, "Black", timeRemaining, highlight); + + if(appData.noGUI) return; + DisplayTimerLabel(blackTimerWidget, _("Black"), timeRemaining, highlight); if (highlight && iconPixmap == wIconPixmap) { iconPixmap = bIconPixmap; XtSetArg(args[0], XtNiconPixmap, iconPixmap); @@ -7659,19 +8124,23 @@ int StartChildProcess(cmdLine, dir, pr) if ((pid = fork()) == 0) { /* Child process */ - dup2(to_prog[0], 0); - dup2(from_prog[1], 1); - close(to_prog[0]); - close(to_prog[1]); + // [HGM] PSWBTM: made order resistant against case where fd of created pipe was 0 or 1 + close(to_prog[1]); // first close the unused pipe ends close(from_prog[0]); - close(from_prog[1]); - dup2(1, fileno(stderr)); /* force stderr to the pipe */ + dup2(to_prog[0], 0); // to_prog was created first, nd is the only one to use 0 or 1 + dup2(from_prog[1], 1); + if(to_prog[0] >= 2) close(to_prog[0]); // if 0 or 1, the dup2 already cosed the original + close(from_prog[1]); // and closing again loses one of the pipes! + if(fileno(stderr) >= 2) // better safe than sorry... + dup2(1, fileno(stderr)); /* force stderr to the pipe */ if (dir[0] != NULLCHAR && chdir(dir) != 0) { perror(dir); exit(1); } + nice(appData.niceEngines); // [HGM] nice: adjust priority of engine proc + execvp(argv[0], argv); /* If we get here, exec failed */ @@ -7692,22 +8161,37 @@ int StartChildProcess(cmdLine, dir, pr) return 0; } +// [HGM] kill: implement the 'hard killing' of AS's Winboard_x +static RETSIGTYPE AlarmCallBack(int n) +{ + return; +} + void -DestroyChildProcess(pr, signal) +DestroyChildProcess(pr, signalType) ProcRef pr; - int signal; + int signalType; { ChildProc *cp = (ChildProc *) pr; if (cp->kind != CPReal) return; cp->kind = CPNone; - if (signal) { - kill(cp->pid, SIGTERM); + if (signalType == 10) { // [HGM] kill: if it does not terminate in 3 sec, kill + signal(SIGALRM, AlarmCallBack); + alarm(3); + if(wait((int *) 0) == -1) { // process does not terminate on its own accord + kill(cp->pid, SIGKILL); // kill it forcefully + wait((int *) 0); // and wait again + } + } else { + if (signalType) { + kill(cp->pid, signalType == 9 ? SIGKILL : SIGTERM); // [HGM] kill: use hard kill if so requested + } + /* Process is exiting either because of the kill or because of + a quit command sent by the backend; either way, wait for it to die. + */ + wait((int *) 0); } - /* Process is exiting either because of the kill or because of - a quit command sent by the backend; either way, wait for it to die. - */ - wait((int *) 0); close(cp->fdFrom); close(cp->fdTo); } @@ -7743,7 +8227,7 @@ int OpenTCP(host, port, pr) ProcRef *pr; { #if OMIT_SOCKETS - DisplayFatalError("Socket support is not configured in", 0, 2); + DisplayFatalError(_("Socket support is not configured in"), 0, 2); #else /* !OMIT_SOCKETS */ int s; struct sockaddr_in sa; @@ -7845,7 +8329,7 @@ int OpenRcmd(host, user, cmd, pr) char *host, *user, *cmd; ProcRef *pr; { - DisplayFatalError("internal rcmd not implemented for Unix", 0, 1); + DisplayFatalError(_("internal rcmd not implemented for Unix"), 0, 1); return -1; } @@ -8571,9 +9055,9 @@ AnimateMove(board, fromX, fromY, toX, toY) #endif if (appData.debugMode) { - printf("AnimateMove: piece %d %s from %d,%d to %d,%d \n", - piece, hop ? "hops" : "slides", fromX, fromY, toX, toY); - } + fprintf(debugFP, hop ? _("AnimateMove: piece %d hops from %d,%d to %d,%d \n") : + _("AnimateMove: piece %d slides from %d,%d to %d,%d \n"), + piece, fromX, fromY, toX, toY); } ScreenSquare(fromX, fromY, &start, &startColor); ScreenSquare(toX, toY, &finish, &endColor); @@ -8728,4 +9212,6 @@ void SetProgramStats( FrontEndProgramStats * stats ) { // [HR] TODO + // [HGM] done, but perhaps backend should call this directly? + EngineOutputUpdate( stats ); }