/xboard-4.5.2a/xboard.c
C | 9144 lines | 7958 code | 806 blank | 380 comment | 1103 complexity | 3223cfc3085b0c66253d8eceeb9a6be2 MD5 | raw file
Possible License(s): GPL-3.0, MPL-2.0-no-copyleft-exception
Large files files are truncated, but you can click here to view the full file
- /*
- * xboard.c -- X front end for XBoard
- *
- * Copyright 1991 by Digital Equipment Corporation, Maynard,
- * Massachusetts.
- *
- * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
- * 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
- *
- * The following terms apply to Digital Equipment Corporation's copyright
- * interest in XBoard:
- * ------------------------------------------------------------------------
- * All Rights Reserved
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Digital not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * ------------------------------------------------------------------------
- *
- * The following terms apply to the enhanced version of XBoard
- * distributed by the Free Software Foundation:
- * ------------------------------------------------------------------------
- *
- * GNU XBoard is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or (at
- * your option) any later version.
- *
- * GNU XBoard is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/. *
- *
- *------------------------------------------------------------------------
- ** See the file ChangeLog for a revision history. */
- #define HIGHDRAG 1
- #include "config.h"
- #include <stdio.h>
- #include <ctype.h>
- #include <signal.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <pwd.h>
- #include <math.h>
- #if !OMIT_SOCKETS
- # if HAVE_SYS_SOCKET_H
- # include <sys/socket.h>
- # include <netinet/in.h>
- # include <netdb.h>
- # else /* not HAVE_SYS_SOCKET_H */
- # if HAVE_LAN_SOCKET_H
- # include <lan/socket.h>
- # include <lan/in.h>
- # include <lan/netdb.h>
- # else /* not HAVE_LAN_SOCKET_H */
- # define OMIT_SOCKETS 1
- # endif /* not HAVE_LAN_SOCKET_H */
- # endif /* not HAVE_SYS_SOCKET_H */
- #endif /* !OMIT_SOCKETS */
- #if STDC_HEADERS
- # include <stdlib.h>
- # include <string.h>
- #else /* not STDC_HEADERS */
- extern char *getenv();
- # if HAVE_STRING_H
- # include <string.h>
- # else /* not HAVE_STRING_H */
- # include <strings.h>
- # endif /* not HAVE_STRING_H */
- #endif /* not STDC_HEADERS */
- #if HAVE_SYS_FCNTL_H
- # include <sys/fcntl.h>
- #else /* not HAVE_SYS_FCNTL_H */
- # if HAVE_FCNTL_H
- # include <fcntl.h>
- # endif /* HAVE_FCNTL_H */
- #endif /* not HAVE_SYS_FCNTL_H */
- #if HAVE_SYS_SYSTEMINFO_H
- # include <sys/systeminfo.h>
- #endif /* HAVE_SYS_SYSTEMINFO_H */
- #if TIME_WITH_SYS_TIME
- # include <sys/time.h>
- # include <time.h>
- #else
- # if HAVE_SYS_TIME_H
- # include <sys/time.h>
- # else
- # include <time.h>
- # endif
- #endif
- #if HAVE_UNISTD_H
- # include <unistd.h>
- #endif
- #if HAVE_SYS_WAIT_H
- # include <sys/wait.h>
- #endif
- #if HAVE_DIRENT_H
- # include <dirent.h>
- # define NAMLEN(dirent) strlen((dirent)->d_name)
- # define HAVE_DIR_STRUCT
- #else
- # define dirent direct
- # define NAMLEN(dirent) (dirent)->d_namlen
- # if HAVE_SYS_NDIR_H
- # include <sys/ndir.h>
- # define HAVE_DIR_STRUCT
- # endif
- # if HAVE_SYS_DIR_H
- # include <sys/dir.h>
- # define HAVE_DIR_STRUCT
- # endif
- # if HAVE_NDIR_H
- # include <ndir.h>
- # define HAVE_DIR_STRUCT
- # endif
- #endif
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <X11/Shell.h>
- #include <X11/cursorfont.h>
- #include <X11/Xatom.h>
- #include <X11/Xmu/Atoms.h>
- #if USE_XAW3D
- #include <X11/Xaw3d/Dialog.h>
- #include <X11/Xaw3d/Form.h>
- #include <X11/Xaw3d/List.h>
- #include <X11/Xaw3d/Label.h>
- #include <X11/Xaw3d/SimpleMenu.h>
- #include <X11/Xaw3d/SmeBSB.h>
- #include <X11/Xaw3d/SmeLine.h>
- #include <X11/Xaw3d/Box.h>
- #include <X11/Xaw3d/MenuButton.h>
- #include <X11/Xaw3d/Text.h>
- #include <X11/Xaw3d/AsciiText.h>
- #else
- #include <X11/Xaw/Dialog.h>
- #include <X11/Xaw/Form.h>
- #include <X11/Xaw/List.h>
- #include <X11/Xaw/Label.h>
- #include <X11/Xaw/SimpleMenu.h>
- #include <X11/Xaw/SmeBSB.h>
- #include <X11/Xaw/SmeLine.h>
- #include <X11/Xaw/Box.h>
- #include <X11/Xaw/MenuButton.h>
- #include <X11/Xaw/Text.h>
- #include <X11/Xaw/AsciiText.h>
- #endif
- // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
- #include "common.h"
- #if HAVE_LIBXPM
- #include <X11/xpm.h>
- #include "pixmaps/pixmaps.h"
- #define IMAGE_EXT "xpm"
- #else
- #define IMAGE_EXT "xim"
- #include "bitmaps/bitmaps.h"
- #endif
- #include "bitmaps/icon_white.bm"
- #include "bitmaps/icon_black.bm"
- #include "bitmaps/checkmark.bm"
- #include "frontend.h"
- #include "backend.h"
- #include "backendz.h"
- #include "moves.h"
- #include "xboard.h"
- #include "childio.h"
- #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 EvalGraphProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- #ifdef __EMX__
- #ifndef HAVE_USLEEP
- #define HAVE_USLEEP
- #endif
- #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;
- String ref;
- XtActionProc proc;
- } MenuItem;
- typedef struct {
- String name;
- String ref;
- MenuItem *mi;
- } Menu;
- int main P((int argc, char **argv));
- FILE * XsraSelFile P((Widget w, char *prompt, char *ok, char *cancel, char *failed,
- char *init_path, char *filter, char *mode, int (*show_entry)(), char **name_return));
- RETSIGTYPE CmailSigHandler P((int sig));
- RETSIGTYPE IntSigHandler P((int sig));
- RETSIGTYPE TermSizeSigHandler P((int sig));
- void CreateGCs P((int redo));
- void CreateAnyPieces P((void));
- void CreateXIMPieces P((void));
- void CreateXPMPieces P((void));
- void CreateXPMBoard P((char *s, int n));
- void CreatePieces P((void));
- void CreatePieceMenus P((void));
- Widget CreateMenuBar P((Menu *mb));
- Widget CreateButtonBar P ((MenuItem *mi));
- char *FindFont P((char *pattern, int targetPxlSize));
- void PieceMenuPopup P((Widget w, XEvent *event,
- String *params, Cardinal *num_params));
- static void PieceMenuSelect P((Widget w, ChessSquare piece, caddr_t junk));
- static void DropMenuSelect P((Widget w, ChessSquare piece, caddr_t junk));
- void ReadBitmap P((Pixmap *pm, String name, unsigned char bits[],
- u_int wreq, u_int hreq));
- void CreateGrid P((void));
- int EventToSquare P((int x, int limit));
- void DrawSquare P((int row, int column, ChessSquare piece, int do_flash));
- void EventProc P((Widget widget, caddr_t unused, XEvent *event));
- void HandleUserMove P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AnimateUserMove P((Widget w, XEvent * event,
- String * params, Cardinal * nParams));
- void HandlePV P((Widget w, XEvent * event,
- String * params, Cardinal * nParams));
- void SelectPV P((Widget w, XEvent * event,
- String * params, Cardinal * nParams));
- void StopPV P((Widget w, XEvent * event,
- String * params, Cardinal * nParams));
- void WhiteClock P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void BlackClock P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void DrawPositionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void XDrawPosition P((Widget w, /*Boolean*/int repaint,
- Board board));
- void CommentClick P((Widget w, XEvent * event,
- String * params, Cardinal * nParams));
- void CommentPopUp P((char *title, char *label));
- void CommentPopDown P((void));
- void CommentCallback P((Widget w, XtPointer client_data,
- XtPointer call_data));
- void ICSInputBoxPopUp P((void));
- void ICSInputBoxPopDown P((void));
- void FileNamePopUp P((char *label, char *def, char *filter,
- FileProc proc, char *openMode));
- void FileNamePopDown P((void));
- void FileNameCallback P((Widget w, XtPointer client_data,
- XtPointer call_data));
- void FileNameAction P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AskQuestionReplyAction P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AskQuestionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AskQuestionPopDown P((void));
- void PromotionPopDown P((void));
- void PromotionCallback P((Widget w, XtPointer client_data,
- XtPointer call_data));
- void EditCommentPopDown P((void));
- void EditCommentCallback P((Widget w, XtPointer client_data,
- XtPointer call_data));
- void SelectCommand P((Widget w, XtPointer client_data, XtPointer call_data));
- void ResetProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void LoadGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void LoadNextGameProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void LoadPrevGameProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void ReloadGameProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void LoadPositionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void LoadNextPositionProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void LoadPrevPositionProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void ReloadPositionProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void CopyPositionProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void PastePositionProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void CopyGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void PasteGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void SaveGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void SavePositionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void MailMoveProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void ReloadCmailMsgProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void QuitProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void PauseProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void MachineBlackProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void MachineWhiteProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AnalyzeModeProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AnalyzeFileProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void TwoMachinesProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void MatchProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void MatchOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void IcsClientProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void EditGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void EditPositionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void TrainingProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void EditCommentProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void IcsInputBoxProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
- void AcceptProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void DeclineProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void RematchProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void CallFlagProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void DrawProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AbortProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AdjournProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void ResignProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AdjuWhiteProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AdjuBlackProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AdjuDrawProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void EnterKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void UpKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void DownKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void StopObservingProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void StopExaminingProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- 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 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 AnnotateProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void TruncateGameProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void RetractMoveProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void MoveNowProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AlwaysQueenProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void AnimateDraggingProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void AnimateMovingProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void AutoflagProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AutoflipProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void BlindfoldProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void FlashMovesProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void FlipViewProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void HighlightDraggingProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void HighlightLastMoveProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void HighlightArrowProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void MoveSoundProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- //void IcsAlarmProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void OneClickProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void PeriodicUpdatesProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void PonderNextMoveProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void PopupMoveErrorsProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- void PopupExitMessageProc P((Widget w, XEvent *event, String *prms,
- Cardinal *nprms));
- //void PremoveProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- 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 SaveSettingsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void SaveOnExitProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void InfoProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void ManProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void HintProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void BookProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void AboutGameProc 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));
- int LoadGamePopUp P((FILE *f, int gameNumber, char *title));
- void ErrorPopUp P((char *title, char *text, int modal));
- void ErrorPopDown P((void));
- static char *ExpandPathName P((char *path));
- static void CreateAnimVars P((void));
- static void DragPieceMove P((int x, int y));
- static void DrawDragPiece P((void));
- char *ModeToWidgetName P((GameMode mode));
- 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 OptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void NewVariantProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void IcsTextProc 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 GameListOptionsPopUp P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void IcsOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- void SoundOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
- 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 GameListOptionsPopDown P(());
- void ShufflePopDown P(());
- void TimeControlPopDown P(());
- void GenericPopDown P(());
- void update_ics_width P(());
- int get_term_width P(());
- int CopyMemoProc P(());
- void DrawArrowHighlight P((int fromX, int fromY, int toX,int toY));
- Boolean IsDrawArrowEnabled P(());
- /*
- * XBoard depends on Xt R4 or higher
- */
- int xtVersion = XtSpecificationRelease;
- int xScreen;
- Display *xDisplay;
- Window xBoardWindow;
- Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor,
- jailSquareColor, highlightSquareColor, premoveHighlightColor;
- Pixel lowTimeWarningColor;
- GC lightSquareGC, darkSquareGC, jailSquareGC, lineGC, wdPieceGC, wlPieceGC,
- bdPieceGC, blPieceGC, wbPieceGC, bwPieceGC, coordGC, highlineGC,
- wjPieceGC, bjPieceGC, prelineGC, countGC;
- Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap;
- Widget shellWidget, layoutWidget, formWidget, boardWidget, messageWidget,
- whiteTimerWidget, blackTimerWidget, titleWidget, widgetList[16],
- commentShell, promotionShell, whitePieceMenu, blackPieceMenu, dropMenu,
- menuBarWidget, buttonBarWidget, editShell, errorShell, analysisShell,
- ICSInputShell, fileNameShell, askQuestionShell;
- Widget historyShell, evalGraphShell, gameListShell;
- int hOffset; // [HGM] dual
- 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;
- 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;
- typedef unsigned int BoardSize;
- BoardSize boardSize;
- Boolean chessProgram;
- int minX, minY; // [HGM] placement: volatile limits on upper-left corner
- 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,
- editUp = False, errorUp = False, errorExitStatus = -1, lineGap, defaultLineGap;
- Pixel timerForegroundPixel, timerBackgroundPixel;
- Pixel buttonForegroundPixel, buttonBackgroundPixel;
- char *chessDir, *programName, *programVersion,
- *gameCopyFilename, *gamePasteFilename;
- Boolean alwaysOnTop = False;
- Boolean saveSettingsOnExit;
- char *settingsFileName;
- char *icsTextMenuString;
- char *icsNames;
- char *firstChessProgramNames;
- char *secondChessProgramNames;
- WindowPlacement wpMain;
- WindowPlacement wpConsole;
- WindowPlacement wpComment;
- WindowPlacement wpMoveHistory;
- WindowPlacement wpEvalGraph;
- WindowPlacement wpEngineOutput;
- WindowPlacement wpGameList;
- WindowPlacement wpTags;
- #define SOLID 0
- #define OUTLINE 1
- Pixmap pieceBitmap[2][(int)BlackPawn];
- Pixmap pieceBitmap2[2][(int)BlackPawn+4]; /* [HGM] pieces */
- Pixmap xpmPieceBitmap[4][(int)BlackPawn]; /* LL, LD, DL, DD actually used*/
- Pixmap xpmPieceBitmap2[4][(int)BlackPawn+4]; /* LL, LD, DL, DD set to select from */
- Pixmap xpmLightSquare, xpmDarkSquare, xpmJailSquare;
- Pixmap xpmBoardBitmap[2];
- int useImages, useImageSqs, useTexture, textureW[2], textureH[2];
- XImage *ximPieceBitmap[4][(int)BlackPawn+4]; /* LL, LD, DL, DD */
- Pixmap ximMaskPm[(int)BlackPawn]; /* clipmasks, used for XIM pieces */
- Pixmap ximMaskPm2[(int)BlackPawn+4]; /* clipmasks, used for XIM pieces */
- XImage *ximLightSquare, *ximDarkSquare;
- XImage *xim_Cross;
- #define pieceToSolid(piece) &pieceBitmap[SOLID][(piece) % (int)BlackPawn]
- #define pieceToOutline(piece) &pieceBitmap[OUTLINE][(piece) % (int)BlackPawn]
- #define White(piece) ((int)(piece) < (int)BlackPawn)
- /* Variables for doing smooth animation. This whole thing
- would be much easier if the board was double-buffered,
- but that would require a fairly major rewrite. */
- typedef struct {
- Pixmap saveBuf;
- Pixmap newBuf;
- GC blitGC, pieceGC, outlineGC;
- XPoint startSquare, prevFrame, mouseDelta;
- int startColor;
- int dragPiece;
- Boolean dragActive;
- int startBoardX, startBoardY;
- } AnimState;
- /* There can be two pieces being animated at once: a player
- can begin dragging a piece before the remote opponent has moved. */
- static AnimState game, player;
- /* Bitmaps for use as masks when drawing XPM pieces.
- Need one for each black and white piece. */
- static Pixmap xpmMask[BlackKing + 1];
- /* This magic number is the number of intermediate frames used
- in each half of the animation. For short moves it's reduced
- by 1. The total number of frames will be factor * 2 + 1. */
- #define kFactor 4
- SizeDefaults sizeDefaults[] = SIZE_DEFAULTS;
- MenuItem fileMenu[] = {
- {N_("New Game Ctrl+N"), "New Game", ResetProc},
- {N_("New Shuffle Game ..."), "New Shuffle Game", ShuffleMenuProc},
- {N_("New Variant ... Alt+Shift+V"), "New Variant", NewVariantProc}, // [HGM] variant: not functional yet
- {"----", NULL, NothingProc},
- {N_("Load Game Ctrl+O"), "Load Game", LoadGameProc},
- {N_("Load Position Ctrl+Shift+O"), "Load Position", LoadPositionProc},
- // {N_("Load Next Game"), "Load Next Game", LoadNextGameProc},
- // {N_("Load Previous Game"), "Load Previous Game", LoadPrevGameProc},
- // {N_("Reload Same Game"), "Reload Same Game", ReloadGameProc},
- {N_("Next Position Shift+PgDn"), "Load Next Position", LoadNextPositionProc},
- {N_("Prev Position Shift+PgUp"), "Load Previous Position", LoadPrevPositionProc},
- {"----", NULL, NothingProc},
- // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
- {N_("Save Game Ctrl+S"), "Save Game", SaveGameProc},
- {N_("Save Position Ctrl+Shift+S"), "Save Position", SavePositionProc},
- {"----", NULL, NothingProc},
- {N_("Mail Move"), "Mail Move", MailMoveProc},
- {N_("Reload CMail Message"), "Reload CMail Message", ReloadCmailMsgProc},
- {"----", NULL, NothingProc},
- {N_("Quit Ctr+Q"), "Exit", QuitProc},
- {NULL, NULL, NULL}
- };
- MenuItem editMenu[] = {
- {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc},
- {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc},
- {"----", NULL, NothingProc},
- {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc},
- {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc},
- {"----", NULL, NothingProc},
- {N_("Edit Game Ctrl+E"), "Edit Game", EditGameProc},
- {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionProc},
- {N_("Edit Tags"), "Edit Tags", EditTagsProc},
- {N_("Edit Comment"), "Edit Comment", EditCommentProc},
- {"----", NULL, NothingProc},
- {N_("Revert Home"), "Revert", RevertProc},
- {N_("Annotate"), "Annotate", AnnotateProc},
- {N_("Truncate Game End"), "Truncate Game", TruncateGameProc},
- {"----", NULL, NothingProc},
- {N_("Backward Alt+Left"), "Backward", BackwardProc},
- {N_("Forward Alt+Right"), "Forward", ForwardProc},
- {N_("Back to Start Alt+Home"), "Back to Start", ToStartProc},
- {N_("Forward to End Alt+End"), "Forward to End", ToEndProc},
- {NULL, NULL, NULL}
- };
- MenuItem viewMenu[] = {
- {N_("Flip View F2"), "Flip View", FlipViewProc},
- {"----", NULL, NothingProc},
- {N_("Engine Output Alt+Shift+O"), "Show Engine Output", EngineOutputProc},
- {N_("Move History Alt+Shift+H"), "Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code
- {N_("Evaluation Graph Alt+Shift+E"), "Show Evaluation Graph", EvalGraphProc},
- {N_("Game List Alt+Shift+G"), "Show Game List", ShowGameListProc},
- {N_("ICS text menu"), "ICStex", IcsTextProc},
- {"----", NULL, NothingProc},
- {N_("Tags"), "Show Tags", EditTagsProc},
- {N_("Comments"), "Show Comments", EditCommentProc},
- {N_("ICS Input Box"), "ICS Input Box", IcsInputBoxProc},
- {"----", NULL, NothingProc},
- {N_("Board..."), "Board Options", BoardOptionsProc},
- {N_("Game List Tags..."), "Game List", GameListOptionsPopUp},
- {NULL, NULL, NULL}
- };
- MenuItem modeMenu[] = {
- {N_("Machine White Ctrl+W"), "Machine White", MachineWhiteProc},
- {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_("Edit Game Ctrl+E"), "Edit Game", EditGameProc},
- {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionProc},
- {N_("Training"), "Training", TrainingProc},
- {N_("ICS Client"), "ICS Client", IcsClientProc},
- {"----", NULL, NothingProc},
- {N_("Machine Match"), "Machine Match", MatchProc},
- {N_("Pause Pause"), "Pause", PauseProc},
- {NULL, NULL, NULL}
- };
- MenuItem actionMenu[] = {
- {N_("Accept F3"), "Accept", AcceptProc},
- {N_("Decline F4"), "Decline", DeclineProc},
- {N_("Rematch F12"), "Rematch", RematchProc},
- {"----", NULL, NothingProc},
- {N_("Call Flag F5"), "Call Flag", CallFlagProc},
- {N_("Draw F6"), "Draw", DrawProc},
- {N_("Adjourn F7"), "Adjourn", AdjournProc},
- {N_("Abort F8"),"Abort", AbortProc},
- {N_("Resign F9"), "Resign", ResignProc},
- {"----", NULL, NothingProc},
- {N_("Stop Observing F10"), "Stop Observing", StopObservingProc},
- {N_("Stop Examining F11"), "Stop Examining", StopExaminingProc},
- {N_("Upload to Examine"), "Upload to Examine", UploadProc},
- {"----", NULL, NothingProc},
- {N_("Adjudicate to White"), "Adjudicate to White", AdjuWhiteProc},
- {N_("Adjudicate to Black"), "Adjudicate to Black", AdjuBlackProc},
- {N_("Adjudicate Draw"), "Adjudicate Draw", AdjuDrawProc},
- {NULL, NULL, NULL}
- };
- MenuItem engineMenu[] = {
- {N_("Engine #1 Settings ..."), "Engine #1 Settings", FirstSettingsProc},
- {N_("Engine #2 Settings ..."), "Engine #2 Settings", SecondSettingsProc},
- {"----", NULL, NothingProc},
- {N_("Hint"), "Hint", HintProc},
- {N_("Book"), "Book", BookProc},
- {"----", NULL, NothingProc},
- {N_("Move Now Ctrl+M"), "Move Now", MoveNowProc},
- {N_("Retract Move Ctrl+X"), "Retract Move", RetractMoveProc},
- {NULL, NULL, NULL}
- };
- MenuItem optionsMenu[] = {
- #define OPTIONSDIALOG
- #ifdef OPTIONSDIALOG
- {N_("General ..."), "General", OptionsProc},
- #endif
- {N_("Time Control ... Alt+Shift+T"), "Time Control", TimeControlProc},
- {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc},
- {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
- {N_("ICS ..."), "ICS", IcsOptionsProc},
- {N_("Match ..."), "Match", MatchOptionsProc},
- {N_("Load Game ..."), "Load Game", LoadOptionsProc},
- {N_("Save Game ..."), "Save Game", SaveOptionsProc},
- // {N_(" ..."), "", OptionsProc},
- {N_("Game List ..."), "Game List", GameListOptionsPopUp},
- {N_("Sounds ..."), "Sounds", SoundOptionsProc},
- {"----", NULL, NothingProc},
- #ifndef OPTIONSDIALOG
- {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc},
- {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc},
- {N_("Animate Moving Ctrl+Shift+A"), "Animate Moving", AnimateMovingProc},
- {N_("Auto Flag Ctrl+Shift+F"), "Auto Flag", AutoflagProc},
- {N_("Auto Flip View"), "Auto Flip View", AutoflipProc},
- {N_("Blindfold"), "Blindfold", BlindfoldProc},
- {N_("Flash Moves"), "Flash Moves", FlashMovesProc},
- #if HIGHDRAG
- {N_("Highlight Dragging"), "Highlight Dragging", HighlightDraggingProc},
- #endif
- {N_("Highlight Last Move"), "Highlight Last Move", HighlightLastMoveProc},
- {N_("Highlight With Arrow"), "Arrow", HighlightArrowProc},
- {N_("Move Sound"), "Move Sound", MoveSoundProc},
- // {N_("ICS Alarm"), "ICS Alarm", IcsAlarmProc},
- {N_("One-Click Moving"), "OneClick", OneClickProc},
- {N_("Periodic Updates"), "Periodic Updates", PeriodicUpdatesProc},
- {N_("Ponder Next Move Ctrl+Shift+P"), "Ponder Next Move", PonderNextMoveProc},
- {N_("Popup Exit Message"), "Popup Exit Message", PopupExitMessageProc},
- {N_("Popup Move Errors"), "Popup Move Errors", PopupMoveErrorsProc},
- // {N_("Premove"), "Premove", PremoveProc},
- {N_("Show Coords"), "Show Coords", ShowCoordsProc},
- {N_("Hide Thinking Ctrl+Shift+H"), "Hide Thinking", HideThinkingProc},
- {N_("Test Legality Ctrl+Shift+L"), "Test Legality", TestLegalityProc},
- {"----", NULL, NothingProc},
- #endif
- {N_("Save Settings Now"), "Save Settings Now", SaveSettingsProc},
- {N_("Save Settings on Exit"), "Save Settings on Exit", SaveOnExitProc},
- {NULL, NULL, NULL}
- };
- MenuItem helpMenu[] = {
- {N_("Info XBoard"), "Info XBoard", InfoProc},
- {N_("Man XBoard F1"), "Man XBoard", ManProc},
- {"----", NULL, NothingProc},
- {N_("About XBoard"), "About XBoard", AboutProc},
- {NULL, NULL, NULL}
- };
- Menu menuBar[] = {
- {N_("File"), "File", fileMenu},
- {N_("Edit"), "Edit", editMenu},
- {N_("View"), "View", viewMenu},
- {N_("Mode"), "Mode", modeMenu},
- {N_("Action"), "Action", actionMenu},
- {N_("Engine"), "Engine", engineMenu},
- {N_("Options"), "Options", optionsMenu},
- {N_("Help"), "Help", helpMenu},
- {NULL, NULL, NULL}
- };
- #define PAUSE_BUTTON "P"
- MenuItem buttonBar[] = {
- {"<<", "<<", ToStartProc},
- {"<", "<", BackwardProc},
- {PAUSE_BUTTON, PAUSE_BUTTON, PauseProc},
- {">", ">", ForwardProc},
- {">>", ">>", ToEndProc},
- {NULL, NULL, NULL}
- };
- #define PIECE_MENU_SIZE 18
- String pieceMenuStrings[2][PIECE_MENU_SIZE] = {
- { N_("White"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"),
- N_("Queen"), N_("King"), "----", N_("Elephant"), N_("Cannon"),
- N_("Archbishop"), N_("Chancellor"), "----", N_("Promote"), N_("Demote"),
- N_("Empty square"), N_("Clear board") },
- { N_("Black"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"),
- N_("Queen"), N_("King"), "----", N_("Elephant"), N_("Cannon"),
- N_("Archbishop"), N_("Chancellor"), "----", N_("Promote"), N_("Demote"),
- 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,
- WhiteRook, WhiteQueen, WhiteKing, (ChessSquare) 0, WhiteAlfil,
- WhiteCannon, WhiteAngel, WhiteMarshall, (ChessSquare) 0,
- PromotePiece, DemotePiece, EmptySquare, ClearBoard },
- { BlackPlay, (ChessSquare) 0, BlackPawn, BlackKnight, BlackBishop,
- BlackRook, BlackQueen, BlackKing, (ChessSquare) 0, BlackAlfil,
- BlackCannon, BlackAngel, BlackMarshall, (ChessSquare) 0,
- PromotePiece, DemotePiece, EmptySquare, ClearBoard },
- };
- #define DROP_MENU_SIZE 6
- String dropMenuStrings[DROP_MENU_SIZE] = {
- "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), N_("Queen")
- };
- /* must be in same order as PieceMenuStrings! */
- ChessSquare dropMenuTranslation[DROP_MENU_SIZE] = {
- (ChessSquare) 0, WhitePawn, WhiteKnight, WhiteBishop,
- WhiteRook, WhiteQueen
- };
- typedef struct {
- char piece;
- char* widget;
- } DropMenuEnables;
- DropMenuEnables dmEnables[] = {
- { 'P', "Pawn" },
- { 'N', "Knight" },
- { 'B', "Bishop" },
- { 'R', "Rook" },
- { 'Q', "Queen" }
- };
- Arg shellArgs[] = {
- { XtNwidth, 0 },
- { XtNheight, 0 },
- { XtNminWidth, 0 },
- { XtNminHeight, 0 },
- { XtNmaxWidth, 0 },
- { XtNmaxHeight, 0 }
- };
- Arg layoutArgs[] = {
- { XtNborderWidth, 0 },
- { XtNdefaultDistance, 0 },
- };
- Arg formArgs[] = {
- { XtNborderWidth, 0 },
- { XtNresizable, (XtArgVal) True },
- };
- Arg boardArgs[] = {
- { XtNborderWidth, 0 },
- { XtNwidth, 0 },
- { XtNheight, 0 }
- };
- Arg titleArgs[] = {
- { XtNjustify, (XtArgVal) XtJustifyRight },
- { XtNlabel, (XtArgVal) "..." },
- { XtNresizable, (XtArgVal) True },
- { XtNresize, (XtArgVal) False }
- };
- Arg messageArgs[] = {
- { XtNjustify, (XtArgVal) XtJustifyLeft },
- { XtNlabel, (XtArgVal) "..." },
- { XtNresizable, (XtArgVal) True },
- { XtNresize, (XtArgVal) False }
- };
- Arg timerArgs[] = {
- { XtNborderWidth, 0 },
- { XtNjustify, (XtArgVal) XtJustifyLeft }
- };
- XtResource clientResources[] = {
- { "flashCount", "flashCount", XtRInt, sizeof(int),
- XtOffset(AppDataPtr, flashCount), XtRImmediate,
- (XtPointer) FLASH_COUNT },
- };
- XrmOptionDescRec shellOptions[] = {
- { "-flashCount", "flashCount", XrmoptionSepArg, NULL },
- { "-flash", "flashCount", XrmoptionNoArg, "3" },
- { "-xflash", "flashCount", XrmoptionNoArg, "0" },
- };
- XtActionsRec boardActions[] = {
- { "DrawPosition", DrawPositionProc },
- { "HandleUserMove", HandleUserMove },
- { "AnimateUserMove", AnimateUserMove },
- { "HandlePV", HandlePV },
- { "SelectPV", SelectPV },
- { "StopPV", StopPV },
- { "FileNameAction", FileNameAction },
- { "AskQuestionProc", AskQuestionProc },
- { "AskQuestionReplyAction", AskQuestionReplyAction },
- { "PieceMenuPopup", PieceMenuPopup },
- { "WhiteClock", WhiteClock },
- { "BlackClock", BlackClock },
- { "Iconify", Iconify },
- { "ResetProc", ResetProc },
- { "NewVariantProc", NewVariantProc },
- { "LoadGameProc", LoadGameProc },
- { "LoadNextGameProc", LoadNextGameProc },
- { "LoadPrevGameProc", LoadPrevGameProc },
- { "LoadSelectedProc", LoadSelectedProc },
- { "SetFilterProc", SetFilterProc },
- { "ReloadGameProc", ReloadGameProc },
- { "LoadPositionProc", LoadPositionProc },
- { "LoadNextPositionProc", LoadNextPositionProc },
- { "LoadPrevPositionProc", LoadPrevPositionProc },
- { "ReloadPositionProc", ReloadPositionProc },
- { "CopyPositionProc", CopyPositionProc },
- { "PastePositionProc", PastePositionProc },
- { "CopyGameProc", CopyGameProc },
- { "PasteGameProc", PasteGameProc },
- { "SaveGameProc", SaveGameProc },
- { "SavePositionProc", SavePositionProc },
- { "MailMoveProc", MailMoveProc },
- { "ReloadCmailMsgProc", ReloadCmailMsgProc },
- { "QuitProc", QuitProc },
- { "MachineWhiteProc", MachineWhiteProc },
- { "MachineBlackProc", MachineBlackProc },
- { "AnalysisModeProc", AnalyzeModeProc },
- { "AnalyzeFileProc", AnalyzeFileProc },
- { "TwoMachinesProc", TwoMachinesProc },
- { "IcsClientProc", IcsClientProc },
- { "EditGameProc", EditGameProc },
- { "EditPositionProc", EditPositionProc },
- { "TrainingProc", EditPositionProc },
- { "EngineOutputProc", EngineOutputProc}, // [HGM] Winboard_x engine-output window
- { "EvalGraphProc", EvalGraphProc}, // [HGM] Winboard_x avaluation graph window
- { "ShowGameListProc", ShowGameListProc },
- { "ShowMoveListProc", HistoryShowProc},
- { "EditTagsProc", EditCommentProc },
- { "EditCommentProc", EditCommentProc },
- { "IcsInputBoxProc", IcsInputBoxProc },
- { "PauseProc", PauseProc },
- { "AcceptProc", AcceptProc },
- { "DeclineProc", DeclineProc },
- { "RematchProc", RematchProc },
- { "CallFlagProc", CallFlagProc },
- { "DrawProc", DrawProc },
- { "AdjournProc", AdjournProc },
- { "AbortProc", AbortProc },
- { "ResignProc", ResignProc },
- { "AdjuWhiteProc", AdjuWhiteProc },
- { "AdjuBlackProc", AdjuBlackProc },
- { "AdjuDrawProc", AdjuDrawProc },
- { "EnterKeyProc", EnterKeyProc },
- { "UpKeyProc", UpKeyProc },
- { "DownKeyProc", DownKeyProc },
- { "StopObservingProc", StopObservingProc },
- { "StopExaminingProc", StopExaminingProc },
- { "UploadProc", UploadProc },
- { "BackwardProc", BackwardProc },
- { "ForwardProc", ForwardProc },
- { "ToStartProc", ToStartProc },
- { "ToEndProc", ToEndProc },
- { "RevertProc", RevertProc },
- { "AnnotateProc", AnnotateProc },
- { "TruncateGameProc", TruncateGameProc },
- { "MoveNowProc", MoveNowProc },
- { "RetractMoveProc", RetractMoveProc },
- { "EngineMenuProc", (XtActionProc) EngineMenuProc },
- { "UciMenuProc", (XtActionProc) UciMenuProc },
- { "TimeControlProc", (XtActionProc) TimeControlProc },
- { "FlipViewProc", FlipViewProc },
- { "PonderNextMoveProc", PonderNextMoveProc },
- #ifndef OPTIONSDIALOG
- { "AlwaysQueenProc", AlwaysQueenProc },
- { "AnimateDraggingProc", AnimateDraggingProc },
- { "AnimateMovingProc", AnimateMovingProc },
- { "AutoflagProc", AutoflagProc },
- { "AutoflipProc", AutoflipProc },
- { "BlindfoldProc", BlindfoldProc },
- { "FlashMovesProc", FlashMovesProc },
- #if HIGHDRAG
- { "HighlightDraggingProc", HighlightDraggingProc },
- #endif
- { "HighlightLastMoveProc", HighlightLastMoveProc },
- // { "IcsAlarmProc", IcsAlarmProc },
- { "MoveSoundProc", MoveSoundProc },
- { "PeriodicUpdatesProc", PeriodicUpdatesProc },
- { "PopupExitMessageProc", PopupExitMessageProc },
- { "PopupMoveErrorsProc", PopupMoveErrorsProc },
- // { "PremoveProc", PremoveProc },
- { "ShowCoordsProc", ShowCoordsProc },
- { "ShowThinkingProc", ShowThinkingProc },
- { "HideThinkingProc", HideThinkingProc },
- { "TestLegalityProc", TestLegalityProc },
- #endif
- { "SaveSettingsProc", SaveSettingsProc },
- { "SaveOnExitProc", SaveOnExitProc },
- { "InfoProc", InfoProc },
- { "ManProc", ManProc },
- { "HintProc", HintProc },
- { "BookProc", BookProc },
- { "AboutGameProc", AboutGameProc },
- { "AboutProc", AboutProc },
- { "DebugProc", DebugProc },
- { "NothingProc", NothingProc },
- { "CommentClick", (XtActionProc) CommentClick },
- { "CommentPopDown", (XtActionProc) CommentPopDown },
- { "EditCommentPopDown", (XtActionProc) EditCommentPopDown },
- { "TagsPopDown", (XtActionProc) TagsPopDown },
- { "ErrorPopDown", (XtActionProc) ErrorPopDown },
- { "ICSInputBoxPopDown", (XtActionProc) ICSInputBoxPopDown },
- { "FileNamePopDown", (XtActionProc) FileNamePopDown },
- { "AskQuestionPopDown", (XtActionProc) AskQuestionPopDown },
- { "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 },
- };
- char globalTranslations[] =
- ":<Key>F9: ResignProc() \n \
- :Ctrl<Key>n: ResetProc() \n \
- :Meta<Key>V: NewVariantProc() \n \
- :Ctrl<Key>o: LoadGameProc() \n \
- :Meta<Key>Next: LoadNextGameProc() \n \
- :Meta<Key>Prior: LoadPrevGameProc() \n \
- :Ctrl<Key>s: SaveGameProc() \n \
- :Ctrl<Key>c: CopyGameProc() \n \
- :Ctrl<Key>v: PasteGameProc() \n \
- :Ctrl<Key>O: LoadPositionProc() \n \
- :Shift<Key>Next: LoadNextPositionProc() \n \
- :Shift<Key>Prior: LoadPrevPositionProc() \n \
- :Ctrl<Key>S: SavePositionProc() \n \
- :Ctrl<Key>C: CopyPositionProc() \n \
- :Ctrl<Key>V: PastePositionProc() \n \
- :Ctrl<Key>q: QuitProc() \n \
- :Ctrl<Key>w: MachineWhiteProc() \n \
- :Ctrl<Key>b: MachineBlackProc() \n \
- :Ctrl<Key>t: TwoMachinesProc() \n \
- :Ctrl<Key>a: AnalysisModeProc() \n \
- :Ctrl<Key>f: AnalyzeFileProc() \n \
- :Ctrl<Key>e: EditGameProc() \n \
- :Ctrl<Key>E: EditPositionProc() \n \
- :Meta<Key>O: EngineOutputProc() \n \
- :Meta<Key>E: EvalGraphProc() \n \
- :Meta<Key>G: ShowGameListProc() \n \
- :Meta<Key>H: ShowMoveListProc() \n \
- :<Key>Pause: PauseProc() \n \
- :<Key>F3: AcceptProc() \n \
- :<Key>F4: DeclineProc() \n \
- :<Key>F12: RematchProc() \n \
- :<Key>F5: CallFlagProc() \n \
- :<Key>F6: DrawProc() \n \
- :<Key>F7: AdjournProc() \n \
- :<Key>F8: AbortProc() \n \
- :<Key>F10: StopObservingProc() \n \
- :<Key>F11: StopExaminingProc() \n \
- :Meta Ctrl<Key>F12: DebugProc() \n \
- :Meta<Key>End: ToEndProc() \n \
- :Meta<Key>Right: ForwardProc() \n \
- :Meta<Key>Home: ToStartProc() \n \
- :Meta<Key>Left: BackwardProc() \n \
- :<Key>Home: RevertProc() \n \
- :<Key>End: TruncateGameProc() \n \
- :Ctrl<Key>m: MoveNowProc() \n \
- :Ctrl<Key>x: RetractMoveProc() \n \
- :Meta<Key>J: EngineMenuProc() \n \
- :Meta<Key>U: UciMenuProc() \n \
- :Meta<Key>T: TimeControlProc() \n \
- :Ctrl<Key>P: PonderNextMoveProc() \n "
- #ifndef OPTIONSDIALOG
- "\
- :Ctrl<Key>Q: AlwaysQueenProc() \n \
- :Ctrl<Key>F: AutoflagProc() \n \
- :Ctrl<Key>A: AnimateMovingProc() \n \
- :Ctrl<Key>L: TestLegalityProc() \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\",\
- \"Send to chess program:\",,1) \n \
- Shift<Key>2: AskQuestionProc(\"Direct command\",\
- \"Send to second chess program:\",,2) \n";
- char boardTranslations[] =
- "<Btn1Down>: HandleUserMove(0) \n \
- Shift<Btn1Up>: HandleUserMove(1) \n \
- <Btn1Up>: HandleUserMove(0) \n \
- <Btn1Motion>: AnimateUserMove() \n \
- <Btn3Motion>: HandlePV() \n \
- <Btn3Up>: PieceMenuPopup(menuB) \n \
- Shift<Btn2Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD)\
- PieceMenuPopup(menuB) \n \
- Any<Btn2Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD) \
- PieceMenuPopup(menuW) \n \
- Shift<Btn3Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD)\
- PieceMenuPopup(menuW) \n \
- Any<Btn3Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD) \
- PieceMenuPopup(menuB) \n";
- char whiteTranslations[] = "<BtnDown>: WhiteClock()\n";
- char blackTranslations[] = "<BtnDown>: BlackClock()\n";
- char ICSInputTranslations[] =
- "<Key>Up: UpKeyProc() \n "
- "<Key>Down: DownKeyProc() \n "
- "<Key>Return: EnterKeyProc() \n";
- // [HGM] vari: another hideous kludge: call extend-end first so we can be sure select-start works,
- // as the widget is destroyed before the up-click can call extend-end
- char commentTranslations[] = "<Btn3Down>: extend-end() select-start() CommentClick() \n";
- String xboardResources[] = {
- "*fileName*value.translations: #override\\n <Key>Return: FileNameAction()",
- "*question*value.translations: #override\\n <Key>Return: AskQuestionReplyAction()",
- "*errorpopup*translations: #override\\n <Key>Return: ErrorPopDown()",
- NULL
- };
- /* Max possible square size */
- #define MAXSQSIZE 256
- static int xpm_avail[MAXSQSIZE];
- #ifdef HAVE_DIR_STRUCT
- /* Extract piece size from filename */
- static int
- xpm_getsize(name, len, ext)
- char *name;
- int len;
- char *ext;
- {
- char *p, *d;
- char buf[10];
- if (len < 4)
- return 0;
- if ((p=strchr(name, '.')) == NULL ||
- StrCaseCmp(p+1, ext) != 0)
- return 0;
- p = name + 3;
- d = buf;
- while (*p && isdigit(*p))
- *(d++) = *(p++);
- *d = 0;
- return atoi(buf);
- }
- /* Setup xpm_avail */
- static int
- xpm_getavail(dirname, ext)
- char *dirname;
- char *ext;
- {
- DIR *dir;
- struct dirent *ent;
- int i;
- for (i=0; i<MAXSQSIZE; ++i)
- xpm_avail[i] = 0;
- if (appData.debugMode)
- fprintf(stderr, "XPM dir:%s:ext:%s:\n", dirname, ext);
- dir = opendir(dirname);
- if (!dir)
- {
- fprintf(stderr, _("%s: Can't access XPM directory %s\n"),
- programName, dirname);
- exit(1);
- }
- while ((ent=readdir(dir)) != NULL) {
- i = xpm_getsize(ent->d_name, NAMLEN(ent), ext);
- if (i > 0 && i < MAXSQSIZE)
- xpm_avail[i] = 1;
- }
- closedir(dir);
- return 0;
- }
- void
- xpm_print_avail(fp, ext)
- FILE *fp;
- char *ext;
- {
- int i;
- fprintf(fp, _("Available `%s' sizes:\n"), ext);
- for (i=1; i<MAXSQSIZE; ++i) {
- if (xpm_avail[i])
- printf("%d\n", i);
- }
- }
- /* Return XPM piecesize closest to size */
- int
- xpm_closest_to(dirname, size, ext)
- char *dirname;
- int size;
- char *ext;
- {
- int i;
- int sm_diff = MAXSQSIZE;
- int sm_index = 0;
- int diff;
- xpm_getavail(dirname, ext);
- if (appData.debugMode)
- xpm_print_avail(stderr, ext);
- for (i=1; i<MAXSQSIZE; ++i) {
- if (xpm_avail[i]) {
- diff = size - i;
- diff = (diff<0) ? -diff : diff;
- if (diff < sm_diff) {
- sm_diff = diff;
- sm_index = i;
- }
- }
- }
- if (!sm_index) {
- fprintf(stderr, _("Error: No `%s' files!\n"), ext);
- exit(1);
- }
- return sm_index;
- }
- #else /* !HAVE_DIR_STRUCT */
- /* If we are on a system without a DIR struct, we can't
- read the directory, so we can't collect a list of
- filenames, etc., so we can't do any size-fitting. */
- int
- xpm_closest_to(dirname, size, ext)
- char *dirname;
- int size;
- char *ext;
- {
- fprintf(stderr, _("\
- Warning: No DIR structure found on this system --\n\
- Unable to autosize for XPM/XIM pieces.\n\
- Please report this error to frankm@hiwaay.net.\n\
- Include system type & operating system in message.\n"));
- return size;
- }
- #endif /* HAVE_DIR_STRUCT */
- static char *cnames[9] = { "black", "red", "green", "yellow", "blue",
- "magenta", "cyan", "white" };
- typedef struct {
- int attr, bg, fg;
- } TextColors;
- TextColors textColors[(int)NColorClasses];
- /* String is: "fg, bg, attr". Which is 0, 1, 2 */
- static int
- parse_color(str, which)
- char *str;
- int which;
- {
- char *p, buf[100], *d;
- int i;
- if (strlen(str) > 99) /* watch bounds on buf */
- return -1;
- p = str;
- d = buf;
- for (i=0; i<which; ++i) {
- p = strchr(p, ',');
- if (!p)
- return -1;
- ++p;
- }
- /* Could be looking at something like:
- black, , 1
- .. in which case we want to stop on a comma also */
- while (*p && *p != ',' && !isalpha(*p) && !isdigit(*p))
- ++p;
- if (*p == ',') {
- return -1; /* Use default for empty field */
- }
- if (which == 2 || isdigit(*p))
- return atoi(p);
- while (*p && isalpha(*p))
- *(d++) = *(p++);
- *d = 0;
- for (i=0; i<8; ++i) {
- if (!StrCaseCmp(buf, cnames[i]))
- return which? (i+40) : (i+30);
- }
- if (!StrCaseCmp(buf, "default")) return -1;
- fprintf(stderr, _("%s: unrecognized color %s\n"), programName, buf);
- return -2;
- }
- static int
- parse_cpair(cc, str)
- ColorClass cc;
- char *str;
- {
- if ((textColors[(int)cc].fg=parse_color(str, 0)) == -2) {
- fprintf(stderr, _("%s: can't parse foreground color in `%s'\n"),
- programName, str);
- return -1;
- }
- /* bg and attr are optional */
- textColors[(int)cc].b…
Large files files are truncated, but you can click here to view the full file