log: log_key()

This commit is contained in:
Justin M. Keyes
2019-08-18 22:21:11 +02:00
parent 9a92ba88dd
commit 0a4ef38e43
2 changed files with 12 additions and 3 deletions

View File

@@ -940,3 +940,14 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len,
return *bufp;
}
/// Logs a single key as a human-readable keycode.
void log_key(int log_level, int key)
{
if (log_level < MIN_LOG_LEVEL) {
return;
}
char *keyname = key == K_EVENT
? "K_EVENT"
: (char *)get_special_key_name(key, mod_mask);
LOG(log_level, "input: %s", keyname);
}

View File

@@ -65,9 +65,7 @@ getkey:
}
#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL
char *keyname = key == K_EVENT
? "K_EVENT" : (char *)get_special_key_name(key, mod_mask);
DLOG("input: %s", keyname);
log_key(DEBUG_LOG_LEVEL, key);
#endif
int execute_result = s->execute(s, key);