1 | #include <config.h> |
---|---|
2 | #include "lst.h" |
3 | |
4 | /*************************** |
5 | * ENSURE CURRENT IS NOT ON A bDelete ITEM |
6 | * |
7 | * 1. Should only be required for root list. |
8 | ***************************/ |
9 | void *_lstAdjustCurrent( HLST hLst ) |
10 | { |
11 | HLSTITEM h; |
12 | |
13 | if ( !hLst ) |
14 | return NULL; |
15 | |
16 | if ( !hLst->hCurrent ) |
17 | return NULL; |
18 | |
19 | if ( _lstVisible( hLst->hCurrent ) ) |
20 | return hLst->hCurrent; |
21 | |
22 | h = hLst->hCurrent; |
23 | while ( !_lstVisible( hLst->hCurrent ) && hLst->hCurrent->pPrev ) |
24 | { |
25 | hLst->hCurrent = hLst->hCurrent->pPrev; |
26 | } |
27 | |
28 | if ( _lstVisible( hLst->hCurrent ) ) |
29 | return hLst->hCurrent; |
30 | |
31 | hLst->hCurrent = h; |
32 | while ( !_lstVisible( hLst->hCurrent ) && hLst->hCurrent->pNext ) |
33 | { |
34 | hLst->hCurrent = hLst->hCurrent->pNext; |
35 | } |
36 | |
37 | if ( _lstVisible( hLst->hCurrent ) ) |
38 | return hLst->hCurrent; |
39 | |
40 | hLst->hCurrent = NULL; |
41 | |
42 | return NULL; |
43 | } |
44 | |
45 | |
46 | |
47 |