Last layout index for `ISO_Last_Group`
Currently we have no way to specify the last layout index when using the group actions.
This is an issue for using e.g. ISO_Last_Group. It current compat definition is:
interpret ISO_Last_Group {
action= LockGroup(group=2);
};
What about:
interpret ISO_Last_Group {
action= LockGroup(group=last);
};
where last denotes the last group index, provided by the RMLVO API. It would allow to use also expressions, e.g. last - 1, etc.
The issue is that if using the string API, we cannot not know the total number of groups until parsing all the keymap, contrary to the RMLVO interface where we know it after resolving the rules, because with the latter API we enforce a single group per xkb_symbols section.
I would rather avoid any solution that implies keeping an AST around.
It would be nice to have the mirrored first index, which would be fixed to the expected group 1 (1-indexed).
Cheap solution:
- If using RMLVO API, then the value is known before parsing: just use it.
- Otherwise:
- Set
last = 3 * XKB_MAX_GROUPS. We expect only realistic expressions such as:x ± last, with x in the range-XKB_MAX_GROUPS..XKB_MAX_GROUPS. - When resolving the expression, if the result is ≤
-2 * XKB_MAX_GROUPSor ≥2 * XKB_MAX_GROUPS, then keep it unchanged for post-processing, otherwise check the bounds. - When post-processing:
- Set
lastto the correct value. - If the value is in the range
-XKB_MAX_GROUPS..XKB_MAX_GROUPS: do nothing. - Otherwise:
- If < 0 then add
3 * XKB_MAX_GROUPS - last - Otherwise, add
- 3 * XKB_MAX_GROUPS + last - If the value is still out-of-range, then fix it with the usual function.
- If < 0 then add
- Set
- Set