set_option (OPTNEEDREDRAW);
}
}
- else if (menu->current >= menu->top + menu->pagelen - c) /* indicator below bottom threshold */
- {
- if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
- menu->top = menu->current - menu->pagelen + c;
- else
- menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
- }
- else if (menu->current < menu->top + c) /* indicator above top threshold */
+ else
{
- if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
- menu->top = menu->current - c;
- else
- menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
+ /*
+ * If c = menu->pagelen / 2 and menu->pagelen is even, then (obviously):
+ *
+ * menu->top + menu->pagelen - c == menu->top + c
+ *
+ * In that case, having an "else if" below leads to what has become known as the
+ * indicator break dance effect. Instead of special-casing, we just forget the
+ * "else".
+ */
+
+ if (menu->current < menu->top + c) /* indicator above top threshold */
+ {
+ if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
+ menu->top = menu->current - c;
+ else
+ menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
+ }
+ if (menu->current >= menu->top + menu->pagelen - c) /* indicator below bottom threshold */
+ {
+ if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
+ menu->top = menu->current - menu->pagelen + c + 1;
+ else
+ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
+ }
}
if (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */