Skip to content
Snippets Groups Projects
Commit 2e47ac98 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Just overhaul this who chunk of code.

parent 4f158aa2
Branches
Tags
No related merge requests found
Pipeline #7146 passed
...@@ -956,52 +956,56 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar ...@@ -956,52 +956,56 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar
set_vmem(ptr++, api->chars->list_separator_right, hclr|(bclr<<4), 0); set_vmem(ptr++, api->chars->list_separator_right, hclr|(bclr<<4), 0);
} }
// Clamp cur
if ((*cur) >= opts) if ((*cur) >= opts)
(*cur)=opts-1; /* returned after scrolled */ *cur = opts - 1; /* returned after scrolled */
if ((*cur)<0)
*cur = 0;
if (!bar) { if (!bar) {
// If we don't have bar, do not allow scrolling
if ((*cur) > height - vbrdrsize - 1) if ((*cur) > height - vbrdrsize - 1)
(*cur)=height-vbrdrsize-1; *cur = height - vbrdrsize - 1;
if ((*cur) > opts - 1) if ((*cur) > opts - 1)
(*cur)=opts-1; *cur = opts - 1;
i=0; i=0;
} }
else { else {
if((*bar)>=opts) // *bar must be strictly <= *cur
(*bar)=opts-1; if (*bar > *cur)
if((*bar)>height-vbrdrsize-1) *bar = *cur;
(*bar)=height-vbrdrsize-1;
if((*cur)==opts-1) // *bar needs to fit in window with room for highlight
(*bar)=height-vbrdrsize-1; if ((*bar) >= height - vbrdrsize)
if((*bar)>opts-1) *bar = height - vbrdrsize - 1;
(*bar)=opts-1;
// And finally, *bar can't be negative
if ((*bar) < 0) if ((*bar) < 0)
(*bar)=0; *bar = 0;
// Set i to the first option to display on the screen... // Set i to the first option to display on the screen...
i = (*cur) - (*bar); i = (*cur) - (*bar);
// If bar is too high, start with first item
if (i < 0) { // If there are enough options to fill the screen
*bar = *cur; if ((opts > (height - vbrdrsize))) {
i = 0; // If the screen is not filled...
} if ((opts - i) < (height - vbrdrsize)) {
// If the number of options on screen is greater than the rows on screen... *bar += (height - vbrdrsize) - (opts - i);
if ((opts - i) > (height - vbrdrsize)) { // This shouldn't be possible, but may as well be paranoid
*bar = height - vbrdrsize;
if (*bar > *cur) if (*bar > *cur)
*bar = *cur; *bar = *cur;
// Recalculate i since we adjusted bar
i=(*cur)-(*bar); i=(*cur)-(*bar);
} }
// If there are enough options to fill the screen, but the screen is not filled... }
if ((opts > (height - vbrdrsize)) && ((opts - i) < (height - vbrdrsize))) { else {
*bar += (height - vbrdrsize) - (opts - i); // Show whole menu
i=(*cur)-(*bar); *bar = *cur;
i = 0;
} }
} }
if((*cur)<0)
(*cur)=0;
j=0; j=0;
if(i<0) i=0;
longopt=0; longopt=0;
while(j<height-vbrdrsize) { while(j<height-vbrdrsize) {
if(!(mode&WIN_NOBRDR)) if(!(mode&WIN_NOBRDR))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment