projects
/
xboard.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed whitespace error in configure.ac for os x
[xboard.git]
/
history.c
diff --git
a/history.c
b/history.c
index
4598799
..
ca87aa4
100644
(file)
--- a/
history.c
+++ b/
history.c
@@
-6,6
+6,8
@@
*
* Copyright 2005 Alessandro Scotti
*
*
* Copyright 2005 Alessandro Scotti
*
+ * Enhancements Copyright 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ *
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
@@
-19,7
+21,7
@@
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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/.
+ * along with this program. If not, see http://www.gnu.org/licenses/.
*
* ------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
*
* ------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
@@
-28,7
+30,6
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <malloc.h>
#include <string.h>
#include "common.h"
#include <string.h>
#include "common.h"
@@
-51,6
+52,7
@@
typedef char MoveHistoryString[ MOVE_LEN*2 ];
static int lastFirst = 0;
static int lastLast = 0;
static int lastCurrent = -1;
static int lastFirst = 0;
static int lastLast = 0;
static int lastCurrent = -1;
+static int lastGames;
static char lastLastMove[ MOVE_LEN ];
static char lastLastMove[ MOVE_LEN ];
@@
-70,17
+72,18
@@
static HistoryMove histMoves[ MAX_MOVES ];
/* Note: in the following code a "Memo" is a Rich Edit control (it's Delphi lingo) */
// back-end after replacing Windows data-types by equivalents
/* Note: in the following code a "Memo" is a Rich Edit control (it's Delphi lingo) */
// back-end after replacing Windows data-types by equivalents
-static Boolean OnlyCurrentPositionChanged()
+static Boolean
+OnlyCurrentPositionChanged ()
{
Boolean result = FALSE;
if( lastFirst >= 0 &&
lastLast >= lastFirst &&
{
Boolean result = FALSE;
if( lastFirst >= 0 &&
lastLast >= lastFirst &&
- lastCurrent >= lastFirst &&
+ lastCurrent >= lastFirst &&
currFirst == lastFirst &&
currLast == lastLast &&
currCurrent >= 0 &&
currFirst == lastFirst &&
currLast == lastLast &&
currCurrent >= 0 &&
-
TRUE
)
+
lastGames == storedGames
)
{
result = TRUE;
{
result = TRUE;
@@
-96,7
+99,8
@@
static Boolean OnlyCurrentPositionChanged()
}
// back-end, after replacing Windows data types
}
// back-end, after replacing Windows data types
-static Boolean OneMoveAppended()
+static Boolean
+OneMoveAppended ()
{
Boolean result = FALSE;
{
Boolean result = FALSE;
@@
-106,7
+110,7
@@
static Boolean OneMoveAppended()
lastLast == (currLast-1) &&
lastCurrent == (currCurrent-1) &&
currCurrent == (currLast-1) &&
lastLast == (currLast-1) &&
lastCurrent == (currCurrent-1) &&
currCurrent == (currLast-1) &&
-
TRUE
)
+
lastGames == storedGames
)
{
result = TRUE;
}
{
result = TRUE;
}
@@
-115,7
+119,8
@@
static Boolean OneMoveAppended()
}
// back-end, now that color and font-style are passed as numbers
}
// back-end, now that color and font-style are passed as numbers
-static void AppendMoveToMemo( int index )
+static void
+AppendMoveToMemo (int index)
{
char buf[64];
{
char buf[64];
@@
-132,7
+137,7
@@
static void AppendMoveToMemo( int index )
}
/* Move text */
}
/* Move text */
- s
trcpy( buf, SavePart( currMovelist[index]
) );
+ s
afeStrCpy( buf, SavePart( currMovelist[index]) , sizeof( buf)/sizeof( buf[0]
) );
strcat( buf, " " );
histMoves[index].memoOffset = AppendToHistoryMemo( buf, 0, 0 );
strcat( buf, " " );
histMoves[index].memoOffset = AppendToHistoryMemo( buf, 0, 0 );
@@
-140,7
+145,7
@@
static void AppendMoveToMemo( int index )
/* PV info (if any) */
if( appData.showEvalInMoveHistory && currPvInfo[index].depth > 0 ) {
/* 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 );
currPvInfo[index].score >= 0 ? "+" : "",
currPvInfo[index].score / 100.0,
currPvInfo[index].depth );
@@
-150,7
+155,8
@@
static void AppendMoveToMemo( int index )
}
// back-end
}
// back-end
-void RefreshMemoContent()
+void
+RefreshMemoContent ()
{
int i;
{
int i;
@@
-162,29
+168,31
@@
void RefreshMemoContent()
}
// back-end part taken out of HighlightMove to determine character positions
}
// back-end part taken out of HighlightMove to determine character positions
-static void DoHighlight(int index, int onoff)
+static void
+DoHighlight (int index, int onoff)
{
if( index >= 0 && index < MAX_MOVES ) {
{
if( index >= 0 && index < MAX_MOVES ) {
- HighlightMove( histMoves[index].memoOffset,
+ HighlightMove( histMoves[index].memoOffset,
histMoves[index].memoOffset + histMoves[index].memoLength, onoff );
}
}
// back-end, now that a wrapper is provided for the front-end code to do the actual scrolling
histMoves[index].memoOffset + histMoves[index].memoLength, onoff );
}
}
// back-end, now that a wrapper is provided for the front-end code to do the actual scrolling
-void MemoContentUpdated()
+void
+MemoContentUpdated ()
{
int caretPos;
{
int caretPos;
- DoHighlight( lastCurrent, FALSE );
- DoHighlight( currCurrent, TRUE );
+ if(lastCurrent <= currLast) DoHighlight( lastCurrent, FALSE );
lastFirst = currFirst;
lastLast = currLast;
lastCurrent = currCurrent;
lastFirst = currFirst;
lastLast = currLast;
lastCurrent = currCurrent;
+ lastGames = storedGames;
lastLastMove[0] = '\0';
if( lastLast > 0 ) {
lastLastMove[0] = '\0';
if( lastLast > 0 ) {
-
strcpy( lastLastMove, SavePart( currMovelist[lastLast-1]
) );
+
safeStrCpy( lastLastMove, SavePart( currMovelist[lastLast-1] ) , sizeof( lastLastMove)/sizeof( lastLastMove[0]
) );
}
/* Deselect any text, move caret to end of memo */
}
/* Deselect any text, move caret to end of memo */
@@
-196,10
+204,12
@@
void MemoContentUpdated()
}
ScrollToCurrent(caretPos);
}
ScrollToCurrent(caretPos);
+ DoHighlight( currCurrent, TRUE ); // [HGM] moved last, because in X some scrolling methods spoil highlighting
}
// back-end. Must be called as double-click call-back on move-history text edit
}
// back-end. Must be called as double-click call-back on move-history text edit
-void FindMoveByCharIndex( int char_index )
+void
+FindMoveByCharIndex (int char_index)
{
int index;
{
int index;
@@
-213,7
+223,8
@@
void FindMoveByCharIndex( int char_index )
}
// back-end. In WinBoard called by call-back, but could be called directly by SetIfExists?
}
// back-end. In WinBoard called by call-back, but could be called directly by SetIfExists?
-void UpdateMoveHistory()
+void
+UpdateMoveHistory ()
{
/* Update the GUI */
if( OnlyCurrentPositionChanged() ) {
{
/* Update the GUI */
if( OnlyCurrentPositionChanged() ) {
@@
-230,7
+241,8
@@
void UpdateMoveHistory()
}
// back-end
}
// back-end
-void MoveHistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current, ChessProgramStats_Move * pvInfo )
+void
+MoveHistorySet (char movelist[][2*MOVE_LEN], int first, int last, int current, ChessProgramStats_Move * pvInfo)
{
/* [AS] Danger! For now we rely on the movelist parameter being a static variable! */
{
/* [AS] Danger! For now we rely on the movelist parameter being a static variable! */
@@
-243,4
+255,3
@@
void MoveHistorySet( char movelist[][2*MOVE_LEN], int first, int last, int curre
if(MoveHistoryDialogExists())
UpdateMoveHistory(); // [HGM] call this directly, in stead of through call-back
}
if(MoveHistoryDialogExists())
UpdateMoveHistory(); // [HGM] call this directly, in stead of through call-back
}
-