#! /bin/sh
# This file is part of GNU XBoard.
-#
+#
# Copyright 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
-#
+#
# 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.
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# See the file ChangeLog for a revision history.
aclocal -I m4 \
&& autoheader \
extern char *engineName, *engineDir, *engineChoice, *engineLine, *nickName, *params;
extern Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick;
-static char resetOptions[] =
+static char resetOptions[] =
"-reuse -firstIsUCI false -firstHasOwnBookUCI true -firstTimeOdds 1 "
"-firstInitString \"" INIT_STRING "\" -firstComputerString \"" COMPUTER_STRING "\" "
"-firstFeatures \"\" -firstLogo \"\" -firstAccumulateTC 1 "
if(nickName[0]) snprintf(buf, MSG_SIZ, "\"%s\" -fcp ", nickName); else buf[0] = NULLCHAR;
quote = strchr(p, '"') ? '\'' : '"'; // use single quotes around engine command if it contains double quotes
snprintf(buf+strlen(buf), MSG_SIZ-strlen(buf), "%c%s%c -fd \"%s\"%s%s%s%s%s%s%s%s\n",
- quote, p, quote, appData.directory[i],
+ quote, p, quote, appData.directory[i],
useNick ? " -fn \"" : "",
useNick ? nickName : "",
useNick ? "\"" : "",
if(mps)
snprintf(buf, MSG_SIZ, ":%d/%s+%g", mps, mytc, ti);
- else
+ else
snprintf(buf, MSG_SIZ, ":%s+%g", mytc, ti);
} else {
if(mps)
snprintf(buf, MSG_SIZ, ":%d/%s", mps, mytc);
- else
+ else
snprintf(buf, MSG_SIZ, ":%s", mytc);
}
fullTimeControlString = StrSave(buf); // this should now be in PGN format
-
+
if( NextTimeControlFromString( &tc, &tc1 ) != 0 ) {
return FALSE;
}
initialPosition[2][0] = BlackAngel;
initialPosition[6][BOARD_WIDTH-1] = WhiteMarshall;
initialPosition[5][BOARD_WIDTH-1] = WhiteAngel;
- initialPosition[1][1] = initialPosition[2][1] =
+ initialPosition[1][1] = initialPosition[2][1] =
initialPosition[6][BOARD_WIDTH-2] = initialPosition[5][BOARD_WIDTH-2] = 1;
}
if (appData.debugMode) {
}
Boolean
-OnlyMove (int *x, int *y, Boolean captures)
+OnlyMove (int *x, int *y, Boolean captures)
{
DisambiguateClosure cl;
if (appData.zippyPlay || !appData.testLegality) return FALSE;
if( (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) && fromY != DROP_RANK ) {
if( pup != EmptySquare ) return;
moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop;
- if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n",
+ if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n",
moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]);
// holdings might not be sent yet in ICS play; we have to figure out which piece belongs here
if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down
fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings
- while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++;
+ while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++;
fromY = DROP_RANK;
}
}
}
if(x == fromX && y == fromY) return; // if OnlyMove altered (x,y) we go on
- second = FALSE;
+ second = FALSE;
}
// ignore clicks on holdings
if(x < BOARD_LEFT || x >= BOARD_RGHT) return;
if(cps->initDone) return FALSE;
cps->isr = NULL; // this should suppress further error popups from breaking pipes
DestroyChildProcess(cps->pr, 9 ); // just to be sure
- cps->pr = NoProc;
+ cps->pr = NoProc;
if(cps == &first) {
appData.noChessProgram = TRUE;
gameMode = MachinePlaysBlack; ModeHighlight(); // kludge to unmark Machine Black menu
return; // [HGM] This return was missing, causing option features to be recognized as non-compliant commands!
}
- if ((!appData.testLegality || gameInfo.variant == VariantFairy) &&
+ if ((!appData.testLegality || gameInfo.variant == VariantFairy) &&
!strncmp(message, "setup ", 6)) { // [HGM] allow first engine to define opening position
int dummy, s=6; char buf[MSG_SIZ];
if(appData.icsActive || forwardMostMove != 0 || cps != &first) return;
) {
/* white pawn promotion */
board[toY][toX] = CharToPiece(ToUpper(promoChar));
- if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse)
+ if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse)
&& PieceToChar(PROMOTED board[toY][toX]) == '~') /* [HGM] use shadow piece (if available) */
board[toY][toX] = (ChessSquare) (PROMOTED board[toY][toX]);
board[fromY][fromX] = EmptySquare;
) {
/* black pawn promotion */
board[toY][toX] = CharToPiece(ToLower(promoChar));
- if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse)
+ if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse)
&& PieceToChar(PROMOTED board[toY][toX]) == '~') /* [HGM] use shadow piece (if available) */
board[toY][toX] = (ChessSquare) (PROMOTED board[toY][toX]);
board[fromY][fromX] = EmptySquare;
*blackPlayer = curRound + appData.tourneyType;
}
- // take care of white/black alternation per round.
+ // take care of white/black alternation per round.
// For cycles and games this is already taken care of by default, derived from matchGame!
return curRound & 1;
}
SendToProgram(buf, &pairing);
return 0; // wait for pairing engine to answer (which causes NextTourneyGame to be called again...
}
- pairingReceived = 0; // ... so we continue here
+ pairingReceived = 0; // ... so we continue here
*swapColors = 0;
appData.matchGames = appData.tourneyCycles * syncInterval - 1;
whitePlayer = savedWhitePlayer-1; blackPlayer = savedBlackPlayer-1;
if(piece < BlackPawn) piece += BlackPawn; else if(piece < EmptySquare) piece -= BlackPawn; // color-flip
reverseBoard[r][f] = piece;
}
- reverseBoard[EP_STATUS-1] = soughtBoard[EP_STATUS-1] ^ 3;
+ reverseBoard[EP_STATUS-1] = soughtBoard[EP_STATUS-1] ^ 3;
for(r=0; r<6; r++) reverseBoard[CASTLING][r] = boards[currentMove][CASTLING][(r+3)%6];
if(appData.findMirror && appData.searchMode <= 3 && (!nrCastlingRights
- || (boards[currentMove][CASTLING][2] == NoRights ||
+ || (boards[currentMove][CASTLING][2] == NoRights ||
boards[currentMove][CASTLING][0] == NoRights && boards[currentMove][CASTLING][1] == NoRights )
- && (boards[currentMove][CASTLING][5] == NoRights ||
+ && (boards[currentMove][CASTLING][5] == NoRights ||
boards[currentMove][CASTLING][3] == NoRights && boards[currentMove][CASTLING][4] == NoRights ) )
) {
flipSearch = TRUE;
StopClocks();
} else if(appData.ponderNextMove) SendToProgram("easy\n", &first); // pre-emptively bring out of ponder
} else { // human on move, pause pondering by either method
- if(first.pause)
+ if(first.pause)
PauseEngine(&first);
- else if(appData.ponderNextMove)
+ else if(appData.ponderNextMove)
SendToProgram("easy\n", &first);
StopClocks();
}
gameInfo.white, _("vs."), gameInfo.black,
nextGame+1, appData.matchGames+1,
appData.tourneyType>0 ? "gt" : appData.tourneyType<0 ? "sw" : "rr");
- } else
+ } else
if (first.twoMachinesColor[0] == 'w') {
snprintf(buf, MSG_SIZ, "%s %s %s (%d-%d-%d)",
gameInfo.white, _("vs."), gameInfo.black,
for(i=target; i>backwardMostMove; i--) { // seek back to start or previous null move
if(moveList[i-1][1] == '@' && moveList[i-1][0] == '@') break;
}
- SendBoard(&first, i);
+ SendBoard(&first, i);
if(second.analyzing) SendBoard(&second, i);
for(currentMove=i; currentMove<target; currentMove++) {
SendMoveToProgram(currentMove, &first);
char *p;
float score;
- if(index && sscanf(text, "%f/%d", &score, &len) == 2 &&
+ if(index && sscanf(text, "%f/%d", &score, &len) == 2 &&
pvInfoList[index-1].depth == len &&
fabs(pvInfoList[index-1].score - score*100.) < 0.5 &&
(p = strchr(text, '\n'))) text = p; // [HGM] strip off first line with PV info, if any
sscanf(message, "tell%c", &c)!=1 && sscanf(message, "0-1 %c", &c)!=1 &&
sscanf(message, "1-0 %c", &c)!=1 && sscanf(message, "1/2-1/2 %c", &c)!=1 &&
sscanf(message, "setboard %c", &c)!=1 && sscanf(message, "setup %c", &c)!=1 &&
- sscanf(message, "hint: %c", &c)!=1 &&
+ sscanf(message, "hint: %c", &c)!=1 &&
sscanf(message, "pong %c", &c)!=1 && start != '#') {
quote = appData.engineComments == 2 ? "# " : "### NON-COMPLIANT! ### ";
print = (appData.engineComments >= 2);
void
TypeInEvent (char firstChar)
{
- if ((gameMode == BeginningOfGame && !appData.icsActive) ||
+ if ((gameMode == BeginningOfGame && !appData.icsActive) ||
gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack ||
- gameMode == AnalyzeMode || gameMode == EditGame ||
+ gameMode == AnalyzeMode || gameMode == EditGame ||
gameMode == EditPosition || gameMode == IcsExamining ||
gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack ||
isdigit(firstChar) && // [HGM] movenum: allow typing in of move nr in 'passive' modes
return;
}
- if (gameMode != EditGame && currentMove != forwardMostMove &&
+ if (gameMode != EditGame && currentMove != forwardMostMove &&
gameMode != Training) {
DisplayMoveError(_("Displayed move is not current"));
} else {
- int ok = ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove,
+ int ok = ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove,
&moveType, &fromX, &fromY, &toX, &toY, &promoChar);
if(!ok && move[0] >= 'a') { move[0] += 'A' - 'a'; ok = 2; } // [HGM] try also capitalized
- if (ok==1 || ok && ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove,
+ if (ok==1 || ok && ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove,
&moveType, &fromX, &fromY, &toX, &toY, &promoChar)) {
- UserMoveEvent(fromX, fromY, toX, toY, promoChar);
+ UserMoveEvent(fromX, fromY, toX, toY, promoChar);
} else {
DisplayMoveError(_("Could not parse move"));
}
snprintf(buf, MSG_SIZ, "\"%s\"", nickName);
if(appData.useBitmaps) {
snprintf(buf+strlen(buf), MSG_SIZ-strlen(buf), " -ubt true -lbtf \"%s\" -dbtf \"%s\" -lbtm %d -dbtm %d",
- appData.liteBackTextureFile, appData.darkBackTextureFile,
+ appData.liteBackTextureFile, appData.darkBackTextureFile,
appData.liteBackTextureMode,
appData.darkBackTextureMode );
} else {
drawHighlight(hi2X, hi2Y, 0);
}
}
-
+
if(arrow) // there currently is an arrow displayed
ArrowDamage(hi1X, hi1Y, hi2X, hi2Y); // mark which squares it damaged
if( IsDrawArrowEnabled() && fromX >= 0 && fromY >= 0 && toX >= 0 && toY >= 0)
DrawArrowBetweenSquares(fromX, fromY, toX, toY);
}
-
-
extern int damage[2][BOARD_RANKS][BOARD_FILES];
extern Option *currBoard;
-
* book.c -- code for probing Polyglot opening books
*
* This code was first released in the public domain by Michel Van den Bergh.
- * The array Random64 is taken from the Polyglot source code.
+ * The array Random64 is taken from the Polyglot source code.
* I am pretty sure that a table of random numbers is never protected
* by copyright.
*
typedef unsigned int uint32;
typedef struct {
- uint64 key;
+ uint64 key;
uint16 move;
uint16 weight;
uint16 learnPoints;
f = boards[moveNr][EP_STATUS];
if(f >= 0 && f < 8){
if(!WhiteOnMove(moveNr)){
- // the test for neighboring Pawns might not be needed,
+ // the test for neighboring Pawns might not be needed,
// as epStatus already kept track of it, but better safe than sorry.
if((f>0 && boards[moveNr][3][f-1]==BlackPawn)||
(f<7 && boards[moveNr][3][f+1]==BlackPawn)){
if(gameInfo.variant != VariantNormal) return;
- // correct FRC-style castlings in variant normal.
+ // correct FRC-style castlings in variant normal.
// [HGM] This is buggy code! e1h1 could very well be a normal R or Q move.
if(!strcmp(move_s,"e1h1")){
safeStrCpy(move_s,"e1g1", 6);
static FILE *f = NULL;
static char curBook[MSG_SIZ];
- if(book == NULL) return -1;
+ if(book == NULL) return -1;
if(!f || strcmp(book, curBook)){ // keep book file open until book changed
strncpy(curBook, book, MSG_SIZ);
if(f) fclose(f);
char
*ProbeBook (int moveNr, char *book)
-{ //
+{ //
entry_t entries[MOVE_BUF];
int count;
int i, j;
static char move_s[6];
int total_weight;
- if(moveNr >= 2*appData.bookDepth) return NULL;
+ if(moveNr >= 2*appData.bookDepth) return NULL;
if(mcMode) return MCprobe(moveNr);
if((count = ReadFromBookFile(moveNr, book, entries)) <= 0) return NULL; // no book, or no hit
/*
- * childio.c -- set up communication with child processes
+ * childio.c -- set up communication with child processes
*
* Copyright 1991 by Digital Equipment Corporation, Maynard,
- * Massachusetts.
+ * Massachusetts.
*
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
* 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
extern char *ptsname();
char *ptss;
int fd;
-
+
fd = open("/dev/ptmx", O_RDWR);
if (fd < 0) return fd;
if (grantpt(fd) == -1) return -1;
* childio.h -- set up communication with child processes
*
* Copyright 1991 by Digital Equipment Corporation, Maynard,
- * Massachusetts.
+ * Massachusetts.
*
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
* 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
#define secondOptions engOptions[1]
#endif
-
//-------------------------------------------- Load Game Options ---------------------------------
-static char *modeNames[] = { N_("Exact position match"), N_("Shown position is subset"), N_("Same material with exactly same Pawn chain"),
+static char *modeNames[] = { N_("Exact position match"), N_("Shown position is subset"), N_("Same material with exactly same Pawn chain"),
N_("Same material"), N_("Material range (top board half optional)"), N_("Material difference (optional stuff balanced)"), NULL };
static char *modeValues[] = { "1", "2", "3", "4", "5", "6" };
static char *searchMode;
{
if (histP == histIn) return NULL;
histP = (histP + 1) % HISTORY_SIZE;
- return history[histP];
+ return history[histP];
}
// end of borrowed code
{
errorUp = True;
errorOptions[1].name = label;
- if(dialogError = shellUp[TransientDlg])
+ if(dialogError = shellUp[TransientDlg])
GenericPopUp(errorOptions+1, title, FatalDlg, TransientDlg, MODAL, 0); // pop up as daughter of the transient dialog
else
GenericPopUp(errorOptions+modal, title, modal ? FatalDlg: ErrorDlg, BoardWindow, modal, 0); // kludge: option start address indicates modality
{
void *whiteLogo = first.programLogo, *blackLogo = second.programLogo;
if(appData.autoLogo) {
-
+
switch(gameMode) { // pick logos based on game mode
case IcsObserving:
whiteLogo = second.programLogo; // ICS logo
int w = width - 44 - mainOptions[n].min;
mainOptions[W_TITLE].max = w; // width left behind menu bar
if(w < 0.4*width) // if no reasonable amount of space for title, force small layout
- mainOptions[W_SMALL].type = mainOptions[W_TITLE].type, mainOptions[W_TITLE].type = -1;
+ mainOptions[W_SMALL].type = mainOptions[W_TITLE].type, mainOptions[W_TITLE].type = -1;
}
void
{
return NULL;
}
-
#define W_WHITE 12
#define W_BLACK 13
#define W_SMALL 15 // title in small layout
-#define W_MESSG 16
+#define W_MESSG 16
#define W_BUTTON 17 // button bar
#define W_PAUSE 20
#define W_BOARD 24
#define W_MENUW 25
#define W_MENUB 26
#define W_DROP 27 // drop (popup) menu
-
+
typedef enum { // identifier of dialogs done by GenericPopup
TransientDlg=0, // transient: grabs mouse events and is destroyed at pop-down (so other dialog can use this ID next time)
CommentDlg, TagsDlg, TextMenuDlg, InputBoxDlg, ChatDlg, DummyDlg, HistoryDlg, // persistent: no grab and reused
// in ngamelist.c
int GameListClicks P((int direction));
void SetFilter P((void));
-
}
char *pngPieceNames[] = // must be in same order as internal piece encoding
-{ "Pawn", "Knight", "Bishop", "Rook", "Queen", "Advisor", "Elephant", "Archbishop", "Marshall", "Gold", "Commoner",
- "Canon", "Nightrider", "CrownedBishop", "CrownedRook", "Princess", "Chancellor", "Hawk", "Lance", "Cobra", "Unicorn", "King",
+{ "Pawn", "Knight", "Bishop", "Rook", "Queen", "Advisor", "Elephant", "Archbishop", "Marshall", "Gold", "Commoner",
+ "Canon", "Nightrider", "CrownedBishop", "CrownedRook", "Princess", "Chancellor", "Hawk", "Lance", "Cobra", "Unicorn", "King",
"GoldKnight", "GoldLance", "GoldPawn", "GoldSilver", NULL
};
/* free memory */
cairo_destroy (cr);
}
-
-
// defined in xoptions.c
void GraphExpose P((Option *opt, int x, int y, int w, int h));
-
void SetEngineOutputTitle( char *title );
void InitEngineOutput P((Option *opt, Option *memo2)); // XB only
void DrawWidgetIcon P((Option *opt, int nIcon)); // XB only
-
if( depth <=0 ) return title;
if( currCurrent & 1 ) score = -score; /* Flip score for black */
- snprintf(buf, MSG_SIZ, "%s {%d: %s%.2f/%-2d %d}", title, currCurrent/2+1,
+ snprintf(buf, MSG_SIZ, "%s {%d: %s%.2f/%-2d %d}", title, currCurrent/2+1,
score>0 ? "+" : " ", score/100., depth, (currPvInfo[currCurrent].time+50)/100);
return buf;
DrawAxis ()
{
int cy = nHeightPB / 2, space = nHeightPB/(6 + appData.zoom);
-
+
DrawAxisSegmentHoriz( +5, TRUE );
DrawAxisSegmentHoriz( +3, space >= 20 );
DrawAxisSegmentHoriz( +1, space >= 20 && space*appData.zoom >= 40 );
extern int GetMoveIndexFromPoint( int x, int y );
extern void PaintEvalGraph( void );
extern char *MakeEvalTitle( char *title );
-
idx++;
} while( id != '\0' );
}
-
/* Always toggle, don't set. Previous code messes up when
invoked while the button is pressed, as releasing it
toggles the state again. */
- GdkColor color;
+ GdkColor color;
gdk_color_parse( pausing ? "#808080" : "#F0F0F0", &color );
gtk_widget_modify_bg ( GTK_WIDGET(optList[W_PAUSE].handle), GTK_STATE_NORMAL, &color );
}
return;
}
selection_tmp[len] = NULLCHAR; // file is now in selection_tmp
-
+
// copy selection_tmp to clipboard
GdkDisplay *gdisp = gdk_display_get_default();
if (!gdisp) {
}
cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text(cb, selection_tmp, -1);
- g_free(selection_tmp);
+ g_free(selection_tmp);
}
void
gchar *fenstr;
if (gdisp == NULL) return;
- cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD);
+ cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD);
fenstr = gtk_clipboard_wait_for_text(cb);
- if (fenstr==NULL) return; // nothing had been selected to copy
+ if (fenstr==NULL) return; // nothing had been selected to copy
EditPositionPasteFEN(fenstr);
return;
}
// get game from clipboard
GdkDisplay *gdisp = gdk_display_get_default();
if (gdisp == NULL) return;
- cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD);
+ cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD);
text = gtk_clipboard_wait_for_text(cb);
- if (text == NULL) return; // nothing to paste
+ if (text == NULL) return; // nothing to paste
len = strlen(text);
// write to temp file
if (text == NULL || len == 0) {
- return; //nothing to paste
+ return; //nothing to paste
}
f = fopen(gamePasteFilename, "w");
if (f == NULL) {
fwrite(text, 1, len, f);
fclose(f);
- // load from file
+ // load from file
LoadGameFromFile(gamePasteFilename, 0, gamePasteFilename, TRUE);
return;
}
buf[0]=eventkey->keyval;
buf[1]='\0';
- if (*buf >= 32)
+ if (*buf >= 32)
BoxAutoPopUp (buf);
}
return;
}
-
#define TOPLEVEL 1 /* preference item; 1 = make popup windows toplevel */
-
{
char *p;
GtkTextIter start;
-
+
/* the backend adds \r\n, which is needed for winboard,
* for xboard we delete them again over here */
if(p = strchr(text, '\r')) *p = ' ';
if(mode) gtk_widget_show(engoutOptions[13].handle);
else gtk_widget_hide(engoutOptions[13].handle);
}
-
#include <cairo/cairo.h>
#include <cairo/cairo-xlib.h>
#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
+#include <gdk/gdkkeysyms.h>
#include "common.h"
#include "backend.h"
}
void GetWidgetTextGTK(GtkWidget *w, char **buf)
-{
+{
GtkTextIter start;
- GtkTextIter end;
+ GtkTextIter end;
if (GTK_IS_ENTRY(w)) {
*buf = (char *) gtk_entry_get_text(GTK_ENTRY (w));
}
else {
printf("error in GetWidgetText, invalid widget\n");
- *buf = NULL;
+ *buf = NULL;
}
}
case PathName:
case TextBox: GetWidgetTextGTK((GtkWidget *) opt->handle, buf); break;
case Spin:
- x = gtk_spin_button_get_value (GTK_SPIN_BUTTON(opt->handle));
+ x = gtk_spin_button_get_value (GTK_SPIN_BUTTON(opt->handle));
snprintf(val, 12, "%d", x); *buf = val;
break;
default:
}
void SetSpinValue(Option *opt, char *val, int n)
-{
+{
if (opt->type == Spin)
{
if (!strcmp(val, _("Unused")))
gtk_widget_set_sensitive(opt->handle, FALSE);
else
{
- gtk_widget_set_sensitive(opt->handle, TRUE);
+ gtk_widget_set_sensitive(opt->handle, TRUE);
gtk_spin_button_set_value(opt->handle, atoi(val));
}
}
else
- printf("error in SetSpinValue, unknown type %d\n", opt->type);
+ printf("error in SetSpinValue, unknown type %d\n", opt->type);
}
void SetWidgetTextGTK(GtkWidget *w, char *text)
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
GtkListStore *store = GTK_LIST_STORE(model);
GtkTreeIter iter;
-
+
if(n1 >= 0 && n2 >= 0) {
SetListBoxItem(store, n1, data[n1]);
SetListBoxItem(store, n2, data[n2]);
return;
}
- if (gtk_tree_model_get_iter_first(model, &iter))
+ if (gtk_tree_model_get_iter_first(model, &iter))
gtk_list_store_clear(store);
while(*data) { // add elements to listbox one by one
gint i = ((intptr_t)addr) & 255; // option number
gint g;
- g = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ g = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
values[i] = g; // store in temporary, for transfer at OK
#if TODO_GTK
menu = gtk_menu_new();
// menu = XtCreatePopupShell(opt->name, simpleMenuWidgetClass, parent, NULL, 0);
- for (i=0; 1; i++)
+ for (i=0; 1; i++)
{
char *msg = mb[i].string;
if(!msg) break;
- if(strcmp(msg, "----")) { //
+ if(strcmp(msg, "----")) { //
if(!(opt->min & NO_GETTEXT)) msg = _(msg);
if(mb[i].handle) {
entry = gtk_check_menu_item_new_with_label(msg); // should be used for items that can be checkmarked
/* get text from textbuffer */
gtk_text_buffer_get_start_iter (memo->handle, &start);
gtk_text_buffer_get_end_iter (memo->handle, &end);
- val = gtk_text_buffer_get_text (memo->handle, &start, &end, FALSE);
+ val = gtk_text_buffer_get_text (memo->handle, &start, &end, FALSE);
break;
default:
return FALSE; // should not happen
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
- XFlush(xDisplay);
+ XFlush(xDisplay);
XSync(xDisplay, False);
#endif
}
int
PopDown (DialogClass n)
{
- //Arg args[10];
-
- if (!shellUp[n] || !shells[n]) return 0;
+ //Arg args[10];
+
+ if (!shellUp[n] || !shells[n]) return 0;
if(n && wp[n]) { // remember position
GetActualPlacement(shells[n], wp[n]);
}
-
+
gtk_widget_hide(shells[n]);
shellUp[n]--; // count rather than clear
#endif
shells[dlg] = w; // make sure we pop down the right one in case of multiple instances
- /* OK pressed */
+ /* OK pressed */
if (resptype == GTK_RESPONSE_ACCEPT) {
if (GenericReadout(currentOption, -1)) PopDown(dlg);
return TRUE;
}
int AppendText(Option *opt, char *s)
-{
+{
char *v;
int len;
- GtkTextIter end;
-
+ GtkTextIter end;
+
GetWidgetTextGTK(opt->handle, &v);
len = strlen(v);
g_free(v);
void GenericCallback(GtkWidget *widget, gpointer gdata)
{
const gchar *name;
- char buf[MSG_SIZ];
- int data = (intptr_t) gdata;
+ char buf[MSG_SIZ];
+ int data = (intptr_t) gdata;
DialogClass dlg;
#ifdef TODO_GTK
GtkWidget *sh = XtParent(XtParent(XtParent(w))), *oldSh;
oldSh = shells[dlg]; shells[dlg] = sh; // bow to reality
if (data == 30000) { // cancel
- PopDown(dlg);
+ PopDown(dlg);
} else
if (data == 30001) { // save buttons imply OK
if(GenericReadout(currentOption, -1)) PopDown(dlg); // calls OK-proc after full readout, but no popdown if it returns false
} else
if(currentCps) {
- name = gtk_button_get_label (GTK_BUTTON(widget));
+ name = gtk_button_get_label (GTK_BUTTON(widget));
if(currentOption[data].type == SaveButton) GenericReadout(currentOption, -1);
snprintf(buf, MSG_SIZ, "option %s\n", name);
SendToProgram(buf, currentCps);
- } else ((ButtonCallback*) currentOption[data].target)(data);
+ } else ((ButtonCallback*) currentOption[data].target)(data);
shells[dlg] = oldSh; // in case of multiple instances, restore previous (as this one could be popped down now)
}
GtkFileFilter *gtkfilter_all;
int opt_i = (intptr_t) gdata;
GtkFileChooserAction fc_action;
-
+
gtkfilter = gtk_file_filter_new();
gtkfilter_all = gtk_file_filter_new();
gtk_file_filter_add_pattern(gtkfilter_all, "*");
gtk_file_filter_set_name (gtkfilter_all, "All Files");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),gtkfilter_all);
-
+
/* filter for specific filetypes e.g. pgn or fen */
- if (currentOption[opt_i].textValue != NULL && (strcmp(currentOption[opt_i].textValue, "") != 0) )
- {
- strcat(fileext, currentOption[opt_i].textValue);
+ if (currentOption[opt_i].textValue != NULL && (strcmp(currentOption[opt_i].textValue, "") != 0) )
+ {
+ strcat(fileext, currentOption[opt_i].textValue);
gtk_file_filter_add_pattern(gtkfilter, fileext);
gtk_file_filter_set_name (gtkfilter, currentOption[opt_i].textValue);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(dialog),gtkfilter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog),gtkfilter);
}
else
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog),gtkfilter_all);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog),gtkfilter_all);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
entry = currentOption[opt_i].handle;
- gtk_entry_set_text (GTK_ENTRY (entry), filename);
+ gtk_entry_set_text (GTK_ENTRY (entry), filename);
g_free (filename);
}
int
GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent, int modal, int topLevel)
-{
+{
GtkWidget *dialog = NULL;
gint w;
GtkWidget *label;
GtkWidget *box;
GtkWidget *checkbutton;
GtkWidget *entry;
- GtkWidget *oldHbox, *hbox = NULL;
+ GtkWidget *oldHbox, *hbox = NULL;
GtkWidget *pane = NULL;
GtkWidget *button;
GtkWidget *table;
- GtkWidget *spinner;
+ GtkWidget *spinner;
GtkAdjustment *spinner_adj;
GtkWidget *combobox;
GtkWidget *textview;
- GtkTextBuffer *textbuffer;
- GdkColor color;
+ GtkTextBuffer *textbuffer;
+ GdkColor color;
GtkWidget *actionarea;
- GtkWidget *sw;
- GtkWidget *list;
- GtkWidget *graph;
- GtkWidget *menuButton;
- GtkWidget *menuBar;
- GtkWidget *menu;
-
- int i, j, arraysize, left, top, height=999, width=1, boxStart, breakType = 0, r;
+ GtkWidget *sw;
+ GtkWidget *list;
+ GtkWidget *graph;
+ GtkWidget *menuButton;
+ GtkWidget *menuBar;
+ GtkWidget *menu;
+
+ int i, j, arraysize, left, top, height=999, width=1, boxStart, breakType = 0, r;
char def[MSG_SIZ], *msg, engineDlg = (currentCps != NULL && dlgNr != BrowserDlg);
if(dlgNr < PromoDlg && shellUp[dlgNr]) return 0; // already up
printf("n=%d, h=%d, w=%d\n",n,height,width);
// if(n && (currentOption[n-1].type == Button || currentOption[n-1].type == SaveButton)) currentOption[n].min = SAME_ROW; // OK on same line
currentOption[n].type = EndMark; currentOption[n].target = NULL; // delimit list by callback-less end mark
- }
+ }
parents[dlgNr] = parent;
#ifdef TODO_GTK
(modal ? GTK_DIALOG_MODAL : 0),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- NULL );
+ NULL );
shells[dlgNr] = dialog;
box = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) );
-// gtk_box_set_spacing(GTK_BOX(box), 5);
+// gtk_box_set_spacing(GTK_BOX(box), 5);
arraysize = 0;
for (i=0;option[i].type != EndMark;i++) {
- arraysize++;
+ arraysize++;
}
table = gtk_table_new(arraysize, r=TableWidth(option), FALSE);
left = 0;
- top = -1;
+ top = -1;
for (i=0;option[i].type != EndMark;i++) {
if(option[i].type == -1) continue;
gtk_box_pack_start (GTK_BOX (pane), table, TRUE, TRUE, 0);
table = gtk_table_new(arraysize - i, r=TableWidth(option + i), FALSE);
top = 0;
- }
+ }
if(!SameRow(&option[i])) {
if(SameRow(&option[i+1])) {
GtkAttachOptions x = GTK_FILL;
} else hbox = NULL; //and also make sure no hbox exists if only singl option on row
} else top--;
switch(option[i].type) {
- case Fractional:
+ case Fractional:
snprintf(def, MSG_SIZ, "%.2f", *(float*)option[i].target);
option[i].value = *(float*)option[i].target;
goto tBox;
if(!currentCps) option[i].value = *(int*)option[i].target;
snprintf(def, MSG_SIZ, "%d", option[i].value);
case TextBox:
- case FileName:
+ case FileName:
case PathName:
tBox:
label = gtk_label_new(option[i].name);
if(option[i].type == FileName || option[i].type == PathName) w -= 55;
if (option[i].type==TextBox && option[i].value > 80){
- textview = gtk_text_view_new();
+ textview = gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), option[i].min & T_WRAP ? GTK_WRAP_WORD : GTK_WRAP_NONE);
#ifdef TODO_GTK
if(option[i].min & T_FILL) { XtSetArg(args[j], XtNautoFill, True); j++; }
gtk_container_add(GTK_CONTAINER(sw), textview);
gtk_widget_set_size_request(GTK_WIDGET(sw), w, -1);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_OUT);
-
- textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- /* check if label is empty */
+
+ textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ /* check if label is empty */
if (strcmp(option[i].name,"") != 0) {
gtk_table_attach(GTK_TABLE(table), label, left, left+1, top, top+1, GTK_FILL, GTK_FILL, 2, 1);
Pack(hbox, table, sw, left+1, left+r, top, 0);
else {
/* no label so let textview occupy all columns */
Pack(hbox, table, sw, left, left+r, top, GTK_EXPAND);
- }
+ }
if ( *(char**)option[i].target != NULL )
gtk_text_buffer_set_text (textbuffer, *(char**)option[i].target, -1);
else
- gtk_text_buffer_set_text (textbuffer, "", -1);
+ gtk_text_buffer_set_text (textbuffer, "", -1);
option[i].handle = (void*)textbuffer;
option[i].textValue = (char*)textview;
if(option[i].choice) { // textviews can request a handler for mouse events in the choice field
g_signal_connect(textview, "button-release-event", G_CALLBACK (MemoEvent), (gpointer) &option[i] );
g_signal_connect(textview, "motion-notify-event", G_CALLBACK (MemoEvent), (gpointer) &option[i] );
}
- break;
+ break;
}
entry = gtk_entry_new();
else if (currentCps)
gtk_entry_set_text (GTK_ENTRY (entry), option[i].textValue);
else if ( *(char**)option[i].target != NULL )
- gtk_entry_set_text (GTK_ENTRY (entry), *(char**)option[i].target);
+ gtk_entry_set_text (GTK_ENTRY (entry), *(char**)option[i].target);
//gtk_entry_set_width_chars (GTK_ENTRY (entry), 18);
gtk_entry_set_max_length (GTK_ENTRY (entry), w);
if (strcmp(option[i].name, "") != 0)
gtk_table_attach(GTK_TABLE(table), label, left, left+1, top, top+1, GTK_FILL, GTK_FILL, 2, 1); // leading names do not expand
- if (option[i].type == Spin) {
+ if (option[i].type == Spin) {
spinner_adj = (GtkAdjustment *) gtk_adjustment_new (option[i].value, option[i].min, option[i].max, 1.0, 0.0, 0.0);
spinner = gtk_spin_button_new (spinner_adj, 1.0, 0);
gtk_table_attach(GTK_TABLE(table), spinner, left+1, left+r, top, top+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 1);
button = gtk_button_new_with_label ("Browse");
gtk_table_attach(GTK_TABLE(table), button, left+2, left+r, top, top+1, GTK_FILL, GTK_FILL, 2, 1); // Browse button does not expand
g_signal_connect (button, "clicked", G_CALLBACK (BrowseGTK), (gpointer)(intptr_t) i);
- option[i].handle = (void*)entry;
+ option[i].handle = (void*)entry;
}
else {
Pack(hbox, table, entry, left + (strcmp(option[i].name, "") != 0), left+r, top, 0);
option[i].handle = (void*)entry;
- }
+ }
break;
case CheckBox:
- checkbutton = gtk_check_button_new_with_label(option[i].name);
+ checkbutton = gtk_check_button_new_with_label(option[i].name);
if(!currentCps) option[i].value = *(Boolean*)option[i].target;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), option[i].value);
gtk_table_attach(GTK_TABLE(table), checkbutton, left, left+r, top, top+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 0);
- option[i].handle = (void *)checkbutton;
- break;
- case Icon:
+ option[i].handle = (void *)checkbutton;
+ break;
+ case Icon:
option[i].handle = (void *) (label = gtk_image_new_from_pixbuf(NULL));
gtk_widget_set_size_request(label, option[i].max ? option[i].max : -1, -1);
Pack(hbox, table, label, left, left+2, top, 0);
- break;
- case Label:
+ break;
+ case Label:
option[i].handle = (void *) (label = gtk_label_new(option[i].name));
/* Left Justify */
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gdk_color_parse( option[i].textValue, &color );
gtk_widget_modify_bg ( GTK_WIDGET(button), GTK_STATE_NORMAL, &color );
gtk_widget_set_sensitive(button, appData.noChessProgram || option[i].value < 0
- || strstr(first.variants, VariantName(option[i].value)));
+ || strstr(first.variants, VariantName(option[i].value)));
}
-
+
Pack(hbox, table, button, left, left+1, top, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (GenericCallback), (gpointer)(intptr_t) i + (dlgNr<<16));
- option[i].handle = (void*)button;
- break;
+ g_signal_connect (button, "clicked", G_CALLBACK (GenericCallback), (gpointer)(intptr_t) i + (dlgNr<<16));
+ option[i].handle = (void*)button;
+ break;
case ComboBox:
label = gtk_label_new(option[i].name);
/* Left Justify */
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_table_attach(GTK_TABLE(table), label, left, left+1, top, top+1, GTK_FILL, GTK_FILL, 2, 1);
- combobox = gtk_combo_box_new_text();
+ combobox = gtk_combo_box_new_text();
for(j=0;;j++) {
if ( ((char **) option[i].textValue)[j] == NULL) break;
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), ((char **) option[i].choice)[j]);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), ((char **) option[i].choice)[j]);
}
if(currentCps)
option[i].choice = (char**) option[i].textValue;
else {
- for(j=0; option[i].choice[j]; j++) {
+ for(j=0; option[i].choice[j]; j++) {
if(*(char**)option[i].target && !strcmp(*(char**)option[i].target, ((char**)(option[i].textValue))[j])) break;
}
/* If choice is NULL set to first */
if (option[i].choice[j] == NULL)
option[i].value = 0;
- else
+ else
option[i].value = j;
}
- //option[i].value = j + (option[i].choice[j] == NULL);
- gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), option[i].value);
-
+ //option[i].value = j + (option[i].choice[j] == NULL);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), option[i].value);
+
Pack(hbox, table, combobox, left+1, left+r, top, 0);
g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(ComboSelect), (gpointer) (intptr_t) (i + 256*dlgNr));
option[i].handle = (void*)combobox;
- values[i] = option[i].value;
+ values[i] = option[i].value;
break;
case ListBox:
{
gtk_container_add(GTK_CONTAINER(sw), list);
gtk_widget_set_size_request(GTK_WIDGET(sw), option[i].max ? option[i].max : -1, option[i].value ? option[i].value : -1);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_OUT);
-
+
if(option[i].textValue) // generic callback for double-clicking listbox item
g_signal_connect(list, "button-press-event", G_CALLBACK(ListCallback), (gpointer) (dlgNr<<16 | i) );
case BarEnd:
top--;
gtk_table_attach(GTK_TABLE(table), menuBar, left, left+r, top, top+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 1);
-
+
if(option[i].target) ((ButtonCallback*)option[i].target)(boxStart); // callback that can make sizing decisions
break;
case BoxEnd:
case Break:
breakType = option[i].min & SAME_ROW;
top = height; // force next option to start in a new table
- break;
+ break;
case PopUp:
top--;
- break;
+ break;
default:
printf("GenericPopUp: unexpected case in switch. i=%d type=%d name=%s.\n", i, option[i].type, option[i].name);
break;
- }
+ }
}
if(pane)
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_NONE);
/* Show dialog */
- gtk_widget_show_all( dialog );
+ gtk_widget_show_all( dialog );
/* hide OK/cancel buttons */
if((option[i].min & NO_OK)) {
{
FocusOnWidget(opt, 0); // second arg not used in GDK
}
-
-
{
clockTimerTag = g_timeout_add(millisec,(GSourceFunc) ClockTimerCallback,NULL);
}
-
-
* 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/.
+ * along with this program. If not, see http://www.gnu.org/licenses/.
*
* ------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
if( lastFirst >= 0 &&
lastLast >= lastFirst &&
- lastCurrent >= lastFirst &&
+ lastCurrent >= lastFirst &&
currFirst == lastFirst &&
currLast == lastLast &&
currCurrent >= 0 &&
/* PV info (if any) */
if( appData.showEvalInMoveHistory && currPvInfo[index].depth > 0 ) {
- sprintf( buf, "{%s%.2f/%d} ",
+ sprintf( buf, "{%s%.2f/%d} ",
currPvInfo[index].score >= 0 ? "+" : "",
currPvInfo[index].score / 100.0,
currPvInfo[index].depth );
DoHighlight (int index, int onoff)
{
if( index >= 0 && index < MAX_MOVES ) {
- HighlightMove( histMoves[index].memoOffset,
+ HighlightMove( histMoves[index].memoOffset,
histMoves[index].memoOffset + histMoves[index].memoLength, onoff );
}
}
if(MoveHistoryDialogExists())
UpdateMoveHistory(); // [HGM] call this directly, in stead of through call-back
}
-
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
-
+
if [ -d $dst ]; then
instcmd=:
else
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
+# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
echo "install: $src does not exist"
exit 1
fi
-
+
if [ x"$dst" = x ]
then
echo "install: no destination specified"
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
-defaultIFS='
+defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
# If we're going to rename the final executable, determine the name now.
- if [ x"$transformarg" = x ]
+ if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
- dstfile=`basename $dst $transformbasename |
+ dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
- if [ x"$dstfile" = x ]
+ if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
}
void
-LoadPositionProc()
+LoadPositionProc()
{
if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
Reset(FALSE, TRUE);
#else
char *zippy = "";
#endif
- snprintf(buf, sizeof(buf),
+ snprintf(buf, sizeof(buf),
_("%s%s\n\n"
"Copyright 1991 Digital Equipment Corporation\n"
"Enhancements Copyright 1992-2012 Free Software Foundation\n"
MarkMenuItem("Options.SaveSettingsonExit", True);
}
}
-
-
#define OPTIONSDIALOG
#define INFOFILE "xboard.info"
-
}
if(gameInfo.variant == VariantSpartan) rookRange = 2; // in Spartan Chess restrict range to modern Dababba
goto doRook;
-
+
/* Shogi Dragon King has to continue as Ferz after Rook moves */
case SHOGI WhiteDragon:
case SHOGI BlackDragon:
rf, ff, rf + 1, ff, closure);
for (s = -1; s <= 1; s += 2) {
if (rf < BOARD_HEIGHT-1 && ff + s >= BOARD_LEFT && ff + s < BOARD_RGHT && board[rf + 1][ff + s] == EmptySquare)
- callback(board, flags,
+ callback(board, flags,
rf >= BOARD_HEIGHT-1-promoRank ? WhitePromotion : NormalMove,
rf, ff, rf + 1, ff + s, closure);
if (rf == 1 && ff + 2*s >= BOARD_LEFT && ff + 2*s < BOARD_RGHT && board[3][ff + 2*s] == EmptySquare )
callback(board, flags, NormalMove, rf, ff, 3, ff + 2*s, closure);
}
break;
-
+
case BlackLance:
if(gameInfo.variant == VariantSuper) goto Amazon;
if (rf > 0 && WhitePiece(board[rf - 1][ff]))
rf, ff, rf - 1, ff, closure);
for (s = -1; s <= 1; s += 2) {
if (rf > 0 && ff + s >= BOARD_LEFT && ff + s < BOARD_RGHT && board[rf - 1][ff + s] == EmptySquare)
- callback(board, flags,
+ callback(board, flags,
rf <= promoRank ? BlackPromotion : NormalMove,
rf, ff, rf - 1, ff + s, closure);
if (rf == BOARD_HEIGHT-2 && ff + 2*s >= BOARD_LEFT && ff + 2*s < BOARD_RGHT && board[rf-2][ff + 2*s] == EmptySquare )
int rf, int ff, int rt, int ft,
VOIDSTAR closure));
-void
+void
GenLegalCallback (Board board, int flags, ChessMove kind, int rf, int ff, int rt, int ft, VOIDSTAR closure)
{
register GenLegalClosure *cl = (GenLegalClosure *) closure;
if(quickFlag) flags = flags & ~1 | quickFlag & 1; // [HGM] speed: in quick mode quickFlag specifies side-to-move.
if(rf == DROP_RANK) return LegalDrop(board, flags, ff, rt, ft);
piece = filterPiece = board[rf][ff];
- if(PieceToChar(piece) == '~') filterPiece = DEMOTED piece;
+ if(PieceToChar(piece) == '~') filterPiece = DEMOTED piece;
/* [HGM] Cobra and Falcon are wildcard pieces; consider all their moves legal */
/* (perhaps we should disallow moves that obviously leave us in check?) */
piece == WhiteKnight && closure->rt > BOARD_HEIGHT-3) /* promotion mandatory */
closure->kind = c == '=' ? IllegalMove : WhitePromotion;
else /* promotion optional, default is defer */
- closure->kind = c == '+' ? WhitePromotion : WhiteNonPromotion;
+ closure->kind = c == '+' ? WhitePromotion : WhiteNonPromotion;
} else closure->kind = c == '+' ? IllegalMove : NormalMove;
} else {
if( (int) piece < (int) BlackWazir && (closure->rf < BOARD_HEIGHT/3 || closure->rt < BOARD_HEIGHT/3) ) {
/* [HGM] in Shogi non-pawns can promote */
*outp++ = promoChar; // Don't bother to correct move type, return value is never used!
}
- else if (gameInfo.variant != VariantSuper && promoChar &&
+ else if (gameInfo.variant != VariantSuper && promoChar &&
(piece == WhiteLance || piece == BlackLance) ) { // Lance sometimes represents Pawn
*outp++ = '=';
*outp++ = ToUpper(promoChar);
}
*outp = NULLCHAR;
return cl.kind;
-
+
case EmptySquare:
/* Moving a nonexistent piece */
break;
#define F_IGNORE_CHECK 32
#define F_KRIEGSPIEL_CAPTURE 64 /* pawns can try to capture invisible pieces */
#define F_ATOMIC_CAPTURE 128 /* capturing piece explodes, destroying itself
- and all non-pawns on adjacent squares;
+ and all non-pawns on adjacent squares;
destroying your own king is illegal */
#define F_FRC_TYPE_CASTLING 256 /* generate castlings as captures of own Rook */
#define F_MANDATORY_CAPTURE 0x200
extern void GenPseudoLegal P((Board board, int flags,
MoveCallback callback, VOIDSTAR closure, ChessSquare filter));
-/* Like GenPseudoLegal, but include castling moves and (unless
+/* Like GenPseudoLegal, but include castling moves and (unless
F_IGNORE_CHECK is set in the flags) omit moves that would leave the
king in check. The CASTLE_OK flags are true if castling is not yet
ruled out by a move of the king or rook. Return TRUE if the player
e.p. capture. The possibility of castling out of a check along the
back rank is not accounted for (i.e., we still return nonzero), as
this is illegal anyway. Return value is the number of times the
- king is in check. */
+ king is in check. */
extern int CheckTest P((Board board, int flags,
int rf, int ff, int rt, int ft, int enPassant));
{
if (!PopDown(EngOutDlg)) EngineOutputPopUp();
}
-
DisplayEvalGraph();
}
}
-
/* Copy the list into the global memory block */
if( f != NULL ) {
-
+
lg = (ListGame *) gameList.head;
for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
}
return False;
}
-
* 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/.
+ * along with this program. If not, see http://www.gnu.org/licenses/.
*
* ------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
{
char *start = *p;
if(**p == 'e' && (Match("ep", p) || Match("e.p.", p))) { *p = start; return NULLCHAR; } // non-compliant e.p. suffix is no promoChar!
- if(**p == '+' && gameInfo.variant == VariantShogi) { (*p)++; return '+'; }
+ if(**p == '+' && gameInfo.variant == VariantShogi) { (*p)++; return '+'; }
if(**p == '=' || (gameInfo.variant == VariantSChess) && **p == '/') (*p)++; // optional = (or / for Seirawan gating)
if(**p == '(' && (*p)[2] == ')' && isalpha( (*p)[1] )) { (*p) += 3; return ToLower((*p)[-2]); }
if(isalpha(**p)) return ToLower(*(*p)++);
}
// we always get here; move must be completely read now, with to-square coord(s) at end
if(n == 3) { // incomplete to-square. Could be Xiangqi traditional, or stuff like fxg
- if(piece && type[1] == NOTHING && type[0] == NUMERIC && type[2] == NUMERIC &&
+ if(piece && type[1] == NOTHING && type[0] == NUMERIC && type[2] == NUMERIC &&
(separator == '+' || separator == '=' || separator == '-')) {
// Xiangqi traditional
if(**p == '[') {
oldp = ++(*p);
if(Match("--", p)) { // "[--" could be start of position diagram
- if(!Scan(']', p) && (*p)[-3] == '-' && (*p)[-2] == '-') return PositionDiagram;
+ if(!Scan(']', p) && (*p)[-3] == '-' && (*p)[-2] == '-') return PositionDiagram;
*p = oldp;
}
SkipWhite(p);
// ********* SAN Castings *************************************
if(**p == 'O' || **p == 'o' || **p == '0') {
int castlingType = 0;
- if(Match("O-O-O", p) || Match("o-o-o", p) || Match("0-0-0", p) ||
+ if(Match("O-O-O", p) || Match("o-o-o", p) || Match("0-0-0", p) ||
Match("OOO", p) || Match("ooo", p) || Match("000", p)) castlingType = 2;
else if(Match("O-O", p) || Match("o-o", p) || Match("0-0", p) ||
Match("OO", p) || Match("oo", p) || Match("00", p)) castlingType = 1;
* 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/.
+ * along with this program. If not, see http://www.gnu.org/licenses/.
*
* ------------------------------------------------------------------------
*/
#include "common.h"
#include "backend.h"
-Boolean GetArgValue(char *a);
+Boolean GetArgValue(char *a);
void
InitEngineUCI (const char *iniDir, ChessProgramState *cps)
/*
- * usystem.c -- X-free, but Unix-like code for XBoard front end
+ * usystem.c -- X-free, but Unix-like code for XBoard front end
*
* Copyright 1991 by Digital Equipment Corporation, Maynard,
* Massachusetts.
host, port, gai_strerror(error));
return ENOENT;
}
-
+
for (ai = ais; ai != NULL; ai = ai->ai_next) {
if ((s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) {
error = errno;
{
update_ics_width();
}
-
-
int MySearchPath P((char *installDir, char *name, char *fullname));
int MyGetFullPathName P((char *name, char *fullname));
void PlaySoundForColor P((ColorClass cc));
-
if(displ) DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
return;
}
-
#define TOPLEVEL 1 /* preference item; 1 = make popup windows toplevel */
-
XtSetValues(form2, args, j);
}
}
-
* 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/.
+ * along with this program. If not, see http://www.gnu.org/licenses/.
*
* ------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
XawTextGetSelectionPos(w, &index, &dummy);
FindMoveByCharIndex( index ); // [HGM] also does the actual moving to it, now
}
-
if(list[0] == NULL) return NULL; // avoid empty menus, as they cause crash
menu = XtCreatePopupShell(opt->name, simpleMenuWidgetClass, parent, NULL, 0);
- for (i=0; 1; i++)
+ for (i=0; 1; i++)
{
char *msg = fromList ? list[i] : mb[i].string;
if(!msg) break;
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
- XFlush(xDisplay);
+ XFlush(xDisplay);
XSync(xDisplay, False);
}
currentOption = dialogOptions[dlg=data>>16]; data &= 0xFFFF;
oldSh = shells[dlg]; shells[dlg] = sh; // bow to reality
if (data == 30000) { // cancel
- PopDown(dlg);
+ PopDown(dlg);
} else
if (data == 30001) { // save buttons imply OK
if(GenericReadout(currentOption, -1)) PopDown(dlg); // calls OK-proc after full readout, but no popdown if it returns false
XtSetArg(args[j], XtNdisplayCaret, False); j++;
XtSetArg(args[j], XtNresizable, True); j++;
XtSetArg(args[j], XtNinsertPosition, 9999); j++;
- XtSetArg(args[j], XtNstring, option[i].type==Spin || option[i].type==Fractional ? def :
+ XtSetArg(args[j], XtNstring, option[i].type==Spin || option[i].type==Fractional ? def :
engineDlg ? option[i].textValue : *(char**)option[i].target); j++;
edit = last;
option[i].handle = (void*)
{
Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, openName, openFP);
}
-
Copyright (C) 1996, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
NOTICE: The piece images distributed with ZIICS are
- copyrighted works of their original creators. Images
+ copyrighted works of their original creators. Images
converted with zic2xpm may not be redistributed without
the permission of the copyright holders. Do not contact
the authors of zic2xpm or of ZIICS itself to request
- permission.
+ permission.
NOTICE: The format of the ZIICS piece file was gleaned from
SHOWSETS.PAS, a part of ZIICS. Thanks to Andy McFarland
- (Zek on ICC) for making this source available! ZIICS is a
+ (Zek on ICC) for making this source available! ZIICS is a
completely separate and copyrighted work of Andy
McFarland. Use and distribution of ZIICS falls under the
ZIICS license, NOT the GNU General Public License.
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/.
size = Piece size.
Plus 4 files for the light & dark squares.
-
+
This means that you can extract multiple SIZES in one directory
without name clashes. Extracting two sets of the SAME
size in a directory will cause the second to overwrite
{
fputc( w, fp );
fputc( h, fp );
-
+
return 0;
}
unsigned char *lump, *p, *line;
long size;
z2xim *ent;
-
+
fpout = fopen( outname, "wb" );
if ( !fpout )
fatal( "Can't create output file.");
c = fgetc( fpin );
h = (fgetc(fpin) << 8) | c;
-
+
++w; ++h;
if ( w != W || h != H )
- fatal( "Bad header." );
+ fatal( "Bad header." );
size = vga_imagesize( w, h ) - 4;
lump = (unsigned char*)malloc( size );
write_xim_header( fpout, w, h );
p = lump;
-
+
/* Write XIM data */
for( i=0; i<h; ++i )
{
p = decode_line( line, p, w );
-
+
for( j=0; j<w; ++j )
{
ent = lookup_xim_color( line[j] );
fputc( ent->xval, fpout );
}
}
-
+
free( lump );
free( line );
fclose( fpout );
unsigned char *lump, *p, *line;
long size;
z2xpm *cv;
-
+
fpout = fopen( outname, "wb" );
if ( !fpout )
fatal( "Can't create output file.");
c = fgetc( fpin );
h = (fgetc(fpin) << 8) | c;
-
+
++w; ++h;
if ( w != W || h != H )
- fatal( "Bad header." );
+ fatal( "Bad header." );
size = vga_imagesize( w, h ) - 4;
lump = (unsigned char*)malloc( size );
write_xpm_header( fpout, w, h );
p = lump;
-
+
/* Write XPM data */
for( i=0; i<h; ++i )
{
p = decode_line( line, p, w );
-
+
fprintf( fpout, "\"" );
for( j=0; j<w; ++j )
{
}
fprintf( fpout, "};\n" );
-
+
free( lump );
free( line );
fclose( fpout );
char buf[BUFLEN];
src_name = filename;
-
+
fp = fopen( filename, "rb" );
if ( !fp )
fatal( "Can't open input file." );
-
+
/* Header is two ints -- Width then Height, x86 format */
c = fgetc( fp );
w = (fgetc(fp) << 8) | c;
c = fgetc( fp );
h = (fgetc(fp) << 8) | c;
-
+
++w; ++h;
if ( w != h )
printf("Creating XIM files...\n");
printf("File: %s, W=%d, H=%d\n", filename, w, h );
fseek( fp, 0, SEEK_SET );
-
+
/* Write .XIM files */
for( piece = 0; piece < nr_pieces; ++piece )
{
printf("%s ", pname[piece] );
-
+
for( kind = 0; kind < nr_kinds; ++kind )
{
printf( "." );
snprintf( buf, BUFLEN, "dsq%d.xim", w );
printf("\nDark Square" );
- create_piece_xim( buf, fp, w, h );
+ create_piece_xim( buf, fp, w, h );
printf("\n");
-
+
printf("Successfully converted!!\n" );
fclose( fp );
-
+
return 0;
}
char buf[BUFLEN];
src_name = filename;
-
+
fp = fopen( filename, "rb" );
if ( !fp )
fatal( "Can't open input file." );
-
+
/* Header is two ints -- Width then Height, x86 format */
c = fgetc( fp );
w = (fgetc(fp) << 8) | c;
c = fgetc( fp );
h = (fgetc(fp) << 8) | c;
-
+
++w; ++h;
if ( w != h )
printf(" (This set is %dx%d)\n", w, h );
exit(1);
}
-
+
printf("Creating XPM files...\n");
printf("File: %s, W=%d, H=%d\n", filename, w, h );
fseek( fp, 0, SEEK_SET );
-
+
/* Write .XPM files */
for( piece = 0; piece < nr_pieces; ++piece )
{
printf("%s ", pname[piece] );
-
+
for( kind = 0; kind < nr_kinds; ++kind )
{
printf( "." );
snprintf( buf, BUFLEN, "dsq%d.xpm", w );
printf("\nDark Square" );
- create_piece_xpm( buf, fp, w, h );
+ create_piece_xpm( buf, fp, w, h );
printf("\n");
-
+
printf("Successfully converted!!\n" );
fclose( fp );
-
+
return 0;
}
main (int argc, char **argv)
{
int i;
-
+
if ( argc < 2 )
{
printf("ZIC2XPM 2.01 - by Frank McIngvale (frankm@hiwaay.net)\n");
setbuf( stdout, NULL );
-
+
for( i=1; i<argc; ++i )
{
process_file_xpm( argv[i] );
process_file_xim( argv[i] );
}
-
+
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
"NOTICE: The piece images distributed with ZIICS are",
" copyrighted works of their original creators. Images",