X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwgamelist.c;h=4fa60251a32223551c3630b93a069d24fe7b7045;hb=c37d45adc7d98a702a7459ccdc0ac23df01a476e;hp=c5a25f59daf2ccd6cedce854e733fd258947a901;hpb=d9f4b584106f4d7477158476ff792f6fa0b2630a;p=xboard.git diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index c5a25f5..4fa6025 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -1,7 +1,7 @@ /* * wgamelist.c -- Game list window for WinBoard * - * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc. + * Copyright 1995, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -57,7 +57,7 @@ struct GameListStats }; /* [AS] Setup the game list according to the specified filter */ -static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos ) +static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow ) { ListGame * lg = (ListGame *) gameList.head; int nItem; @@ -86,11 +86,19 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct } } + if(byPos) InitSearch(); + for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ char * st = NULL; BOOL skip = FALSE; int pos = -1; + if(nItem % 2000 == 0) { + snprintf(buf, MSG_SIZ, _("Scanning through games (%d)"), nItem); + SetWindowText(hwndMain, buf); + } + + if(!narrow || lg->position >= 0) { if( hasFilter ) { st = GameListLine(lg->number, &lg->gameInfo); if( !SearchPattern( st, pszFilter) ) skip = TRUE; @@ -100,8 +108,6 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct if( (pos = GameContainsPosition(gameFile, lg)) < 0) skip = TRUE; } - lg->position = pos; - if( ! skip ) { if(!st) st = GameListLine(lg->number, &lg->gameInfo); SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st); @@ -116,13 +122,18 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct stats->drawn++; else stats->unfinished++; + if(!byPos) pos = 0; } + } + + lg->position = pos; if(st) free(st); lg = (ListGame *) lg->node.succ; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0); + SetWindowText(hwndMain, "WinBoard"); return count; } @@ -176,7 +187,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Set font */ SendDlgItemMessage( hDlg, OPT_GameListText, WM_SETFONT, (WPARAM)font[boardSize][GAMELIST_FONT]->hf, MAKELPARAM(TRUE, 0 )); - count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats, FALSE ); + count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats, FALSE, FALSE ); SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" ); SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 ); @@ -293,7 +304,8 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); break; /* load the game*/ -// case OPT_GameListPrev: + case OPT_GameListPrev: +#if 0 nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); nItem--; if (nItem < 0) { @@ -303,16 +315,16 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); break; /* load the game*/ - +#endif /* [AS] */ - case OPT_GameListPrev: + case OPT_GameListFind: case IDC_GameListDoFilter: { char filter[MAX_FILTER_LENGTH+1]; if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) { filter[ sizeof(filter)-1 ] = '\0'; - count = GameListToListBox( hDlg, TRUE, filter, &stats, LOWORD(wParam)!=IDC_GameListDoFilter ); + count = GameListToListBox( hDlg, TRUE, filter, &stats, LOWORD(wParam)!=IDC_GameListDoFilter, LOWORD(wParam)==OPT_GameListNarrow ); GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats ); } } @@ -408,6 +420,11 @@ VOID GameListPopUp(FILE *fp, char *filename) gameListUp = TRUE; } +FILE *GameFile() +{ + return gameFile; +} + VOID GameListPopDown(void) { CheckMenuItem(GetMenu(hwndMain), IDM_ShowGameList, MF_UNCHECKED);