X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=dae38f2a7b84771d5db95cb391c842703b66b42f;hb=23c979bdeba73c3b697c7c0ce87586df3c87896a;hp=f9fe68f1e85e5e1f5500e975f75a3740ce3435b9;hpb=28c8627bf447437dc772045aec1ce7c0d18b7d5a;p=xboard.git diff --git a/xboard.c b/xboard.c index f9fe68f..dae38f2 100644 --- a/xboard.c +++ b/xboard.c @@ -142,6 +142,10 @@ extern char *getenv(); # endif #endif +#if ENABLE_NLS +#include +#endif + #include #include #include @@ -469,9 +473,8 @@ void BoardOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms) void LoadOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void SaveOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void EditBookProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void SelectMove P((Widget w, XEvent * event, String * params, Cardinal * nParams)); void GameListOptionsPopDown P(()); -void ShufflePopDown P(()); -void TimeControlPopDown P(()); void GenericPopDown P(()); void update_ics_width P(()); int get_term_width P(()); @@ -814,7 +817,7 @@ String pieceMenuStrings[2][PIECE_MENU_SIZE] = { N_("Archbishop"), N_("Chancellor"), "----", N_("Promote"), N_("Demote"), N_("Empty square"), N_("Clear board") } }; -/* must be in same order as PieceMenuStrings! */ +/* must be in same order as pieceMenuStrings! */ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { { WhitePlay, (ChessSquare) 0, WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, WhiteKing, (ChessSquare) 0, WhiteAlfil, @@ -830,7 +833,7 @@ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { String dropMenuStrings[DROP_MENU_SIZE] = { "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), N_("Queen") }; -/* must be in same order as PieceMenuStrings! */ +/* must be in same order as dropMenuStrings! */ ChessSquare dropMenuTranslation[DROP_MENU_SIZE] = { (ChessSquare) 0, WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen @@ -1034,13 +1037,11 @@ XtActionsRec boardActions[] = { { "GameListPopDown", (XtActionProc) GameListPopDown }, { "GameListOptionsPopDown", (XtActionProc) GameListOptionsPopDown }, { "PromotionPopDown", (XtActionProc) PromotionPopDown }, - { "HistoryPopDown", (XtActionProc) HistoryPopDown }, { "EngineOutputPopDown", (XtActionProc) EngineOutputPopDown }, { "EvalGraphPopDown", (XtActionProc) EvalGraphPopDown }, - { "ShufflePopDown", (XtActionProc) ShufflePopDown }, - { "TimeControlPopDown", (XtActionProc) TimeControlPopDown }, { "GenericPopDown", (XtActionProc) GenericPopDown }, { "CopyMemoProc", (XtActionProc) CopyMemoProc }, + { "SelectMove", (XtActionProc) SelectMove }, }; char globalTranslations[] = @@ -1588,8 +1589,8 @@ GetWindowCoords() { // wrapper to shield use of window handles from back-end (make addressible by number?) // In XBoard this will have to wait until awareness of window parameters is implemented GetActualPlacement(shellWidget, &wpMain); - if(EngineOutputIsUp()) GetActualPlacement(engineOutputShell, &wpEngineOutput); else - if(MoveHistoryIsUp()) GetActualPlacement(historyShell, &wpMoveHistory); + if(EngineOutputIsUp()) GetActualPlacement(engineOutputShell, &wpEngineOutput); + if(MoveHistoryIsUp()) GetActualPlacement(shells[7], &wpMoveHistory); if(EvalGraphIsUp()) GetActualPlacement(evalGraphShell, &wpEvalGraph); if(GameListIsUp()) GetActualPlacement(gameListShell, &wpGameList); if(shellUp[1]) GetActualPlacement(shells[1], &wpComment); @@ -1647,7 +1648,7 @@ ConvertToLine(int argc, char **argv) line[0] = NULLCHAR; for(i=1; i BOARD_FILES || appData.NrRanks > BOARD_RANKS ) @@ -2158,17 +2165,26 @@ XBoard square size (hint): %d\n\ appData.coordFont = InsertPxlSize(appData.coordFont, coordFontPxlSize); fontSet = CreateFontSet(appData.font); clockFontSet = CreateFontSet(appData.clockFont); + { + /* For the coordFont, use the 0th font of the fontset. */ + XFontSet coordFontSet = CreateFontSet(appData.coordFont); + XFontStruct **font_struct_list; + char **font_name_list; + XFontsOfFontSet(coordFontSet, &font_struct_list, &font_name_list); + coordFontID = XLoadFont(xDisplay, font_name_list[0]); + coordFontStruct = XQueryFont(xDisplay, coordFontID); + } #else appData.font = FindFont(appData.font, fontPxlSize); appData.clockFont = FindFont(appData.clockFont, clockFontPxlSize); appData.coordFont = FindFont(appData.coordFont, coordFontPxlSize); clockFontID = XLoadFont(xDisplay, appData.clockFont); clockFontStruct = XQueryFont(xDisplay, clockFontID); -#endif coordFontID = XLoadFont(xDisplay, appData.coordFont); coordFontStruct = XQueryFont(xDisplay, coordFontID); - countFontID = XLoadFont(xDisplay, appData.coordFont); // [HGM] holdings - countFontStruct = XQueryFont(xDisplay, countFontID); +#endif + countFontID = coordFontID; // [HGM] holdings + countFontStruct = coordFontStruct; xdb = XtDatabase(xDisplay); #if ENABLE_NLS @@ -3111,18 +3127,51 @@ InsertPxlSize(pattern, targetPxlSize) char *pattern; int targetPxlSize; { - char *base_fnt_lst, strInt[3], *p; + char *base_fnt_lst, strInt[12], *p, *q; + int alternatives, i, len, strIntLen; - base_fnt_lst = calloc(1, strlen(pattern) + 3); - snprintf(strInt, sizeof(strInt)/sizeof(strInt[0]), "%d", targetPxlSize); - p = strstr(pattern, "--"); - if (p == NULL) { - /* Can't insert size; use string as-is */ - return pattern; + /* + * Replace the "*" (if present) in the pixel-size slot of each + * alternative with the targetPxlSize. + */ + p = pattern; + alternatives = 1; + while ((p = strchr(p, ',')) != NULL) { + alternatives++; + p++; + } + snprintf(strInt, sizeof(strInt), "%d", targetPxlSize); + strIntLen = strlen(strInt); + base_fnt_lst = calloc(1, strlen(pattern) + strIntLen * alternatives + 1); + + p = pattern; + q = base_fnt_lst; + while (alternatives--) { + char *comma = strchr(p, ','); + for (i=0; i<14; i++) { + char *hyphen = strchr(p, '-'); + if (!hyphen) break; + if (comma && hyphen > comma) break; + len = hyphen + 1 - p; + if (i == 7 && *p == '*' && len == 2) { + p += len; + memcpy(q, strInt, strIntLen); + q += strIntLen; + *q++ = '-'; + } else { + memcpy(q, p, len); + p += len; + q += len; + } + } + if (!comma) break; + len = comma + 1 - p; + memcpy(q, p, len); + p += len; + q += len; } - strncpy(base_fnt_lst, pattern, p - pattern + 2); - strcat(base_fnt_lst, strInt); - strcat(base_fnt_lst, strchr(p + 2, '-')); + strcpy(q, p); + return base_fnt_lst; } @@ -3137,11 +3186,22 @@ CreateFontSet(base_fnt_lst) fntSet = XCreateFontSet(xDisplay, base_fnt_lst, &missing_list, &missing_count, &def_string); - if (missing_count > 0 && appData.debugMode) { - int i; + if (appData.debugMode) { + int i, count; + XFontStruct **font_struct_list; + char **font_name_list; + fprintf(debugFP, "Requested font set for list %s\n", base_fnt_lst); + if (fntSet) { + fprintf(debugFP, " got list %s, locale %s\n", + XBaseFontNameListOfFontSet(fntSet), + XLocaleOfFontSet(fntSet)); + count = XFontsOfFontSet(fntSet, &font_struct_list, &font_name_list); + for (i = 0; i < count; i++) { + fprintf(debugFP, " got charset %s\n", font_name_list[i]); + } + } for (i = 0; i < missing_count; i++) { - fprintf(debugFP, _("Missing charset %s for %s (usually harmless)\n"), - missing_list[i], base_fnt_lst); + fprintf(debugFP, " missing charset %s\n", missing_list[i]); } } if (fntSet == NULL) { @@ -5063,7 +5123,7 @@ void PromotionPopUp() (XtPointer) dialog); XawDialogAddButton(dialog, _("Captain"), PromotionCallback, (XtPointer) dialog); - } else { + } else { XawDialogAddButton(dialog, _("Queen"), PromotionCallback, (XtPointer) dialog); XawDialogAddButton(dialog, _("Rook"), PromotionCallback, @@ -5074,7 +5134,7 @@ void PromotionPopUp() (XtPointer) dialog); } if (!appData.testLegality || gameInfo.variant == VariantSuicide || - gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) || + gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) || gameInfo.variant == VariantGiveaway) { XawDialogAddButton(dialog, _("King"), PromotionCallback, (XtPointer) dialog); @@ -5886,7 +5946,7 @@ void MatchProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - MatchEvent(2); + MatchEvent(2); } void IcsClientProc(w, event, prms, nprms) @@ -7164,6 +7224,12 @@ PlayAlarmSound() } void +PlayTellSound() +{ + PlaySound(appData.soundTell); +} + +void EchoOn() { system("stty echo"); @@ -8938,3 +9004,9 @@ void DrawArrowHighlight(int fromX, int fromY, int toX,int toY) if( IsDrawArrowEnabled() && fromX >= 0 && fromY >= 0 && toX >= 0 && toY >= 0) DrawArrowBetweenSquares(fromX, fromY, toX, toY); } + +void UpdateLogos(int displ) +{ + return; // no logos in XBoard yet +} +