diff options
author | sabetts <sabetts> | 2001-04-19 06:47:42 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-04-19 06:47:42 +0000 |
commit | 9901676e3cd622efe29dbabcde0872de9d2be310 (patch) | |
tree | 6cd2c20695c78888539d9a56e8cb6625484bedb2 | |
parent | c10e6d6fce6d4007e1ae75509921573173416888 (diff) | |
download | ratpoison-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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/actions.c | 61 | ||||
-rw-r--r-- | src/input.c | 37 |
3 files changed, 78 insertions, 29 deletions
@@ -1,3 +1,12 @@ +2001-04-18 shawn <sabetts@diggin.lamenet.tmp> + + * 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. + 2001-04-15 shawn <sabetts@diggin.lamenet.tmp> * src/split.c (show_frame_indicator): contents of 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); diff --git a/src/input.c b/src/input.c index d64135f..1818f5d 100644 --- a/src/input.c +++ b/src/input.c @@ -115,33 +115,24 @@ init_modifier_map () char * keysym_to_string (KeySym keysym, unsigned int modifier) { - const unsigned int mod_table[] = {ControlMask, - Mod1Mask, - Mod2Mask, - Mod3Mask, - Mod4Mask, - Mod5Mask}; - const unsigned char str_table[] = "CM2345"; + struct sbuf *name; + char *tmp; - unsigned char *name; - int pos, i; + name = sbuf_new (0); - name = xmalloc (15); + if (modifier & ControlMask) sbuf_concat (name, "C-"); + if (modifier & rp_modifier_info.meta_mod_mask) sbuf_concat (name, "M-"); + if (modifier & rp_modifier_info.alt_mod_mask) sbuf_concat (name, "A-"); + if (modifier & rp_modifier_info.hyper_mod_mask) sbuf_concat (name, "H-"); + if (modifier & rp_modifier_info.super_mod_mask) sbuf_concat (name, "S-"); + + sbuf_concat (name, XKeysymToString (keysym)); - for (pos = 0, i = 0; i < 6; i++) - { - if (modifier & mod_table[i]) - { - name[pos] = str_table[i]; - name[pos+1] = '-'; - pos += 2; - } - } - - name[pos] = keysym; - name[pos+1] = '\0'; + /* Eat the nut and throw away the shells. */ + tmp = sbuf_get (name); + free (name); - return name; + return tmp; } /* Cooks a keycode + modifier into a keysym + modifier. This should be |