Fix a problem when using the left key to change the ring and checkbox menu
items. The old code used modulus which does not give the required result, for C (ISO 1990) and before the result is implementation defined so may have worked for some compilers / targets but from C (ISO 1999) onwards the sign of the result comes from the dividend so will not work. (By M. T. Jones)
This commit is contained in:
@@ -6,6 +6,7 @@ Key:
|
||||
* Something changed / fixed
|
||||
|
||||
v0.5dev (ongoing development)
|
||||
* Fix using the left key to change the ring and checkbox menu items
|
||||
* sed1520: Add an option for inverted segment mapping (idea by R. Buchert)
|
||||
|
||||
v0.5.6
|
||||
|
||||
+8
-6
@@ -734,18 +734,20 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char *key, unsi
|
||||
break;
|
||||
switch (subitem->type) {
|
||||
case MENUITEM_CHECKBOX:
|
||||
/* Note: this works as CheckboxValue is an enum >= 0. */
|
||||
subitem->data.checkbox.value--;
|
||||
subitem->data.checkbox.value %= (subitem->data.checkbox.allow_gray) ? 3 : 2;
|
||||
if (subitem->data.checkbox.value == 0)
|
||||
subitem->data.checkbox.value = (subitem->data.checkbox.allow_gray) ? 2 : 1;
|
||||
else
|
||||
subitem->data.checkbox.value--;
|
||||
|
||||
if (subitem->event_func)
|
||||
subitem->event_func(subitem, MENUEVENT_UPDATE);
|
||||
return MENURESULT_NONE;
|
||||
case MENUITEM_RING:
|
||||
/* ring: jump to the end if beginning is reached */
|
||||
/* Note: this works as data.ring.value is a short >= 0 */
|
||||
subitem->data.ring.value--;
|
||||
subitem->data.ring.value %= LL_Length(subitem->data.ring.strings);
|
||||
if (subitem->data.ring.value == 0)
|
||||
subitem->data.ring.value = LL_Length(subitem->data.ring.strings) - 1;
|
||||
else
|
||||
subitem->data.ring.value--;
|
||||
|
||||
if (subitem->event_func)
|
||||
subitem->event_func(subitem, MENUEVENT_UPDATE);
|
||||
|
||||
Reference in New Issue
Block a user