2 * xhistory.c -- Move list window, part of X front end for XBoard
4 * Copyright 2000,2009 Free Software Foundation, Inc.
5 * ------------------------------------------------------------------------
7 * GNU XBoard is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
12 * GNU XBoard is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/. *
20 *------------------------------------------------------------------------
21 ** See the file ChangeLog for a revision history. */
29 #include <sys/types.h>
34 #else /* not STDC_HEADERS */
35 extern char *getenv();
38 # else /* not HAVE_STRING_H */
40 # endif /* not HAVE_STRING_H */
41 #endif /* not STDC_HEADERS */
55 # define _(s) gettext (s)
56 # define N_(s) gettext_noop (s)
62 extern GtkWidget *GUI_History;
63 extern GtkListStore *LIST_MoveHistory;
66 Position gameHistoryX, gameHistoryY;
67 Dimension gameHistoryW, gameHistoryH;
70 HistoryPopDown(object, user_data)
74 /* hides the history window */
76 gtk_widget_hide (GUI_History);
80 void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
84 XawListReturnStruct *R = (XawListReturnStruct *) call_data;
85 if (w == hist->mvn || w == hist->mvw) {
89 else if (w == hist->mvb) {
97 void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
100 char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
103 /* TODO need to add highlights for current move */
104 /* TODO need to add navigation by keyboard or mouse (double click on move) */
106 /* first clear everything, do we need this? */
107 gtk_list_store_clear(LIST_MoveHistory);
109 /* copy move list into history window */
111 /* go through all moves */
114 /* test if there is a move */
117 /* only copy everything before a ' ' */
118 char* p = strchr(movelist[i], ' ');
121 strncpy(move, movelist[i], p-movelist[i]);
122 move[p-movelist[i]] = NULLCHAR;
126 strcpy(move,movelist[i]);
135 strcpy(movewhite,move);
140 strcpy(moveblack,move);
143 gtk_list_store_append (LIST_MoveHistory, &iter);
144 gtk_list_store_set (LIST_MoveHistory, &iter,
150 strcpy(movewhite,"");
151 strcpy(moveblack,"");
155 /* check if there is a white move left */
159 strcpy(moveblack,"");
161 gtk_list_store_append (LIST_MoveHistory, &iter);
162 gtk_list_store_set (LIST_MoveHistory, &iter,
170 // EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed
178 "<Key>Up: BackwardProc() \n \
179 <Key>Left: BackwardProc() \n \
180 <Key>Down: ForwardProc() \n \
181 <Key>Right: ForwardProc() \n";
184 // if(wpMoveHistory.width > 0) {
185 // gameHistoryW = wpMoveHistory.width;
186 // gameHistoryH = wpMoveHistory.height;
187 // gameHistoryX = wpMoveHistory.x;
188 // gameHistoryY = wpMoveHistory.y;
191 // // [HGM] restore old position
192 // if(gameHistoryW > 0) {
194 // XtSetArg(args[j], XtNx, gameHistoryX); j++;
195 // XtSetArg(args[j], XtNy, gameHistoryY); j++;
196 // XtSetArg(args[j], XtNwidth, gameHistoryW); j++;
197 // XtSetArg(args[j], XtNheight, gameHistoryH); j++;
198 // XtSetValues(hist->sh, args, j);
205 /* show history window */
207 gtk_widget_show (GUI_History);
213 HistoryShowProc(object, user_data)
219 //TODO: ToNrEvent(currentMove);
227 /* return status of history window */
229 return gtk_widget_get_visible (GUI_History);