# endif
#endif
+#if ENABLE_NLS
+#include <locale.h>
+#endif
+
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
void CreatePieceMenus P((void));
Widget CreateMenuBar P((Menu *mb));
Widget CreateButtonBar P ((MenuItem *mi));
+#if ENABLE_NLS
+char *InsertPxlSize P((char *pattern, int targetPxlSize));
+XFontSet CreateFontSet P((char *base_fnt_lst));
+#else
char *FindFont P((char *pattern, int targetPxlSize));
+#endif
void PieceMenuPopup P((Widget w, XEvent *event,
String *params, Cardinal *num_params));
static void PieceMenuSelect P((Widget w, ChessSquare piece, caddr_t junk));
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(());
XSegment secondSegments[BOARD_RANKS + BOARD_FILES + 2];
XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2];
XSegment jailGridSegments[BOARD_RANKS + BOARD_FILES + 6];
-Font clockFontID, coordFontID, countFontID;
-XFontStruct *clockFontStruct, *coordFontStruct, *countFontStruct;
+#if ENABLE_NLS
+XFontSet fontSet, clockFontSet;
+#else
+Font clockFontID;
+XFontStruct *clockFontStruct;
+#endif
+Font coordFontID, countFontID;
+XFontStruct *coordFontStruct, *countFontStruct;
XtAppContext appContext;
char *layoutName;
char *oldICSInteractionTitle;
{N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionProc},
{N_("Edit Tags"), "Edit Tags", EditTagsProc},
{N_("Edit Comment"), "Edit Comment", EditCommentProc},
+ {N_("Edit Book"), "Edit Book", EditBookProc},
{"----", NULL, NothingProc},
{N_("Revert Home"), "Revert", RevertProc},
{N_("Annotate"), "Annotate", AnnotateProc},
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,
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
{ "ShowGameListProc", ShowGameListProc },
{ "ShowMoveListProc", HistoryShowProc},
{ "EditTagsProc", EditCommentProc },
+ { "EditBookProc", EditBookProc },
{ "EditCommentProc", EditCommentProc },
{ "IcsInputBoxProc", IcsInputBoxProc },
{ "PauseProc", PauseProc },
{ "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[] =
// [HGM] font: keep a font for each square size, even non-stndard ones
#define NUM_SIZES 18
#define MAX_SIZE 130
-Boolean fontSet[NUM_FONTS], fontValid[NUM_FONTS][MAX_SIZE];
+Boolean fontIsSet[NUM_FONTS], fontValid[NUM_FONTS][MAX_SIZE];
char *fontTable[NUM_FONTS][MAX_SIZE];
void
default:
return;
}
- fontSet[number] = True; // [HGM] font: indicate a font was specified (not from settings file)
+ fontIsSet[number] = True; // [HGM] font: indicate a font was specified (not from settings file)
}
void
{ // 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);
line[0] = NULLCHAR;
for(i=1; i<argc; i++)
{
- if( (strchr(argv[i], ' ') || strchr(argv[i], '\n') ||strchr(argv[i], '\t') )
+ if( (strchr(argv[i], ' ') || strchr(argv[i], '\n') ||strchr(argv[i], '\t') || argv[i][0] == NULLCHAR)
&& argv[i][0] != '{' )
snprintf(buf, sizeof(buf)/sizeof(buf[0]), "{%s} ", argv[i]);
else
setbuf(debugFP, NULL);
}
+#if ENABLE_NLS
+ if (appData.debugMode) {
+ fprintf(debugFP, "locale = %s\n", setlocale(LC_ALL, NULL));
+ }
+#endif
+
/* [HGM,HR] make sure board size is acceptable */
if(appData.NrFiles > BOARD_FILES ||
appData.NrRanks > BOARD_RANKS )
tinyLayout = szd->tinyLayout;
// [HGM] font: use defaults from settings file if available and not overruled
}
- if(!fontSet[CLOCK_FONT] && fontValid[CLOCK_FONT][squareSize])
+ if(!fontIsSet[CLOCK_FONT] && fontValid[CLOCK_FONT][squareSize])
appData.clockFont = fontTable[CLOCK_FONT][squareSize];
- if(!fontSet[MESSAGE_FONT] && fontValid[MESSAGE_FONT][squareSize])
+ if(!fontIsSet[MESSAGE_FONT] && fontValid[MESSAGE_FONT][squareSize])
appData.font = fontTable[MESSAGE_FONT][squareSize];
- if(!fontSet[COORD_FONT] && fontValid[COORD_FONT][squareSize])
+ if(!fontIsSet[COORD_FONT] && fontValid[COORD_FONT][squareSize])
appData.coordFont = fontTable[COORD_FONT][squareSize];
/* Now, using squareSize as a hint, find a good XPM/XIM set size */
/*
* Determine what fonts to use.
*/
+#if ENABLE_NLS
+ appData.font = InsertPxlSize(appData.font, fontPxlSize);
+ appData.clockFont = InsertPxlSize(appData.clockFont, clockFontPxlSize);
+ 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);
- appData.coordFont = FindFont(appData.coordFont, coordFontPxlSize);
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);
+#endif
+ countFontID = coordFontID; // [HGM] holdings
+ countFontStruct = coordFontStruct;
xdb = XtDatabase(xDisplay);
+#if ENABLE_NLS
+ XrmPutLineResource(&xdb, "*international: True");
+ vTo.size = sizeof(XFontSet);
+ vTo.addr = (XtPointer) &fontSet;
+ XrmPutResource(&xdb, "*fontSet", XtRFontSet, &vTo);
+#else
XrmPutStringResource(&xdb, "*font", appData.font);
+#endif
/*
* Detect if there are not enough colors available and adapt.
widgetList[j++] = whiteTimerWidget =
XtCreateWidget("whiteTime", labelWidgetClass,
formWidget, timerArgs, XtNumber(timerArgs));
+#if ENABLE_NLS
+ XtSetArg(args[0], XtNfontSet, clockFontSet);
+#else
XtSetArg(args[0], XtNfont, clockFontStruct);
+#endif
XtSetArg(args[1], XtNtop, XtChainTop);
XtSetArg(args[2], XtNbottom, XtChainTop);
XtSetValues(whiteTimerWidget, args, 3);
widgetList[j++] = blackTimerWidget =
XtCreateWidget("blackTime", labelWidgetClass,
formWidget, timerArgs, XtNumber(timerArgs));
+#if ENABLE_NLS
+ XtSetArg(args[0], XtNfontSet, clockFontSet);
+#else
XtSetArg(args[0], XtNfont, clockFontStruct);
+#endif
XtSetArg(args[1], XtNtop, XtChainTop);
XtSetArg(args[2], XtNbottom, XtChainTop);
XtSetValues(blackTimerWidget, args, 3);
return 0;
}
+static Boolean noEcho;
+
void
ShutDownFrontEnd()
{
if (saveSettingsOnExit) SaveSettings(settingsFileName);
unlink(gameCopyFilename);
unlink(gamePasteFilename);
+ if(noEcho) EchoOn();
}
RETSIGTYPE TermSizeSigHandler(int sig)
#define Abs(n) ((n)<0 ? -(n) : (n))
+#ifdef ENABLE_NLS
+char *
+InsertPxlSize(pattern, targetPxlSize)
+ char *pattern;
+ int targetPxlSize;
+{
+ char *base_fnt_lst, strInt[12], *p, *q;
+ int alternatives, i, len, strIntLen;
+
+ /*
+ * 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;
+ }
+ strcpy(q, p);
+
+ return base_fnt_lst;
+}
+
+XFontSet
+CreateFontSet(base_fnt_lst)
+ char *base_fnt_lst;
+{
+ XFontSet fntSet;
+ char **missing_list;
+ int missing_count;
+ char *def_string;
+
+ fntSet = XCreateFontSet(xDisplay, base_fnt_lst,
+ &missing_list, &missing_count, &def_string);
+ 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\n", missing_list[i]);
+ }
+ }
+ if (fntSet == NULL) {
+ fprintf(stderr, _("Unable to create font set for %s.\n"), base_fnt_lst);
+ exit(2);
+ }
+ return fntSet;
+}
+#else // not ENABLE_NLS
/*
* Find a font that matches "pattern" that is as close as
* possible to the targetPxlSize. Prefer fonts that are k
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);
- snprintf(strInt, sizeof(strInt)/sizeof(strInt[0]), "%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"),
programName, pattern);
exit(2);
}
-#endif
best = fonts[0];
scalable = NULL;
fprintf(debugFP, _("resolved %s at pixel size %d\n to %s\n"),
pattern, targetPxlSize, p);
}
-#ifdef ENABLE_NLS
- if (missing_count > 0)
- XFreeStringList(missing_list);
- XFreeFontSet(xDisplay, fntSet);
-#else
- XFreeFontNames(fonts);
-#endif
+ XFreeFontNames(fonts);
return p;
}
+#endif
void DeleteGCs()
{ // [HGM] deletes GCs that are to be remade, to prevent resource leak;
(XtPointer) dialog);
XawDialogAddButton(dialog, _("Captain"), PromotionCallback,
(XtPointer) dialog);
- } else {\r
+ } else {
XawDialogAddButton(dialog, _("Queen"), PromotionCallback,
(XtPointer) dialog);
XawDialogAddButton(dialog, _("Rook"), PromotionCallback,
(XtPointer) dialog);
}
if (!appData.testLegality || gameInfo.variant == VariantSuicide ||
- gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) ||\r
+ gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) ||
gameInfo.variant == VariantGiveaway) {
XawDialogAddButton(dialog, _("King"), PromotionCallback,
(XtPointer) dialog);
String *prms;
Cardinal *nprms;
{
- MatchEvent(2);\r
+ MatchEvent(2);
}
void IcsClientProc(w, event, prms, nprms)
}
void
+PlayTellSound()
+{
+ PlaySound(appData.soundTell);
+}
+
+void
EchoOn()
{
system("stty echo");
+ noEcho = False;
}
void
EchoOff()
{
system("stty -echo");
+ noEcho = True;
}
void
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
+}
+