applied Stefan Tibus' sun patch, added -bottom option to dmenu which makes it appear...
[dmenu.git] / main.c
diff --git a/main.c b/main.c
index 3ea9d89..7fca45e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -178,6 +178,29 @@ kpress(XKeyEvent * e) {
                        break;
                }
        }
+       if(e->state & Mod1Mask) {
+               switch(ksym) {
+               default: return;
+               case XK_h:
+                       ksym = XK_Left;
+                       break;
+               case XK_l:
+                       ksym = XK_Right;
+                       break;
+               case XK_j:
+                       ksym = XK_Next;
+                       break;
+               case XK_k:
+                       ksym = XK_Prior;
+                       break;
+               case XK_g:
+                       ksym = XK_Home;
+                       break;
+               case XK_G:
+                       ksym = XK_End;
+                       break;
+               }
+       }
        switch(ksym) {
        default:
                if(num && !iscntrl((int) buf[0])) {
@@ -200,7 +223,7 @@ kpress(XKeyEvent * e) {
                }
                break;
        case XK_End:
-               if(!sel)
+               if(!item)
                        return;
                while(next) {
                        sel = curr = next;
@@ -307,6 +330,7 @@ DC dc = {0};
 
 int
 main(int argc, char *argv[]) {
+       Bool bottom = False;
        char *font = FONT;
        char *maxname;
        char *normbg = NORMBGCOLOR;
@@ -324,7 +348,10 @@ main(int argc, char *argv[]) {
        timeout.tv_sec = 3;
        /* command line args */
        for(i = 1; i < argc; i++)
-               if(!strncmp(argv[i], "-font", 6)) {
+               if(!strncmp(argv[i], "-bottom", 8)) {
+                       bottom = True;
+               }
+               else if(!strncmp(argv[i], "-font", 6)) {
                        if(++i < argc) font = argv[i];
                }
                else if(!strncmp(argv[i], "-normbg", 8)) {
@@ -350,7 +377,8 @@ main(int argc, char *argv[]) {
                        exit(EXIT_SUCCESS);
                }
                else
-                       eprint("usage: dmenu [-font <name>] [-{norm,sel}{bg,fg} <color>] [-p <prompt>] [-t <seconds>] [-v]\n", stdout);
+                       eprint("usage: dmenu [-bottom] [-font <name>] [-{norm,sel}{bg,fg} <color>]\n"
+                               "             [-p <prompt>] [-t <seconds>] [-v]\n", stdout);
        setlocale(LC_CTYPE, "");
        dpy = XOpenDisplay(0);
        if(!dpy)
@@ -383,7 +411,12 @@ main(int argc, char *argv[]) {
        wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
        mx = my = 0;
        mw = DisplayWidth(dpy, screen);
-       mh = dc.font.height + 2;
+       if(bottom) {
+               mh = dc.font.ascent + dc.font.descent + 3; // match wmii
+               my = DisplayHeight(dpy, screen) - mh;
+       }
+       else
+               mh = dc.font.height + 2;
        win = XCreateWindow(dpy, root, mx, my, mw, mh, 0,
                        DefaultDepth(dpy, screen), CopyFromParent,
                        DefaultVisual(dpy, screen),