Commit 1c528db8 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: condense three asserts into a single one

Also, when a key string does not denote a Ctrl nor Meta nor Function key,
there is no point in assigning a keycode, because plain characters cannot
be used as a function shortcut.
No related merge requests found
Showing with 6 additions and 9 deletions
+6 -9
...@@ -404,19 +404,16 @@ void assign_keyinfo(sc *s, const char *keystring) ...@@ -404,19 +404,16 @@ void assign_keyinfo(sc *s, const char *keystring)
s->keystr = (char *)keystring; s->keystr = (char *)keystring;
s->meta = (keystring[0] == 'M'); s->meta = (keystring[0] == 'M');
if (s->keystr[0] == '^') { assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
assert(strlen(s->keystr) > 1);
if (keystring[0] == '^')
s->keycode = s->keystr[1] - 64; s->keycode = s->keystr[1] - 64;
} else if (s->meta) { else if (s->meta)
assert(strlen(s->keystr) > 2);
s->keycode = tolower((int) s->keystr[2]); s->keycode = tolower((int) s->keystr[2]);
} else if (s->keystr[0] == 'F') { else if (keystring[0] == 'F')
assert(strlen(s->keystr) > 1);
s->keycode = KEY_F0 + atoi(&s->keystr[1]); s->keycode = KEY_F0 + atoi(&s->keystr[1]);
} else /* RAWINPUT */
s->keycode = (int) s->keystr[0];
/* Override some keys which don't bind as easily as we'd like. */ /* Catch the strings that don't bind as easily as we'd like. */
if (strcasecmp(s->keystr, "^Space") == 0) if (strcasecmp(s->keystr, "^Space") == 0)
s->keycode = 0; s->keycode = 0;
else if (strcasecmp(s->keystr, "M-Space") == 0) else if (strcasecmp(s->keystr, "M-Space") == 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment