Updated copyright notice to 2014
[xboard.git] / winboard / wgamelist.c
index 06c0684..4fa6025 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
  * wgamelist.c -- Game list window for WinBoard\r
  *\r
- * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc.\r
+ * Copyright 1995, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
@@ -57,7 +57,7 @@ struct GameListStats
 };\r
 \r
 /* [AS] Setup the game list according to the specified filter */\r
-static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos )\r
+static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow )\r
 {\r
     ListGame * lg = (ListGame *) gameList.head;\r
     int nItem;\r
@@ -98,6 +98,7 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct
           SetWindowText(hwndMain, buf);\r
         }\r
 \r
+      if(!narrow || lg->position >= 0) {\r
         if( hasFilter ) {\r
             st = GameListLine(lg->number, &lg->gameInfo);\r
            if( !SearchPattern( st, pszFilter) ) skip = TRUE;\r
@@ -107,8 +108,6 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct
             if( (pos = GameContainsPosition(gameFile, lg)) < 0) skip = TRUE;\r
         }\r
 \r
-       lg->position = pos;\r
-\r
         if( ! skip ) {\r
             if(!st) st = GameListLine(lg->number, &lg->gameInfo);\r
             SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st);\r
@@ -123,7 +122,11 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct
                 stats->drawn++;\r
             else\r
                 stats->unfinished++;\r
+           if(!byPos) pos = 0;\r
         }\r
+      }\r
+\r
+       lg->position = pos;\r
 \r
         if(st) free(st);\r
         lg = (ListGame *) lg->node.succ;\r
@@ -184,7 +187,7 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
     /* Set font */\r
     SendDlgItemMessage( hDlg, OPT_GameListText, WM_SETFONT, (WPARAM)font[boardSize][GAMELIST_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
 \r
-    count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats, FALSE         );\r
+    count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats, FALSE, FALSE );\r
 \r
     SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" );\r
     SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 );\r
@@ -302,6 +305,7 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
       break; /* load the game*/\r
 \r
     case OPT_GameListPrev:\r
+#if 0\r
       nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0);\r
       nItem--;\r
       if (nItem < 0) {\r
@@ -311,7 +315,7 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
       }\r
       SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0);\r
       break; /* load the game*/\r
-\r
+#endif\r
     /* [AS] */\r
     case OPT_GameListFind:\r
     case IDC_GameListDoFilter:\r
@@ -320,7 +324,7 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
 \r
             if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) {\r
                 filter[ sizeof(filter)-1 ] = '\0';\r
-                count = GameListToListBox( hDlg, TRUE, filter, &stats, LOWORD(wParam)!=IDC_GameListDoFilter );\r
+                count = GameListToListBox( hDlg, TRUE, filter, &stats, LOWORD(wParam)!=IDC_GameListDoFilter, LOWORD(wParam)==OPT_GameListNarrow );\r
                 GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats );\r
             }\r
         }\r
@@ -416,6 +420,11 @@ VOID GameListPopUp(FILE *fp, char *filename)
   gameListUp = TRUE;\r
 }\r
 \r
+FILE *GameFile()\r
+{\r
+  return gameFile;\r
+}\r
+\r
 VOID GameListPopDown(void)\r
 {\r
   CheckMenuItem(GetMenu(hwndMain), IDM_ShowGameList, MF_UNCHECKED);\r