Merge commit 'v4.4.1.20091019' into gtk
[xboard.git] / xhistory.c
index c247acb..1a29626 100644 (file)
-/*\r
- * xhistory.c -- Move list window, part of X front end for XBoard\r
- * $Id$\r
- *\r
- * Copyright 2000,2009 Free Software Foundation, Inc.\r
- * ------------------------------------------------------------------------\r
- *\r
- * GNU XBoard is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or (at\r
- * your option) any later version.\r
- *\r
- * GNU XBoard is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
- *\r
- *------------------------------------------------------------------------\r
- ** See the file ChangeLog for a revision history.  */\r
-\r
-#include "config.h"\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <sys/types.h>\r
-\r
-#if STDC_HEADERS\r
-# include <stdlib.h>\r
-# include <string.h>\r
-#else /* not STDC_HEADERS */\r
-extern char *getenv();\r
-# if HAVE_STRING_H\r
-#  include <string.h>\r
-# else /* not HAVE_STRING_H */\r
-#  include <strings.h>\r
-# endif /* not HAVE_STRING_H */\r
-#endif /* not STDC_HEADERS */\r
-\r
-#if HAVE_UNISTD_H\r
-# include <unistd.h>\r
-#endif\r
-\r
-#include <X11/Intrinsic.h>\r
-#include <X11/StringDefs.h>\r
-#include <X11/Shell.h>\r
-#include <X11/Xaw/Dialog.h>\r
-#include <X11/Xaw/Form.h>\r
-#include <X11/Xaw/List.h>\r
-#include <X11/Xaw/Label.h>\r
-#include <X11/Xaw/SimpleMenu.h>\r
-#include <X11/Xaw/SmeBSB.h>\r
-#include <X11/Xaw/SmeLine.h>\r
-#include <X11/Xaw/Box.h>\r
-#include <X11/Xaw/Paned.h>\r
-#include <X11/Xaw/MenuButton.h>\r
-#include <X11/cursorfont.h>\r
-#include <X11/Xaw/Text.h>\r
-#include <X11/Xaw/AsciiText.h>\r
-#include <X11/Xaw/Viewport.h>\r
-\r
-#include "common.h"\r
-#include "frontend.h"\r
-#include "backend.h"\r
-#include "xboard.h"\r
-#include "xhistory.h"\r
-#include "gettext.h"\r
-\r
-#ifdef ENABLE_NLS\r
-# define  _(s) gettext (s)\r
-# define N_(s) gettext_noop (s)\r
-#else\r
-# define  _(s) (s)\r
-# define N_(s)  s\r
-#endif\r
-\r
-#define _LL_ 100\r
-\r
-extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;\r
-extern Display *xDisplay;\r
-extern int squareSize;\r
-extern Pixmap xMarkPixmap;\r
-extern char *layoutName;\r
-\r
-struct History{\r
-  String *Nr,*white,*black;\r
-  int     aNr;  /* space actually alocated */\r
-  Widget mvn,mvw,mvb,vbox,viewport,sh;\r
-  char Up;\r
-};\r
-\r
-struct History *hist=0;\r
-String dots=" ... ";\r
-Position gameHistoryX, gameHistoryY;\r
-\r
-void\r
-HistoryPopDown(w, client_data, call_data)\r
-     Widget w;\r
-     XtPointer client_data, call_data;\r
-{\r
-  Arg args[16];\r
-  int j;\r
-  if(hist) {\r
-    // [HGM] remember old position\r
-    j = 0;\r
-    XtSetArg(args[j], XtNx, &gameHistoryX);  j++;\r
-    XtSetArg(args[j], XtNy, &gameHistoryY);  j++;\r
-    XtGetValues(hist->sh, args, j);\r
-\r
-    XtPopdown(hist->sh);\r
-    hist->Up=False;\r
-  }\r
-  j=0;\r
-  XtSetArg(args[j], XtNleftBitmap, None); j++;\r
-  XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"),\r
-               args, j);\r
-}\r
-\r
-void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)\r
-{\r
-    int to;\r
-    XawListReturnStruct *R = (XawListReturnStruct *) call_data;\r
-    if (w == hist->mvn || w == hist->mvw) {\r
-      to=2*R->list_index-1;\r
-      ToNrEvent(to);\r
-    }\r
-    else if (w == hist->mvb) {\r
-      to=2*R->list_index;\r
-      ToNrEvent(to);\r
-    }\r
-}\r
-\r
-void HistoryAlloc(int len){\r
-  int i;\r
-  if(hist){\r
-    free(hist->Nr[0]);free(hist->white[0]);free(hist->black[0]);\r
-    free(hist->Nr);free(hist->white);free(hist->black);\r
-  }\r
-  else{\r
-    hist=(struct History*)malloc(sizeof(struct History));\r
-  }\r
-    hist->aNr=len;\r
-    hist->Nr=(String*)malloc(hist->aNr*sizeof(String*));\r
-    hist->white=(String*)malloc(hist->aNr*sizeof(String*));\r
-    hist->black=(String*)malloc(hist->aNr*sizeof(String*));\r
-\r
-    hist->Nr[0]=(String)malloc(hist->aNr*6);\r
-    hist->white[0]=(String)malloc(hist->aNr*MOVE_LEN);\r
-    hist->black[0]=(String)malloc(hist->aNr*MOVE_LEN);\r
-\r
-      sprintf(hist->Nr[0],"    ");\r
-      sprintf(hist->white[0],_("White "));\r
-      sprintf(hist->black[0],_("Black "));\r
-    for(i=1;i<hist->aNr;i++){\r
-      hist->Nr[i]= hist->Nr[i-1]+6;\r
-      hist->white[i]= hist->white[i-1]+MOVE_LEN;\r
-      hist->black[i]= hist->black[i-1]+MOVE_LEN;\r
-      sprintf(hist->Nr[i],"%i.",i);\r
-      sprintf(hist->white[i],"-----");\r
-      sprintf(hist->black[i],"-----");\r
-     }\r
-}\r
-\r
-\r
-#if 1\r
-/* Find empty space inside vbox form widget and redistribute it amongst\r
-   the list widgets inside it. */\r
-/* This version sort of works */\r
-void\r
-HistoryFill()\r
-{\r
-  Dimension w, bw;\r
-  long extra;\r
-  Position x, x1, x2;\r
-  int j, dd;\r
-  Arg args[16];\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNx, &x);  j++;\r
-  XtSetArg(args[j], XtNwidth, &w);  j++;\r
-  XtSetArg(args[j], XtNborderWidth, &bw);  j++;\r
-  XtGetValues(hist->mvb, args, j);\r
-  x1 = x + w + 2*bw;\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, &w);  j++;\r
-  XtSetArg(args[j], XtNdefaultDistance, &dd);  j++;\r
-  XtGetValues(hist->vbox, args, j);\r
-  x2 = w - dd;\r
-\r
-  extra = x2 - x1;\r
-  if (extra < 0) {\r
-    extra = -((-extra)/2);\r
-  } else {\r
-    extra = extra/2;\r
-  }\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, &w);  j++;\r
-  XtGetValues(hist->mvw, args, j);\r
-  w += extra;\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, w);  j++;\r
-  XtSetValues(hist->mvw, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, &w);  j++;\r
-  XtGetValues(hist->mvb, args, j);\r
-  w += extra;\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, w);  j++;\r
-  XtSetValues(hist->mvb, args, j);\r
-}\r
-#else\r
-/* Find empty space inside vbox form widget and redistribute it amongst\r
-   the list widgets inside it. */\r
-/* This version doesn't work */\r
-void\r
-HistoryFill()\r
-{\r
-  Arg args[16];\r
-  Dimension fw, niw, wiw, biw, nbw, wbw, bbw;\r
-  int j, nl, wl, bl, fdd;\r
-  long extra;\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, &fw);  j++;\r
-  XtSetArg(args[j], XtNdefaultDistance, &fdd);  j++;\r
-  XtGetValues(hist->vbox, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNlongest, &nl);  j++;\r
-  XtSetArg(args[j], XtNinternalWidth, &niw);  j++;\r
-  XtSetArg(args[j], XtNborderWidth, &nbw);  j++;\r
-  XtGetValues(hist->mvn, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNlongest, &wl);  j++;\r
-  XtSetArg(args[j], XtNinternalWidth, &wiw);  j++;\r
-  XtSetArg(args[j], XtNborderWidth, &wbw);  j++;\r
-  XtGetValues(hist->mvw, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNlongest, &bl);  j++;\r
-  XtSetArg(args[j], XtNinternalWidth, &biw);  j++;\r
-  XtSetArg(args[j], XtNborderWidth, &bbw);  j++;\r
-  XtGetValues(hist->mvb, args, j);\r
-\r
-  extra = fw - 4*fdd -\r
-    nl - 1 - 2*niw - 2*nbw - wl - 2*wiw - 2*wbw - bl - 2*biw - 2*bbw;\r
-  if (extra < 0) extra = 0;\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, nl + 1 + 2*niw);  j++;\r
-  XtSetValues(hist->mvn, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, wl + 2*wiw + extra/2);  j++;\r
-  XtSetValues(hist->mvw, args, j);\r
-\r
-  j = 0;\r
-  XtSetArg(args[j], XtNwidth, bl + 2*biw + extra/2);  j++;\r
-  XtSetValues(hist->mvb, args, j);\r
-}\r
-#endif\r
-\r
-void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){\r
-  int i,b,m;\r
-  if(hist){\r
-    if(last >= hist->aNr) HistoryAlloc(last+_LL_);\r
-    for(i=0;i<last;i++) {\r
-      if((i%2)==0) {\r
-       if(movelist[i][0]) {\r
-         char* p = strchr(movelist[i], ' ');\r
-         if (p) {\r
-           strncpy(hist->white[i/2+1], movelist[i], p-movelist[i]);\r
-           hist->white[i/2+1][p-movelist[i]] = NULLCHAR;\r
-         } else {\r
-           strcpy(hist->white[i/2+1],movelist[i]);\r
-         }\r
-       } else {\r
-         strcpy(hist->white[i/2+1],dots);\r
-       }\r
-      } else {\r
-       if(movelist[i][0]) {\r
-         char* p = strchr(movelist[i], ' ');\r
-         if (p) {\r
-           strncpy(hist->black[i/2+1], movelist[i], p-movelist[i]);\r
-           hist->black[i/2+1][p-movelist[i]] = NULLCHAR;\r
-         } else {\r
-           strcpy(hist->black[i/2+1],movelist[i]);\r
-         }\r
-       } else {\r
-         strcpy(hist->black[i/2+1],"");\r
-       }\r
-      }\r
-    }\r
-    strcpy(hist->black[last/2+1],"");\r
-    b=first/2;\r
-    m=(last+3)/2-b;\r
-    XawFormDoLayout(hist->vbox, False);\r
-    XawListChange(hist->mvn,hist->Nr+b,m,0,True);\r
-    XawListChange(hist->mvw,hist->white+b,m,0,True);\r
-    XawListChange(hist->mvb,hist->black+b,m,0,True);\r
-    HistoryFill();\r
-    XawFormDoLayout(hist->vbox, True);\r
-    if(current<0){\r
-      XawListUnhighlight(hist->mvw);\r
-      XawListUnhighlight(hist->mvb);\r
-    }\r
-    else if((current%2)==0){\r
-      XawListHighlight(hist->mvw, current/2+1);\r
-      XawListUnhighlight(hist->mvb);\r
-    }\r
-    else{\r
-      XawListUnhighlight(hist->mvw);\r
-      if(current) XawListHighlight(hist->mvb, current/2+1);\r
-      else XawListUnhighlight(hist->mvb);\r
-    }\r
-  }\r
-}\r
-\r
-Widget HistoryCreate()\r
-{\r
-    Arg args[16];\r
-    int i,j;\r
-\r
-    Widget layout,form,b_close;\r
-    String trstr=\r
-             "<Key>Up: BackwardProc() \n \\r
-             <Key>Left: BackwardProc() \n \\r
-             <Key>Down: ForwardProc() \n \\r
-             <Key>Right: ForwardProc() \n";\r
-    /*--- allocate memory for move-strings ---*/\r
-    HistoryAlloc(_LL_);\r
-\r
-    /*-------- create the widgets ---------------*/\r
-    j = 0;\r
-    XtSetArg(args[j], XtNresizable, True);  j++;\r
-    XtSetArg(args[j], XtNallowShellResize, True);  j++;\r
-#if TOPLEVEL\r
-    hist->sh =\r
-      XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,\r
-                        shellWidget, args, j);\r
-#else\r
-    hist->sh =\r
-      XtCreatePopupShell(_("Move list"), transientShellWidgetClass,\r
-                        shellWidget, args, j);\r
-#endif\r
-    j = 0;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNdefaultDistance, 0);  j++;\r
-      layout =\r
-      XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,\r
-                           args, j);\r
-\r
-    j = 0;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNresizable, True);  j++;\r
-\r
-    form =\r
-      XtCreateManagedWidget("form", formWidgetClass, layout, args, j);\r
-     j=0;\r
-\r
-    j = 0;\r
-\r
-    XtSetArg(args[j], XtNtop, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;\r
-    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;\r
-    XtSetArg(args[j], XtNright, XtChainRight);  j++;\r
-\r
-    XtSetArg(args[j], XtNborderWidth, 1); j++;\r
-    XtSetArg(args[j], XtNresizable, False);  j++;\r
-    XtSetArg(args[j], XtNallowVert, True); j++;\r
-    XtSetArg(args[j], XtNallowHoriz, True);  j++;\r
-    XtSetArg(args[j], XtNforceBars, False); j++;\r
-    XtSetArg(args[j], XtNheight, 280); j++;\r
-    hist->viewport =\r
-      XtCreateManagedWidget("viewport", viewportWidgetClass,\r
-                           form, args, j);\r
-    j=0;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;\r
-    hist->vbox =\r
-      XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);\r
-\r
-    j=0;\r
-    XtSetArg(args[j], XtNtop, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;\r
-    XtSetArg(args[j], XtNright, XtChainLeft);  j++;\r
-\r
-    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;\r
-    XtSetArg(args[j], XtNforceColumns, True);  j++;\r
-    XtSetArg(args[j], XtNverticalList, True);  j++;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNresizable,True);j++;\r
-    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;\r
-    hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,\r
-                                     hist->vbox, args, j);\r
-    XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);\r
-\r
-    j=0;\r
-    XtSetArg(args[j], XtNtop, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;\r
-    XtSetArg(args[j], XtNright, XtRubber);  j++;\r
-\r
-    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;\r
-    XtSetArg(args[j], XtNforceColumns, True);  j++;\r
-    XtSetArg(args[j], XtNverticalList, True);  j++;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNresizable,True);j++;\r
-    XtSetArg(args[j], XtNfromHoriz, hist->mvn);  j++;\r
-    hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,\r
-                                     hist->vbox, args, j);\r
-    XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);\r
-\r
-    j=0;\r
-    XtSetArg(args[j], XtNtop, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;\r
-    XtSetArg(args[j], XtNleft, XtRubber);  j++;\r
-    XtSetArg(args[j], XtNright,  XtRubber);  j++;\r
-\r
-    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;\r
-    XtSetArg(args[j], XtNforceColumns, True);  j++;\r
-    XtSetArg(args[j], XtNverticalList, True);  j++;\r
-    XtSetArg(args[j], XtNborderWidth, 0); j++;\r
-    XtSetArg(args[j], XtNresizable,True);j++;\r
-    XtSetArg(args[j], XtNfromHoriz, hist->mvw);  j++;\r
-    hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,\r
-                                     hist->vbox, args, j);\r
-    XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);\r
-\r
-    j=0;\r
-    XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;\r
-    XtSetArg(args[j], XtNtop, XtChainBottom);  j++;\r
-    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;\r
-    XtSetArg(args[j], XtNright, XtChainLeft);  j++;\r
-    XtSetArg(args[j], XtNfromVert, hist->viewport);  j++;\r
-    b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,\r
-                                  form, args, j);\r
-    XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);\r
-\r
-    XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));\r
-\r
-    XtRealizeWidget(hist->sh);\r
-    CatchDeleteWindow(hist->sh, "HistoryPopDown");\r
-\r
-    for(i=1;i<hist->aNr;i++){\r
-      strcpy(hist->white[i],dots);\r
-      strcpy(hist->black[i],"");\r
-     }\r
-\r
-    return hist->sh;\r
-}\r
-\r
-void\r
-HistoryPopUp()\r
-{\r
-  Arg args[16];\r
-  int j;\r
-\r
-  if(!hist) HistoryCreate();\r
-\r
-  XtPopup(hist->sh, XtGrabNone);\r
-\r
-  // [HGM] restore old position\r
-  j = 0;\r
-  XtSetArg(args[j], XtNx, gameHistoryX);  j++;\r
-  XtSetArg(args[j], XtNy, gameHistoryY);  j++;\r
-  XtSetValues(hist->sh, args, j);\r
-\r
-  j=0;\r
-  XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;\r
-  XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"),\r
-               args, j);\r
-  hist->Up=True;\r
-}\r
-\r
-\r
-void\r
-HistoryShowProc(w, event, prms, nprms)\r
-     Widget w;\r
-     XEvent *event;\r
-     String *prms;\r
-     Cardinal *nprms;\r
-{\r
-  if (!hist) {\r
-    HistoryCreate();\r
-    HistoryPopUp();\r
-  } else if (hist->Up) {\r
-    HistoryPopDown(0,0,0);\r
-  } else {\r
-    HistoryPopUp();\r
-  }\r
-  ToNrEvent(currentMove);\r
-}\r
-\r
+/*
+ * xhistory.c -- Move list window, part of X front end for XBoard
+ *
+ * Copyright 2000,2009 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.  */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#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_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "common.h"
+#include "frontend.h"
+#include "backend.h"
+#include "xboard.h"
+#include "xhistory.h"
+#include "gettext.h"
+
+#ifdef ENABLE_NLS
+# define  _(s) gettext (s)
+# define N_(s) gettext_noop (s)
+#else
+# define  _(s) (s)
+# define N_(s)  s
+#endif
+
+extern GtkWidget               *GUI_History;
+extern GtkListStore            *LIST_MoveHistory;
+
+String dots=" ... ";
+
+void
+HistoryPopDown(object, user_data)
+     GtkObject *object;
+     gpointer user_data;
+{
+  gtk_widget_hide (GUI_History);
+  return;
+}
+
+void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
+{
+    int to;
+    /*
+    XawListReturnStruct *R = (XawListReturnStruct *) call_data;
+    if (w == hist->mvn || w == hist->mvw) {
+      to=2*R->list_index-1;
+      ToNrEvent(to);
+    }
+    else if (w == hist->mvb) {
+      to=2*R->list_index;
+      ToNrEvent(to);
+    }
+    */
+}
+
+
+void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
+{
+  int i,b,m;
+  char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
+  GtkTreeIter iter;
+
+  /* TODO need to add highlights for current move */
+  /* TODO need to add navigation by keyboard or mouse (double click on move) */
+
+  /* first clear everything, do we need this? */
+  gtk_list_store_clear(LIST_MoveHistory);
+
+  /* copy move list into history window */
+
+  /* go through all moves */
+  for(i=0;i<last;i++) 
+    {
+      /* test if there is a move */
+      if(movelist[i][0]) 
+       {
+         /* only copy everything before a  ' ' */
+         char* p = strchr(movelist[i], ' ');
+         if (p) 
+           {
+             strncpy(move, movelist[i], p-movelist[i]);
+             move[p-movelist[i]] = NULLCHAR;
+           } 
+         else 
+           {
+             strcpy(move,movelist[i]);
+           }
+       } 
+      else
+       strcpy(move,dots);
+      
+      if((i%2)==0) 
+       {
+         /* white move */
+         strcpy(movewhite,move);
+       }
+      else
+       {
+         /* black move */
+         strcpy(moveblack,move);
+
+         /* save move */
+         gtk_list_store_append (LIST_MoveHistory, &iter);
+         gtk_list_store_set (LIST_MoveHistory, &iter,
+                             0, i,
+                             1, movewhite,
+                             2, moveblack,
+                             -1);
+
+         strcpy(movewhite,"");
+         strcpy(moveblack,"");
+       };
+    }
+  /* check if ther is a white move left */
+  if(movewhite[0])
+    {
+      i++;
+      strcpy(moveblack,"");
+      /* save move */
+      gtk_list_store_append (LIST_MoveHistory, &iter);
+      gtk_list_store_set (LIST_MoveHistory, &iter,
+                         0, i,
+                         1, movewhite,
+                         2, moveblack,
+                         -1);
+    };
+  
+  return;
+}
+
+void HistoryCreate()
+{
+    String trstr=
+             "<Key>Up: BackwardProc() \n \
+             <Key>Left: BackwardProc() \n \
+             <Key>Down: ForwardProc() \n \
+             <Key>Right: ForwardProc() \n";
+
+    return;
+}
+
+void
+HistoryPopUp()
+{
+  //  if(!hist) HistoryCreate();
+
+  gtk_widget_show (GUI_History);
+  
+  return;
+}
+
+
+void
+HistoryShowProc(object, user_data)
+     GtkObject *object;
+     gpointer user_data;
+{
+  HistoryCreate();
+  HistoryPopUp();
+  //TODO:  ToNrEvent(currentMove);
+
+  return;
+}
+