Improve default selection when editing key bindings

When adding a new key binding, automatically select the new binding.
When removing a key binding, keep the selection index (unless the last
binding of a row is removed).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2017-09-03 15:44:55 +02:00
parent 6521d8cc0a
commit 8373ecfe51

View File

@ -1014,13 +1014,13 @@ void custom_keys_config(void)
selelm,
LINESPERKEY);
wins_scrollwin_display(&kwin);
} else {
nbrowelm++;
selelm = nbrowelm - 1;
}
delwin(grabwin);
}
while (used || not_recognized);
nbrowelm++;
if (selelm < nbrowelm - 1)
selelm++;
#undef WINROW
#undef WINCOL
break;
@ -1029,7 +1029,7 @@ void custom_keys_config(void)
ch = keys_str2int(keystr);
keys_remove_binding(ch, selrow);
nbrowelm--;
if (selelm > 0 && selelm <= nbrowelm)
if (selelm > 0 && selelm >= nbrowelm)
selelm--;
break;
case KEY_GENERIC_QUIT: