changes from Alessandro Scotti from 20060129
[xboard.git] / winboard / whistory.c
index ba69a63..60af898 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Move history for WinBoard
  *
- * Author: Alessandro Scotti
+ * Author: Alessandro Scotti (Dec 2005)
  *
  * ------------------------------------------------------------------------
  * This program is free software; you can redistribute it and/or modify
@@ -53,6 +53,8 @@ extern HWND hwndMain;
 
 extern WindowPlacement wpMoveHistory;
 
+extern BoardSize boardSize;
+
 /* Module globals */
 typedef char MoveHistoryString[ MOVE_LEN*2 ];
 
@@ -60,6 +62,8 @@ static int lastFirst = 0;
 static int lastLast = 0;
 static int lastCurrent = -1;
 
+static char lastLastMove[ MOVE_LEN ];
+
 static MoveHistoryString * currMovelist;
 static ChessProgramStats_Move * currPvInfo;
 static int currFirst = 0;
@@ -125,6 +129,13 @@ static BOOL OnlyCurrentPositionChanged()
         TRUE )
     {
         result = TRUE;
+
+        /* Special case: last move changed */
+        if( currCurrent == currLast-1 ) {
+            if( strcmp( currMovelist[currCurrent], lastLastMove ) != 0 ) {
+                result = FALSE;
+            }
+        }
     }
 
     return result;
@@ -214,7 +225,7 @@ static VOID AppendMoveToMemo( int index )
 
     /* 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 );
@@ -245,6 +256,11 @@ static void MemoContentUpdated()
     lastFirst = currFirst;
     lastLast = currLast;
     lastCurrent = currCurrent;
+    lastLastMove[0] = '\0';
+
+    if( lastLast > 0 ) {
+        strcpy( lastLastMove, SavePart( currMovelist[lastLast-1] ) );
+    }
 
     /* Deselect any text, move caret to end of memo */
     if( currCurrent >= 0 ) {
@@ -288,6 +304,9 @@ LRESULT CALLBACK HistoryDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPAR
 
             SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );
 
+            /* Set font */
+           SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));
+
             /* Restore window placement */
             RestoreWindowPlacement( hDlg, &wpMoveHistory );
         }