# 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 UploadProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void BackwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void ForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void TempBackwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void TempForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+Boolean TempBackwardActive = False;
void ToStartProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void ToEndProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void RevertProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void AboutProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void DebugProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void NothingProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
-void Iconify P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void DisplayMove P((int moveNumber));
void DisplayTitle P((char *title));
void ICSInitScript P((void));
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_("Machine Black Ctrl+B"), "Machine Black", MachineBlackProc},
{N_("Two Machines Ctrl+T"), "Two Machines", TwoMachinesProc},
{N_("Analysis Mode Ctrl+A"), "Analysis Mode", AnalyzeModeProc},
- {N_("Analyze File Ctrl+F"), "Analyze File", AnalyzeFileProc },
+ {N_("Analyze Game Ctrl+G"), "Analyze File", AnalyzeFileProc },
{N_("Edit Game Ctrl+E"), "Edit Game", EditGameProc},
{N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionProc},
{N_("Training"), "Training", TrainingProc},
MenuItem buttonBar[] = {
{"<<", "<<", ToStartProc},
{"<", "<", BackwardProc},
- {PAUSE_BUTTON, PAUSE_BUTTON, PauseProc},
+ {N_(PAUSE_BUTTON), PAUSE_BUTTON, PauseProc},
{">", ">", ForwardProc},
{">>", ">>", ToEndProc},
{NULL, NULL, NULL}
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
{ "PieceMenuPopup", PieceMenuPopup },
{ "WhiteClock", WhiteClock },
{ "BlackClock", BlackClock },
- { "Iconify", Iconify },
{ "ResetProc", ResetProc },
{ "NewVariantProc", NewVariantProc },
{ "LoadGameProc", LoadGameProc },
{ "ShowGameListProc", ShowGameListProc },
{ "ShowMoveListProc", HistoryShowProc},
{ "EditTagsProc", EditCommentProc },
+ { "EditBookProc", EditBookProc },
{ "EditCommentProc", EditCommentProc },
{ "IcsInputBoxProc", IcsInputBoxProc },
{ "PauseProc", PauseProc },
{ "UploadProc", UploadProc },
{ "BackwardProc", BackwardProc },
{ "ForwardProc", ForwardProc },
+ { "TempBackwardProc", TempBackwardProc },
+ { "TempForwardProc", TempForwardProc },
{ "ToStartProc", ToStartProc },
{ "ToEndProc", ToEndProc },
{ "RevertProc", RevertProc },
{ "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[] =
:Ctrl<Key>o: LoadGameProc() \n \
:Meta<Key>Next: LoadNextGameProc() \n \
:Meta<Key>Prior: LoadPrevGameProc() \n \
+ :Ctrl<Key>Down: LoadSelectedProc(3) \n \
+ :Ctrl<Key>Up: LoadSelectedProc(-3) \n \
:Ctrl<Key>s: SaveGameProc() \n \
:Ctrl<Key>c: CopyGameProc() \n \
:Ctrl<Key>v: PasteGameProc() \n \
:Ctrl<Key>b: MachineBlackProc() \n \
:Ctrl<Key>t: TwoMachinesProc() \n \
:Ctrl<Key>a: AnalysisModeProc() \n \
- :Ctrl<Key>f: AnalyzeFileProc() \n \
+ :Ctrl<Key>g: AnalyzeFileProc() \n \
:Ctrl<Key>e: EditGameProc() \n \
:Ctrl<Key>E: EditPositionProc() \n \
:Meta<Key>O: EngineOutputProc() \n \
:Meta<Key>Right: ForwardProc() \n \
:Meta<Key>Home: ToStartProc() \n \
:Meta<Key>Left: BackwardProc() \n \
+ :<Key>Left: BackwardProc() \n \
+ :<Key>Right: ForwardProc() \n \
:<Key>Home: RevertProc() \n \
:<Key>End: TruncateGameProc() \n \
:Ctrl<Key>m: MoveNowProc() \n \
:Ctrl<Key>H: HideThinkingProc() \n "
#endif
"\
- :<Key>-: Iconify() \n \
:<Key>F1: ManProc() \n \
:<Key>F2: FlipViewProc() \n \
- <KeyDown>.: BackwardProc() \n \
- <KeyUp>.: ForwardProc() \n \
- Shift<Key>1: AskQuestionProc(\"Direct command\",\
+ :Ctrl<KeyDown>.: TempBackwardProc() \n \
+ :Ctrl<KeyUp>.: TempForwardProc() \n \
+ :Ctrl<Key>1: AskQuestionProc(\"Direct command\",\
\"Send to chess program:\",,1) \n \
- Shift<Key>2: AskQuestionProc(\"Direct command\",\
+ :Ctrl<Key>2: AskQuestionProc(\"Direct command\",\
\"Send to second chess program:\",,2) \n";
char boardTranslations[] =
Any<Btn3Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD) \
PieceMenuPopup(menuB) \n";
-char whiteTranslations[] = "<BtnDown>: WhiteClock()\n";
-char blackTranslations[] = "<BtnDown>: BlackClock()\n";
+char whiteTranslations[] =
+ "Shift<BtnDown>: WhiteClock(1)\n \
+ <BtnDown>: WhiteClock(0)\n";
+char blackTranslations[] =
+ "Shift<BtnDown>: BlackClock(1)\n \
+ <BtnDown>: BlackClock(0)\n";
char ICSInputTranslations[] =
"<Key>Up: UpKeyProc() \n "
// [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
Arg args[16];
XtGeometryResult gres;
int i;
+ static Dimension oldWidth, oldHeight;
+ static VariantClass oldVariant;
+ static int oldDual = -1, oldMono = -1;
if(!formWidget) return;
+ if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap;
+ boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
+ boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
+
+ if(boardWidth != oldWidth || boardHeight != oldHeight || oldDual != twoBoards) { // do resizing stuff only if size actually changed
/*
* Enable shell resizing.
*/
XtSetArg(args[0], XtNdefaultDistance, &sep);
XtGetValues(formWidget, args, 1);
- if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap;
- boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
- boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
+ oldWidth = boardWidth; oldHeight = boardHeight; oldDual = twoBoards;
CreateGrid();
hOffset = boardWidth + 10;
for(i=0; i<BOARD_WIDTH+BOARD_HEIGHT+2; i++) { // [HGM] dual: grid for second board
shellArgs[4].value = shellArgs[2].value = w;
shellArgs[5].value = shellArgs[3].value = h;
XtSetValues(shellWidget, &shellArgs[0], 6);
+ }
// [HGM] pieces: tailor piece bitmaps to needs of specific variant
// (only for xpm)
+
+ if(gameInfo.variant != oldVariant) { // and only if variant changed
+
if(useImages) {
for(i=0; i<4; i++) {
int p;
}
}
}
+ }
#if HAVE_LIBXPM
+ if(appData.monoMode == oldMono)
CreateAnimVars();
#endif
+ oldMono = appData.monoMode;
}
#endif
#if HAVE_LIBXPM
if (appData.monoMode && // [HGM] no sense to go on to certain doom
(appData.bitmapDirectory == NULL || appData.bitmapDirectory[0] == NULLCHAR))
- appData.bitmapDirectory = DEF_BITMAP_DIR;
+ appData.bitmapDirectory = strdup(DEF_BITMAP_DIR);
if (appData.bitmapDirectory[0] != NULLCHAR) {
CreatePieces();
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)
{ "menuEngine.Engine #2 Settings", False },
{ "menuEngine.Load Engine", False },
{ "menuEdit.Annotate", False },
+ { "menuOptions.Match", False },
{ NULL, False }
};
{ "menuMode.Machine White", False },
{ "menuMode.Machine Black", False },
{ "menuMode.Two Machines", False },
- { "menuMode.Machine Match", False },
+// { "menuMode.Machine Match", False },
{ "menuEngine.Retract Move", False },
{ NULL, False }
};
{ "menuMode.Machine White", True },
{ "menuMode.Machine Black", True },
{ "menuMode.Two Machines", True },
- { "menuMode.Machine Match", True },
+// { "menuMode.Machine Match", True },
{ "menuEngine.Retract Move", True },
{ NULL, False }
};
#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;
{
XpmAttributes attr;
attr.valuemask = 0;
- if(s == NULL || *s == 0 || *s == '*') { useTexture &= ~(kind+1); return; }
+ if(!appData.useBitmaps || s == NULL || *s == 0 || *s == '*') { useTexture &= ~(kind+1); return; }
if (XpmReadFileToPixmap(xDisplay, xBoardWindow, s, &(xpmBoardBitmap[kind]), NULL, &attr) == 0) {
useTexture |= kind + 1; textureW[kind] = attr.width; textureH[kind] = attr.height;
}
String *prms;
Cardinal *nprms;
{
+ shiftKey = prms[0][0] & 1;
ClockClick(0);
}
String *prms;
Cardinal *nprms;
{
+ shiftKey = prms[0][0] & 1;
ClockClick(1);
}
}
}
if(!partnerUp && marker[row][column]) {
+ if(appData.monoMode) {
+ XFillArc(xDisplay, xBoardWindow, marker[row][column] == 2 ? darkSquareGC : lightSquareGC,
+ x + squareSize/4, y+squareSize/4, squareSize/2, squareSize/2, 0, 64*360);
+ XDrawArc(xDisplay, xBoardWindow, marker[row][column] == 2 ? lightSquareGC : darkSquareGC,
+ x + squareSize/4, y+squareSize/4, squareSize/2, squareSize/2, 0, 64*360);
+ } else
XFillArc(xDisplay, xBoardWindow, marker[row][column] == 2 ? prelineGC : highlineGC,
x + squareSize/4, y+squareSize/4, squareSize/2, squareSize/2, 0, 64*360);
}
PopDown(1);
}
+static char *openName;
+FILE *openFP;
+
+void DelayedLoad()
+{
+ (void) (*fileProc)(openFP, 0, openName);
+}
+
void FileNamePopUp(label, def, filter, proc, openMode)
char *label;
char *def;
fileProc = proc; /* I can't see a way not */
fileOpenMode = openMode; /* to use globals here */
{ // [HGM] use file-selector dialog stolen from Ghostview
- char *name;
int index; // this is not supported yet
- FILE *f;
- if(f = XsraSelFile(shellWidget, label, NULL, NULL, "could not open: ",
- (def[0] ? def : NULL), filter, openMode, NULL, &name))
- (void) (*fileProc)(f, index=0, name);
+ if(openFP = XsraSelFile(shellWidget, label, NULL, NULL, _("could not open: "),
+ (def[0] ? def : NULL), filter, openMode, NULL, &openName))
+ // [HGM] delay to give expose event opportunity to redraw board after browser-dialog popdown before lengthy load starts
+ ScheduleDelayedEvent(&DelayedLoad, 50);
}
}
Position x, y;
Dimension bw_width, pw_width;
int j;
+ char *PromoChars = "wglcqrbnkac+=\0";
j = 0;
XtSetArg(args[j], XtNwidth, &bw_width); j++;
if(gameInfo.variant != VariantShogi) {
if(gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove)) {
- XawDialogAddButton(dialog, _("Warlord"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("General"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Lieutenant"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Captain"), PromotionCallback,
- (XtPointer) dialog);
- } else {\r
- XawDialogAddButton(dialog, _("Queen"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Rook"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Bishop"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Knight"), PromotionCallback,
- (XtPointer) dialog);
+ XawDialogAddButton(dialog, _("Warlord"), PromotionCallback, PromoChars + 0);
+ XawDialogAddButton(dialog, _("General"), PromotionCallback, PromoChars + 1);
+ XawDialogAddButton(dialog, _("Lieutenant"), PromotionCallback, PromoChars + 2);
+ XawDialogAddButton(dialog, _("Captain"), PromotionCallback, PromoChars + 3);
+ } else {
+ XawDialogAddButton(dialog, _("Queen"), PromotionCallback, PromoChars + 4);
+ XawDialogAddButton(dialog, _("Rook"), PromotionCallback, PromoChars + 5);
+ XawDialogAddButton(dialog, _("Bishop"), PromotionCallback, PromoChars + 6);
+ XawDialogAddButton(dialog, _("Knight"), PromotionCallback, PromoChars + 7);
}
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);
+ XawDialogAddButton(dialog, _("King"), PromotionCallback, PromoChars + 8);
}
if(gameInfo.variant == VariantCapablanca ||
gameInfo.variant == VariantGothic ||
gameInfo.variant == VariantCapaRandom) {
- XawDialogAddButton(dialog, _("Archbishop"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Chancellor"), PromotionCallback,
- (XtPointer) dialog);
+ XawDialogAddButton(dialog, _("Archbishop"), PromotionCallback, PromoChars + 9);
+ XawDialogAddButton(dialog, _("Chancellor"), PromotionCallback, PromoChars + 10);
}
} else // [HGM] shogi
{
- XawDialogAddButton(dialog, _("Promote"), PromotionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("Defer"), PromotionCallback,
- (XtPointer) dialog);
+ XawDialogAddButton(dialog, _("Promote"), PromotionCallback, PromoChars + 11);
+ XawDialogAddButton(dialog, _("Defer"), PromotionCallback, PromoChars + 12);
}
- XawDialogAddButton(dialog, _("cancel"), PromotionCallback,
- (XtPointer) dialog);
+ XawDialogAddButton(dialog, _("cancel"), PromotionCallback, PromoChars + 13);
XtRealizeWidget(promotionShell);
CatchDeleteWindow(promotionShell, "PromotionPopDown");
Widget w;
XtPointer client_data, call_data;
{
- String name;
- Arg args[16];
- int promoChar;
-
- XtSetArg(args[0], XtNlabel, &name);
- XtGetValues(w, args, 1);
+ int promoChar = * (const char *) client_data;
PromotionPopDown();
if (fromX == -1) return;
- if (strcmp(name, _("cancel")) == 0) {
+ if (! promoChar) {
fromX = fromY = -1;
ClearHighlights();
return;
- } else if (strcmp(name, _("Knight")) == 0) {
- promoChar = 'n';
- } else if (strcmp(name, _("Promote")) == 0) {
- promoChar = '+';
- } else if (strcmp(name, _("Defer")) == 0) {
- promoChar = '=';
- } else {
- promoChar = ToLower(name[0]);
}
-
UserMoveEvent(fromX, fromY, toX, toY, promoChar);
if (!appData.highlightLastMove || gotPremove) ClearHighlights();
XtSetValues(XtNameToWidget(menuBarWidget, wname), args, 1);
}
oldmode = gameMode;
+ XtSetArg(args[0], XtNleftBitmap, matchMode && matchGame < appData.matchGames ? xMarkPixmap : None);
+ XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Machine Match"), args, 1);
/* Maybe all the enables should be handled here, not just this one */
XtSetSensitive(XtNameToWidget(menuBarWidget, "menuMode.Training"),
*value_return = targets_tmp;
*type_return = XA_ATOM;
*length_return = 2;
+#if 0
+ // This code leads to a read of value_return out of bounds on 64-bit systems.
+ // Other code which I have seen always sets *format_return to 32 independent of
+ // sizeof(Atom) without adjusting *length_return. For instance see TextConvertSelection()
+ // at http://cgit.freedesktop.org/xorg/lib/libXaw/tree/src/Text.c -- BJ
*format_return = 8 * sizeof(Atom);
if (*format_return > 32) {
*length_return *= *format_return / 32;
*format_return = 32;
}
+#else
+ *format_return = 32;
+#endif
return True;
} else {
return False;
*value_return = targets_tmp;
*type_return = XA_ATOM;
*length_return = 2;
+#if 0
+ // This code leads to a read of value_return out of bounds on 64-bit systems.
+ // Other code which I have seen always sets *format_return to 32 independent of
+ // sizeof(Atom) without adjusting *length_return. For instance see TextConvertSelection()
+ // at http://cgit.freedesktop.org/xorg/lib/libXaw/tree/src/Text.c -- BJ
*format_return = 8 * sizeof(Atom);
if (*format_return > 32) {
*length_return *= *format_return / 32;
*format_return = 32;
}
+#else
+ *format_return = 32;
+#endif
return True;
} else {
return False;
void CopySomething()
{
- int ret;
-
/*
* Set both PRIMARY (the selection) and CLIPBOARD, since we don't
* have a notion of a game that is selected but not copied.
DisplayError(buf, 0);
return;
}
- Reset(FALSE, TRUE);
+// Reset(FALSE, TRUE);
#ifndef OPTIONSDIALOG
if (!appData.showThinking)
ShowThinkingProc(w,event,prms,nprms);
#endif
AnalyzeFileEvent();
- FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb");
+// FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb");
AnalysisPeriodicEvent(1);
}
String *prms;
Cardinal *nprms;
{
- if(gameMode != BeginningOfGame) { DisplayError(_("You can only start a match from the initial position."), 0); return; }
- appData.matchGames = appData.defaultMatchGames;
- MatchEvent(2);\r
+ MatchEvent(2);
}
void IcsClientProc(w, event, prms, nprms)
BackwardEvent();
}
+void TempBackwardProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ if (!TempBackwardActive) {
+ TempBackwardActive = True;
+ BackwardEvent();
+ }
+}
+
+void TempForwardProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ /* Check to see if triggered by a key release event for a repeating key.
+ * If so the next queued event will be a key press of the same key at the same time */
+ if (XEventsQueued(xDisplay, QueuedAfterReading)) {
+ XEvent next;
+ XPeekEvent(xDisplay, &next);
+ if (next.type == KeyPress && next.xkey.time == event->xkey.time &&
+ next.xkey.keycode == event->xkey.keycode)
+ return;
+ }
+ ForwardEvent();
+ TempBackwardActive = False;
+}
+
void ToStartProc(w, event, prms, nprms)
Widget w;
XEvent *event;
{
char buf[MSG_SIZ];
#if ZIPPY
- char *zippy = " (with Zippy code)";
+ char *zippy = _(" (with Zippy code)");
#else
char *zippy = "";
#endif
- snprintf(buf, sizeof(buf), "%s%s\n\n%s\n%s\n%s\n\n%s%s\n%s",
- programVersion, zippy,
- "Copyright 1991 Digital Equipment Corporation",
- "Enhancements Copyright 1992-2009 Free Software Foundation",
- "Enhancements Copyright 2005 Alessandro Scotti",
- PACKAGE, " is free software and carries NO WARRANTY;",
- "see the file COPYING for more information.");
+ snprintf(buf, sizeof(buf),
+_("%s%s\n\n"
+"Copyright 1991 Digital Equipment Corporation\n"
+"Enhancements Copyright 1992-2009 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."),
+ programVersion, zippy, PACKAGE);
ErrorPopUp(_("About XBoard"), buf, FALSE);
}
return;
}
-void Iconify(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
-{
- Arg args[16];
-
- fromX = fromY = -1;
- XtSetArg(args[0], XtNiconic, True);
- XtSetValues(shellWidget, args, 1);
-}
-
void DisplayMessage(message, extMessage)
char *message, *extMessage;
{
};
};
+ safeStrCpy(lastMsg, message, MSG_SIZ); // [HGM] make available
+
/* need to test if messageWidget already exists, since this function
can also be called during the startup, if for example a Xresource
is not set up correctly */
XtSetArg(args[i], XtNiconName, (XtArgVal) icon); i++;
XtSetArg(args[i], XtNtitle, (XtArgVal) title); i++;
XtSetValues(shellWidget, args, i);
+ XSync(xDisplay, False);
}
} else {
char buf[2048];
char *prefix = "", *sep = "";
+ if(appData.soundProgram[0] == NULLCHAR) return;
if(!strchr(name, '/')) { prefix = appData.soundDirectory; sep = "/"; }
snprintf(buf, sizeof(buf), "%s '%s%s%s' &", appData.soundProgram, prefix, sep, name);
system(buf);
}
void
+PlayTellSound()
+{
+ PlaySound(appData.soundTell);
+}
+
+void
EchoOn()
{
system("stty echo");
+ noEcho = False;
}
void
EchoOff()
{
system("stty -echo");
+ noEcho = True;
+}
+
+void
+RunCommand(char *buf)
+{
+ system(buf);
}
void
struct addrinfo hints;
struct addrinfo *ais, *ai;
int error;
- int s;
+ int s=0;
ChildProc *cp;
memset(&hints, 0, sizeof(hints));
#endif
+void
+DoSleep(int n)
+{
+ FrameDelay(n);
+}
+
/* Convert board position to corner of screen rect and color */
static void
}
void
-DragPieceBegin(x, y)
- int x; int y;
+DragPieceBegin(x, y, instantly)
+ int x; int y; Boolean instantly;
{
int boardX, boardY, color;
XPoint corner;
/* Draw an arrow between two points using current settings */
void DrawArrowBetweenPoints( int s_x, int s_y, int d_x, int d_y )
{
- XPoint arrow[7];
+ XPoint arrow[8];
double dx, dy, j, k, x, y;
if( d_x == s_x ) {
}
XFillPolygon(xDisplay, xBoardWindow, highlineGC, arrow, 7, Nonconvex, CoordModeOrigin);
+ if(appData.monoMode) arrow[7] = arrow[0], XDrawLines(xDisplay, xBoardWindow, darkSquareGC, arrow, 8, CoordModeOrigin);
// Polygon( hdc, arrow, 7 );
}
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
+}
+