EFI_STATUS err;
UINTN visible_max;
- UINTN idx_highlight;
- UINTN idx_highlight_prev;
+ UINTN idx_highlight = config->idx_default;
+ UINTN idx_highlight_prev = 0;
UINTN idx_first;
UINTN idx_last;
- BOOLEAN refresh;
- BOOLEAN highlight;
+ BOOLEAN refresh = TRUE;
+ BOOLEAN highlight = FALSE;
UINTN line_width;
CHAR16 **lines;
UINTN x_start;
UINTN y_start;
UINTN x_max;
UINTN y_max;
- CHAR16 *status;
+ CHAR16 *status = NULL;
CHAR16 *clearline;
UINTN timeout_remain = config->timeout_sec;
INT16 idx;
y_max = 25;
}
- idx_highlight = config->idx_default;
- idx_highlight_prev = 0;
-
visible_max = y_max - 2;
- if ((UINTN)config->idx_default >= visible_max)
- idx_first = config->idx_default-1;
- else
+ /* Drawing entries starts at idx_first until idx_last. We want to make
+ * sure that idx_highlight is centered, but not if we are close to the
+ * beginning/end of the entry list. Otherwise we would have a half-empty
+ * screen. */
+ if (config->entry_count <= visible_max || idx_highlight <= visible_max / 2)
idx_first = 0;
-
- idx_last = idx_first + visible_max-1;
-
- refresh = TRUE;
- highlight = FALSE;
+ else if (idx_highlight >= config->entry_count - (visible_max / 2))
+ idx_first = config->entry_count - visible_max;
+ else
+ idx_first = idx_highlight - (visible_max / 2);
+ idx_last = idx_first + visible_max - 1;
/* length of the longest entry */
line_width = 5;
lines[i][x_max] = '\0';
}
- status = NULL;
clearline = AllocatePool((x_max+1) * sizeof(CHAR16));
for (UINTN i = 0; i < x_max; i++)
clearline[i] = ' ';