get_internal_key_map_seq(key) : get_user_key_map_seq(key);
}
+static char *get_key_map_seq_safe(int key)
+{
+ const char hex[] = "0123456789abcdef";
+ char *seq = get_key_map_seq(key), *sseq;
+ size_t n, len = strlen(seq);
+
+ if (len == 1 && isprint(*seq))
+ return seq;
+ sseq = para_malloc(2 + 2 * len + 1);
+ sseq[0] = '0';
+ sseq[1] = 'x';
+ for (n = 0; n < len; n++) {
+ uint8_t val = (seq[n] & 0xf0) >> 4;
+ sseq[2 + 2 * n] = hex[val];
+ val = seq[n] & 0xf;
+ sseq[2 + 2 * n + 1] = hex[val];
+ }
+ free(seq);
+ sseq[2 + 2 * n] = '\0';
+ return sseq;
+}
+
static inline char *get_internal_key_map_cmd(int key)
{
return para_strdup(default_commands[get_internal_key_map_idx(key)]);
FOR_EACH_MAPPED_KEY(i) {
bool internal = is_internal_key(i);
int idx = get_key_map_idx(i);
- char *seq = get_key_map_seq(i);
+ char *seq = get_key_map_seq_safe(i);
char *cmd = get_key_map_cmd(i);
sz = xasprintf(&buf,
"%s key #%d: %s -> %s\n",