Add UnloadEngine routine
[xboard.git] / xhistory.c
index fe48893..fc5a88d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xhistory.c -- Move list window, part of X front end for XBoard
  *
- * Copyright 2000, 2009, 2010 Free Software Foundation, Inc.
+ * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -67,6 +67,7 @@ extern char *getenv();
 #include "xboard.h"
 #include "xhistory.h"
 #include "gettext.h"
+#include "xevalgraph.h"
 
 #ifdef ENABLE_NLS
 # define  _(s) gettext (s)
@@ -122,7 +123,7 @@ HistoryPopDown(w, client_data, call_data)
   }
   j=0;
   XtSetArg(args[j], XtNleftBitmap, None); j++;
-  XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"),
+  XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Move History"),
                args, j);
 }
 
@@ -223,6 +224,7 @@ HistoryFill()
 
 void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){
   int i,b,m;
+  Widget scroll;
   if(hist){
     if(last >= hist->aNr) HistoryAlloc(last+_LL_);
     for(i=0;i<last;i++) {
@@ -233,10 +235,10 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){
            strncpy(hist->white[i/2+1], movelist[i], p-movelist[i]);
            hist->white[i/2+1][p-movelist[i]] = NULLCHAR;
          } else {
-           safeStrCpy(hist->white[i/2+1],movelist[i], sizeof(hist->white[i/2+1])/sizeof(hist->white[i/2+1][0]));
+           safeStrCpy(hist->white[i/2+1],movelist[i], MOVE_LEN);
          }
        } else {
-         safeStrCpy(hist->white[i/2+1],dots, sizeof(hist->white[i/2+1])/sizeof(hist->white[i/2+1][0]));
+         safeStrCpy(hist->white[i/2+1],dots, MOVE_LEN);
        }
       } else {
        if(movelist[i][0]) {
@@ -245,14 +247,14 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){
            strncpy(hist->black[i/2+1], movelist[i], p-movelist[i]);
            hist->black[i/2+1][p-movelist[i]] = NULLCHAR;
          } else {
-           safeStrCpy(hist->black[i/2+1],movelist[i], sizeof(hist->black[i/2+1])/sizeof(hist->black[i/2+1][0]));
+           safeStrCpy(hist->black[i/2+1],movelist[i], MOVE_LEN);
          }
        } else {
-         safeStrCpy(hist->black[i/2+1],"", sizeof(hist->black[i/2+1])/sizeof(hist->black[i/2+1][0]));
+         safeStrCpy(hist->black[i/2+1],"", MOVE_LEN);
        }
       }
     }
-    safeStrCpy(hist->black[last/2+1],"", sizeof(hist->black[last/2+1])/sizeof(hist->black[last/2+1][0]));
+    safeStrCpy(hist->black[last/2+1],"", MOVE_LEN);
     b=first/2;
     m=(last+3)/2-b;
     XawFormDoLayout(hist->vbox, False);
@@ -274,6 +276,13 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){
       if(current) XawListHighlight(hist->mvb, current/2+1);
       else XawListUnhighlight(hist->mvb);
     }
+    if(scroll = XtNameToWidget(hist->sh, "*form.viewport.vertical")) { // [HGM] always scroll to bottom
+      static char *params[3] = { "", "Forward", "FullLength" };
+      static XEvent event;
+      XtCallActionProc(scroll, "StartScroll", &event, params+1, 1);
+      XtCallActionProc(scroll, "NotifyScroll", &event, params+2, 1);
+      XtCallActionProc(scroll, "EndScroll", &event, params, 0);
+    }
   }
   EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed
 }
@@ -404,8 +413,8 @@ Widget HistoryCreate()
     CatchDeleteWindow(hist->sh, "HistoryPopDown");
 
     for(i=1;i<hist->aNr;i++){
-      safeStrCpy(hist->white[i],dots, sizeof(hist->white[i])/sizeof(hist->white[i][0]));
-      safeStrCpy(hist->black[i],"", sizeof(hist->black[i])/sizeof(hist->black[i][0]));
+      safeStrCpy(hist->white[i],dots, MOVE_LEN);
+      safeStrCpy(hist->black[i],"", MOVE_LEN);
      }
 
     if(wpMoveHistory.width > 0) {
@@ -441,7 +450,7 @@ HistoryPopUp()
 
   j=0;
   XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
-  XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"),
+  XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Move History"),
                args, j);
   hist->Up=True;
 }