core: fix bind of keys with space key, like alt+space (bug #32133)

v2.8-utf8proc
Sébastien Helleu 2017-06-10 08:15:44 +02:00
parent 964481aaeb
commit 46b27bff4e
2 changed files with 71 additions and 55 deletions

View File

@ -35,6 +35,7 @@ Improvements::
Bug fixes::
* core: fix bind of keys with space key, like kbd:[Alt+Space] (bug #32133)
* core: fix infinite loop when the terminal is closed on the secure password prompt (issue #1010)
* buflist: fix long mouse gestures
* buflist: fix slow switch of buffer when there are a lot of buffers opened (issue #998)

View File

@ -273,42 +273,49 @@ gui_key_grab_end_timer_cb (const void *pointer, void *data,
char *
gui_key_get_internal_code (const char *key)
{
char *result;
char *result, *result2;
if ((key[0] == '@') && strchr (key, ':'))
return strdup (key);
if ((result = malloc (strlen (key) + 1)))
{
result[0] = '\0';
while (key[0])
{
if (strncmp (key, "meta2-", 6) == 0)
{
strcat (result, "\x01[[");
key += 6;
}
if (strncmp (key, "meta-", 5) == 0)
{
strcat (result, "\x01[");
key += 5;
}
else if (strncmp (key, "ctrl-", 5) == 0)
{
strcat (result, "\x01");
key += 5;
}
else
{
strncat (result, key, 1);
key++;
}
}
}
else
result = malloc (strlen (key) + 1);
if (!result)
return NULL;
return result;
result[0] = '\0';
while (key[0])
{
if (strncmp (key, "meta2-", 6) == 0)
{
strcat (result, "\x01[[");
key += 6;
}
if (strncmp (key, "meta-", 5) == 0)
{
strcat (result, "\x01[");
key += 5;
}
else if (strncmp (key, "ctrl-", 5) == 0)
{
strcat (result, "\x01");
key += 5;
}
else if (strncmp (key, "space", 5) == 0)
{
strcat (result, " ");
key += 5;
}
else
{
strncat (result, key, 1);
key++;
}
}
result2 = strdup (result);
free (result);
return result2;
}
/*
@ -322,41 +329,49 @@ gui_key_get_internal_code (const char *key)
char *
gui_key_get_expanded_name (const char *key)
{
char *result;
char *result, *result2;
if (!key)
return NULL;
result = malloc ((strlen (key) * 5) + 1);
if (result)
if (!result)
return NULL;
result[0] = '\0';
while (key[0])
{
result[0] = '\0';
while (key[0])
if (strncmp (key, "\x01[[", 3) == 0)
{
if (strncmp (key, "\x01[[", 3) == 0)
{
strcat (result, "meta2-");
key += 3;
}
if (strncmp (key, "\x01[", 2) == 0)
{
strcat (result, "meta-");
key += 2;
}
else if ((key[0] == '\x01') && (key[1]))
{
strcat (result, "ctrl-");
key++;
}
else
{
strncat (result, key, 1);
key++;
}
strcat (result, "meta2-");
key += 3;
}
if (strncmp (key, "\x01[", 2) == 0)
{
strcat (result, "meta-");
key += 2;
}
else if ((key[0] == '\x01') && (key[1]))
{
strcat (result, "ctrl-");
key++;
}
else if (key[0] == ' ')
{
strcat (result, "space");
key++;
}
else
{
strncat (result, key, 1);
key++;
}
}
return result;
result2 = strdup (result);
free (result);
return result2;
}
/*