- }
- /* fix all the prev links on all the mailboxes
- * FIXME move this over to buffy.c where it belongs */
- for ( ; tmp->next != 0; tmp = tmp->next )
- tmp->next->prev = tmp;
-
- /* calculate the position of the current mailbox */
- position = 1;
- tmp = Incoming;
- while (tmp != CurBuffy)
- {
- position++;
- tmp = tmp->next;
- }
- /* calculate the size of the screen we can use */
- count = LINES - 2 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
- /* calculate the position of the current mailbox on the screen */
- mailbox_position = position%count;
- if (mailbox_position == 0) mailbox_position=count;
- /* determine topbuffy */
- TopBuffy = CurBuffy;
- for(i = mailbox_position; i >1; i--) TopBuffy = TopBuffy->prev;
- /* determine bottombuffy */
- BottomBuffy = CurBuffy;
- for(i = mailbox_position; i < count && BottomBuffy->next; i++)
- BottomBuffy = BottomBuffy->next;
+ lines = LINES - 2 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
+ TopBuffy = CurBuffy - (CurBuffy % lines);
+ if (TopBuffy < 0)
+ TopBuffy = 0;