From 9901676e3cd622efe29dbabcde0872de9d2be310 Mon Sep 17 00:00:00 2001 From: sabetts Date: Thu, 19 Apr 2001 06:47:42 +0000 Subject: * src/input.c (keysym_to_string): handles control, meta, alt, hyper, and super modifiers. Returns full keysym names. * src/actions.c (parse_keydesc): parses control, meta, alt, hyper, and super modifiers. (cmd_clock): sets the last character in msg to 0. --- src/actions.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'src/actions.c') diff --git a/src/actions.c b/src/actions.c index a9ed3d7..6bf0d06 100644 --- a/src/actions.c +++ b/src/actions.c @@ -213,19 +213,67 @@ parse_keydesc (char *keydesc) { static struct rp_key key; struct rp_key *p = &key; + char *token, *next_token; if (!keydesc) return NULL; - if (keydesc[0] == '^') + p->state = 0; + p->sym = 0; + + if (!strchr (keydesc, '-')) { - p->state = ControlMask; - p->sym = string_to_keysym (keydesc + 1); + /* Its got no hyphens in it, so just grab the keysym */ + p->sym = string_to_keysym (keydesc); } - else + else { - p->state = 0; - p->sym = string_to_keysym (keydesc); + /* Its got hyphens, so parse out the modifiers and keysym */ + token = strtok (keydesc, "-"); + + do + { + next_token = strtok (NULL, "-"); + + if (next_token == NULL) + { + /* There is nothing more to parse and token contains the + keysym name. */ + p->sym = string_to_keysym (token); + } + else + { + /* Which modifier is it? Only accept modifiers that are + present. ie don't accept a hyper modifier if the keymap + has no hyper key. */ + if (!strcmp (token, "C")) + { + p->state |= ControlMask; + } + else if (!strcmp (token, "M") && rp_modifier_info.meta_mod_mask) + { + p->state |= rp_modifier_info.meta_mod_mask; + } + else if (!strcmp (token, "A") && rp_modifier_info.alt_mod_mask) + { + p->state |= rp_modifier_info.alt_mod_mask; + } + else if (!strcmp (token, "S") && rp_modifier_info.super_mod_mask) + { + p->state |= rp_modifier_info.super_mod_mask; + } + else if (!strcmp (token, "H") && rp_modifier_info.hyper_mod_mask) + { + p->state |= rp_modifier_info.hyper_mod_mask; + } + else + { + return NULL; + } + } + + token = next_token; + } while (next_token != NULL); } if (!p->sym) @@ -713,6 +761,7 @@ cmd_clock (void *data) tmp = ctime(&timep); msg = xmalloc (strlen (tmp)); strncpy(msg, tmp, strlen (tmp) - 1); /* Remove the newline */ + msg[strlen(tmp) - 1] = 0; message (msg); free (msg); -- cgit v1.2.3