Update key collision detection

This commit is contained in:
Arun Prakash Jana 2019-10-11 20:59:22 +05:30
parent ab8e3e445e
commit fe80d5aa9d
No known key found for this signature in database
GPG key ID: A75979F35C080412
5 changed files with 14 additions and 10 deletions

View file

@ -173,6 +173,7 @@ optional args:
-f run filter as cmd on prompt key
-H show hidden files
-i nav-as-you-type mode
-K detect key collision
-n version sort
-o open files on Enter
-p file selection file [stdout if '-']

View file

@ -18,6 +18,7 @@ _nnn () {
-f
-H
-i
-K
-n
-o
-p

View file

@ -12,6 +12,7 @@ complete -c nnn -s d -d 'start in detail mode'
complete -c nnn -s f -d 'run filter as cmd on prompt key'
complete -c nnn -s H -d 'show hidden files'
complete -c nnn -s i -d 'start in navigate-as-you-type mode'
complete -c nnn -s K -d 'detect key collision'
complete -c nnn -s n -d 'use version compare to sort files'
complete -c nnn -s o -d 'open files only on Enter'
complete -c nnn -s p -r -d 'copy selection to file'

View file

@ -16,6 +16,7 @@ args=(
'(-f)-d[run filter as cmd on prompt key]'
'(-H)-H[show hidden files]'
'(-i)-i[start in navigate-as-you-type mode]'
'(-K)-K[detect key collision]'
'(-n)-n[use version compare to sort files]'
'(-o)-o[open files only on Enter]'
'(-p)-p[copy selection to file]:file name'

View file

@ -4671,19 +4671,19 @@ nochange:
}
}
static void check_keybinding_collision(void)
static void check_key_collision(void)
{
unsigned long i;
int key;
uint i = 0;
bool bitmap[KEY_MAX] = {FALSE};
for (i = 0; i < sizeof(bindings) / sizeof(struct key); ++i) {
int curr_sym = bindings[i].sym;
for (; i < sizeof(bindings) / sizeof(struct key); ++i) {
key = bindings[i].sym;
if (bitmap[curr_sym])
fprintf(stdout,
"Collision of key %s detected\n", keyname(curr_sym));
if (bitmap[key])
fprintf(stdout, "collision detected: key [%s]\n", keyname(key));
else
bitmap[curr_sym] = TRUE;
bitmap[key] = TRUE;
}
}
@ -4701,8 +4701,8 @@ static void usage(void)
" -d detail mode\n"
" -f run filter as cmd on prompt key\n"
" -H show hidden files\n"
" -K test for keybinding collision\n"
" -i nav-as-you-type mode\n"
" -K detect key collision\n"
" -n version sort\n"
" -o open files on Enter\n"
" -p file selection file [stdout if '-']\n"
@ -4909,7 +4909,7 @@ int main(int argc, char *argv[])
cfg.autoselect = 0;
break;
case 'K':
check_keybinding_collision();
check_key_collision();
return _SUCCESS;
case 'v':
fprintf(stdout, "%s\n", VERSION);