summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-19 06:47:42 +0000
committersabetts <sabetts>2001-04-19 06:47:42 +0000
commit9901676e3cd622efe29dbabcde0872de9d2be310 (patch)
tree6cd2c20695c78888539d9a56e8cb6625484bedb2 /src/actions.c
parentc10e6d6fce6d4007e1ae75509921573173416888 (diff)
downloadratpoison-9901676e3cd622efe29dbabcde0872de9d2be310.zip
* 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.
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c61
1 files changed, 55 insertions, 6 deletions
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);