Copy purify.fvwm2rc to /tmp - add instructions in README.
[fvwm.git] / libs / modifiers.c
blob477feca552a8c8ef7d6d7ec09373a5e538706377
1 /* -*-c-*- */
2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ---------------------------- included header files ---------------------- */
19 #include "config.h"
20 #include <stdio.h>
22 #include "libs/charmap.h"
23 #include "libs/modifiers.h"
25 /* ---------------------------- local definitions -------------------------- */
27 /* ---------------------------- local macros ------------------------------- */
29 /* ---------------------------- imports ------------------------------------ */
31 /* ---------------------------- included code files ------------------------ */
33 /* ---------------------------- local types -------------------------------- */
35 /* ---------------------------- forward declarations ----------------------- */
37 /* ---------------------------- local variables ---------------------------- */
39 /* ---------------------------- exported variables (globals) --------------- */
41 /* The keys must be in lower case! */
42 charmap_t key_modifiers[] =
44 {'s', ShiftMask},
45 {'c', ControlMask},
46 {'l', LockMask},
47 {'m', Mod1Mask},
48 {'1', Mod1Mask},
49 {'2', Mod2Mask},
50 {'3', Mod3Mask},
51 {'4', Mod4Mask},
52 {'5', Mod5Mask},
53 {'a', AnyModifier},
54 {'n', 0},
55 {0, 0}
58 /* Table to translate a modifier map index to a modifier that we define that
59 * generates that index. This mapping can be chosen by each client, but the
60 * settings below try to emulate the usual terminal behaviour. */
61 unsigned int modifier_mapindex_to_mask[8] =
63 ShiftMask,
64 Mod3Mask, /* Alt Gr */
65 Mod3Mask | ShiftMask,
66 /* Just guessing below here - LockMask is not used anywhere*/
67 ControlMask,
68 Mod1Mask, /* Alt/Meta on XFree86 */
69 Mod2Mask, /* Num lock on XFree86 */
70 Mod4Mask,
71 Mod5Mask, /* Scroll lock on XFree86 */
74 /* ---------------------------- local functions ---------------------------- */
76 /* ---------------------------- interface functions ------------------------ */
78 /* Converts the input string into a mask with bits for the modifiers */
79 int modifiers_string_to_modmask(char *in_modifiers, int *out_modifier_mask)
81 int error;
83 error = charmap_string_to_mask(
84 out_modifier_mask, in_modifiers, key_modifiers,
85 "bad modifier");
87 return error;