JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
The crlf mode was reversed.
[st.git] / st.c
diff --git a/st.c b/st.c
index dbbc1f6..b8b2bbf 100644 (file)
--- a/st.c
+++ b/st.c
@@ -59,8 +59,8 @@
 #define STR_ARG_SIZ   16
 #define DRAW_BUF_SIZ  20*1024
 #define UTF_SIZ       4
-#define XK_NO_MOD     UINT_MAX
-#define XK_ANY_MOD    0
+#define XK_ANY_MOD    UINT_MAX
+#define XK_NO_MOD     0
 
 #define REDRAW_TIMEOUT (80*1000) /* 80 ms */
 
@@ -2699,18 +2699,24 @@ kmap(KeySym k, uint state) {
 
                if(kp->k != k)
                        continue;
-               if((state & mask) != mask &&
-                               (mask == XK_NO_MOD && state)) {
+
+               if(mask == XK_NO_MOD && state)
                        continue;
-               }
+               if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state)
+                       continue;
+               if((state & mask) != state)
+                       continue;
+
                if((kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) ||
                                (kp->appkey > 0 && !IS_SET(MODE_APPKEYPAD))) {
                        continue;
                }
+
                if((kp->appcursor < 0 && IS_SET(MODE_APPCURSOR)) ||
                                (kp->appcursor > 0 && !IS_SET(MODE_APPCURSOR))) {
                        continue;
                }
+
                if((kp->crlf < 0 && IS_SET(MODE_CRLF)) ||
                                (kp->crlf > 0 && !IS_SET(MODE_CRLF))) {
                        continue;
@@ -2718,6 +2724,7 @@ kmap(KeySym k, uint state) {
 
                return kp->s;
        }
+
        return NULL;
 }