aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c58
1 files changed, 2 insertions, 56 deletions
diff --git a/st.c b/st.c
index 839dc94..1a8fa1f 100644
--- a/st.c
+++ b/st.c
@@ -110,16 +110,6 @@ typedef struct {
110 int narg; /* nb of args */ 110 int narg; /* nb of args */
111} STREscape; 111} STREscape;
112 112
113typedef struct {
114 KeySym k;
115 uint mask;
116 char *s;
117 /* three valued logic variables: 0 indifferent, 1 on, -1 off */
118 signed char appkey; /* application keypad */
119 signed char appcursor; /* application cursor */
120 signed char crlf; /* crlf mode */
121} Key;
122
123/* function definitions used in config.h */ 113/* function definitions used in config.h */
124static void clipcopy(const Arg *); 114static void clipcopy(const Arg *);
125static void clippaste(const Arg *); 115static void clippaste(const Arg *);
@@ -223,6 +213,8 @@ size_t colornamelen = LEN(colorname);
223size_t mshortcutslen = LEN(mshortcuts); 213size_t mshortcutslen = LEN(mshortcuts);
224size_t shortcutslen = LEN(shortcuts); 214size_t shortcutslen = LEN(shortcuts);
225size_t selmaskslen = LEN(selmasks); 215size_t selmaskslen = LEN(selmasks);
216size_t keyslen = LEN(key);
217size_t mappedkeyslen = LEN(mappedkeys);
226 218
227ssize_t 219ssize_t
228xwrite(int fd, const char *s, size_t len) 220xwrite(int fd, const char *s, size_t len)
@@ -2550,54 +2542,8 @@ redraw(void)
2550 draw(); 2542 draw();
2551} 2543}
2552 2544
2553int
2554match(uint mask, uint state)
2555{
2556 return mask == XK_ANY_MOD || mask == (state & ~ignoremod);
2557}
2558
2559void 2545void
2560numlock(const Arg *dummy) 2546numlock(const Arg *dummy)
2561{ 2547{
2562 term.numlock ^= 1; 2548 term.numlock ^= 1;
2563} 2549}
2564
2565char*
2566kmap(KeySym k, uint state)
2567{
2568 Key *kp;
2569 int i;
2570
2571 /* Check for mapped keys out of X11 function keys. */
2572 for (i = 0; i < LEN(mappedkeys); i++) {
2573 if (mappedkeys[i] == k)
2574 break;
2575 }
2576 if (i == LEN(mappedkeys)) {
2577 if ((k & 0xFFFF) < 0xFD00)
2578 return NULL;
2579 }
2580
2581 for (kp = key; kp < key + LEN(key); kp++) {
2582 if (kp->k != k)
2583 continue;
2584
2585 if (!match(kp->mask, state))
2586 continue;
2587
2588 if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
2589 continue;
2590 if (term.numlock && kp->appkey == 2)
2591 continue;
2592
2593 if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
2594 continue;
2595
2596 if (IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0)
2597 continue;
2598
2599 return kp->s;
2600 }
2601
2602 return NULL;
2603}