From 8373ecfe5137a42035ce472eb47e84391b10a2c4 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 3 Sep 2017 15:44:55 +0200 Subject: 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 --- src/custom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/custom.c b/src/custom.c index 7e75e51..8688245 100644 --- a/src/custom.c +++ b/src/custom.c @@ -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: -- cgit v1.2.3-70-g09d2