Skip to content

Commit

Permalink
core: fix bind of keys with space key, like alt+space (bug #32133)
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Jun 10, 2017
1 parent 964481a commit 46b27bf
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 52 deletions.
1 change: 1 addition & 0 deletions ChangeLog.adoc
Expand Up @@ -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)
Expand Down
119 changes: 67 additions & 52 deletions src/gui/gui-key.c
Expand Up @@ -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 = malloc (strlen (key) + 1);
if (!result)
return NULL;

result[0] = '\0';
while (key[0])
{
result[0] = '\0';
while (key[0])
if (strncmp (key, "meta2-", 6) == 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++;
}
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++;
}
}
else
return NULL;

return result;
result2 = strdup (result);
free (result);

return result2;
}

/*
Expand All @@ -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;
}

/*
Expand Down

0 comments on commit 46b27bf

Please sign in to comment.