/*
* xgamelist.c -- Game list window, part of X front end for XBoard
*
- * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc.
+ * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
"<Btn1Up>(2): LoadSelectedProc(0) \n \
<Key>Home: LoadSelectedProc(-2) \n \
<Key>End: LoadSelectedProc(2) \n \
+ Ctrl<Key>Up: LoadSelectedProc(-3) \n \
+ Ctrl<Key>Down: LoadSelectedProc(3) \n \
<Key>Up: LoadSelectedProc(-1) \n \
<Key>Down: LoadSelectedProc(1) \n \
<Key>Left: LoadSelectedProc(-1) \n \
static GameListClosure *glc = NULL;
Widget
-GameListCreate(name, callback, client_data)
- char *name;
- XtCallbackProc callback;
- XtPointer client_data;
+GameListCreate (char *name, XtCallbackProc callback, XtPointer client_data)
{
Arg args[16];
Widget shell, form, viewport, listwidg, layout, label;
return shell;
}
+extern int soughtCounts[];
+extern Board soughtBoard;
+
static int
-GameListPrepare(int byPos)
+GameListPrepare (int byPos)
{ // [HGM] filter: put in separate routine, to make callable from call-back
int nstrings;
ListGame *lg;
char **st, *line;
+ TimeMark t, t2;
+ GetTimeMark(&t);
if(st = glc->strings) while(*st) free(*st++);
nstrings = ((ListGame *) gameList.tailPred)->number;
glc->strings = (char **) malloc((nstrings + 1) * sizeof(char *));
st = glc->strings;
lg = (ListGame *) gameList.head;
listLength = wins = losses = draws = 0;
+ if(byPos) InitSearch();
while (nstrings--) {
int pos = -1;
line = GameListLine(lg->number, &lg->gameInfo);
lg->position = pos;
lg = (ListGame *) lg->node.succ;
}
+GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t));
DisplayTitle("XBoard");
*st = NULL;
return listLength;
}
static char *list[1003];
+int listEnd;
static void
-GameListReplace(int page)
+GameListReplace (int page)
{
// filter: put in separate routine, to make callable from call-back
Widget listwidg;
int i;
if(page) *st++ = _("previous page"); else if(listLength > 1000) *st++ = "";
- for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) break;
+ for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) { st--; break; }
+ listEnd = st - list;
if(page + 1000 <= listLength) *st++ = _("next page");
*st = NULL;
XawListChange(listwidg, list, 0, 0, True);
XtSetValues(listwidg, &arg, 1);
XawListHighlight(listwidg, 0);
- snprintf(buf, MSG_SIZ, "%s- %d/%d games (%d-%d-%d)", glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
+ snprintf(buf, MSG_SIZ, _("%s - %d/%d games (%d-%d-%d)"), glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
XtSetArg(arg, XtNtitle, buf);
XtSetValues(glc->shell, &arg, 1);
}
void
-GameListCallback(w, client_data, call_data)
- Widget w;
- XtPointer client_data, call_data;
+GameListCallback (Widget w, XtPointer client_data, XtPointer call_data)
{
String name;
Arg args[16];
}
void
-GameListPopUp(fp, filename)
- FILE *fp;
- char *filename;
+GameListPopUp (FILE *fp, char *filename)
{
Arg args[16];
int j;
if (glc == NULL) {
glc = (GameListClosure *) calloc(1, sizeof(GameListClosure));
glc->x = glc->y = -1;
+ glc->filename = NULL;
+ glc->shell = NULL;
}
GameListPrepare(False); // [HGM] filter: code put in separate routine
if (glc->filename != NULL) free(glc->filename);
glc->filename = StrSave(filename);
-
if (glc->shell == NULL) {
glc->shell = GameListCreate(filename, GameListCallback, glc);
} else {
}
void
-GameListDestroy()
+GameListDestroy ()
{
if (glc == NULL) return;
GameListPopDown();
}
void
-ShowGameListProc(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
+ShowGameListProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{
Arg args[16];
int j;
}
void
-LoadSelectedProc(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
+LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{
Widget listwidg;
XawListReturnStruct *rs;
}
if(direction != 0) {
+ int doLoad = abs(direction) > 2;
+ if(doLoad) direction /= 3;
index += direction;
if(direction == -2) index = 0;
- if(direction == 2) index = listLength-1;
- if(index < 0 || index >= listLength) return;
+ if(direction == 2) index = listEnd-1;
+ if(index < 0 || index >= listEnd) return;
XawListHighlight(listwidg, index);
- return;
+ if(!doLoad) return;
}
index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
if (cmailMsgLoaded) {
CmailLoadGame(glc->fp, index + 1, glc->filename, True);
} else {
LoadGame(glc->fp, index + 1, glc->filename, True);
+ XSync(xDisplay, False);
+ XSetInputFocus(xDisplay, XtWindow(boardWidget), RevertToPointerRoot, CurrentTime);
}
}
void
-SetFilterProc(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
+SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{
Arg args[16];
String name;
}
void
-GameListPopDown()
+GameListPopDown ()
{
Arg args[16];
int j;
}
void
-GameListHighlight(index)
- int index;
+GameListHighlight (int index)
{
Widget listwidg;
int i=0; char **st;
}
Boolean
-GameListIsUp()
+GameListIsUp ()
{
return glc && glc->up;
}
-int SaveGameListAsText(FILE *f)
+int
+SaveGameListAsText (FILE *f)
{
ListGame * lg = (ListGame *) gameList.head;
int nItem;
if( !glc || ((ListGame *) gameList.tailPred)->number <= 0 ) {
- DisplayError("Game list not loaded or empty", 0);
+ DisplayError(_("Game list not loaded or empty"), 0);
return False;
}
char *strings[20];
int stringPtr;
-void GLT_ClearList()
+void
+GLT_ClearList ()
{
strings[0] = NULL;
stringPtr = 0;
}
-void GLT_AddToList(char *name)
+void
+GLT_AddToList (char *name)
{
strings[stringPtr++] = name;
strings[stringPtr] = NULL;
}
-Boolean GLT_GetFromList(int index, char *name)
+Boolean
+GLT_GetFromList (int index, char *name)
{
safeStrCpy(name, strings[index], MSG_SIZ);
return TRUE;
}
-void GLT_DeSelectList()
+void
+GLT_DeSelectList ()
{
XawListChange(listwidg, strings, 0, 0, True);
XawListHighlight(listwidg, 0);
}
void
-GameListOptionsPopDown()
+GameListOptionsPopDown ()
{
if (gameListOptShell == NULL) return;
}
void
-GameListOptionsCallback(w, client_data, call_data)
- Widget w;
- XtPointer client_data, call_data;
+GameListOptionsCallback (Widget w, XtPointer client_data, XtPointer call_data)
{
String name;
Arg args[16];
}
Widget
-GameListOptionsCreate()
+GameListOptionsCreate ()
{
Arg args[16];
Widget shell, form, viewport, layout;
XtSetArg(args[j], XtNresizable, True); j++;
XtSetArg(args[j], XtNallowShellResize, True); j++;
shell = gameListOptShell =
- XtCreatePopupShell("Game-list options", transientShellWidgetClass,
+ XtCreatePopupShell(_("Game-list options"), transientShellWidgetClass,
shellWidget, args, j);
layout =
XtCreateManagedWidget(layoutName, formWidgetClass, shell,
}
void
-GameListOptionsPopUp(Widget w, XEvent *event, String *prms, Cardinal *nprms)
+GameListOptionsPopUp (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{
if (gameListOptShell == NULL)
gameListOptShell = GameListOptionsCreate();