Compare commits

...

10 Commits
1.8 ... 1.9

9 changed files with 42 additions and 19 deletions

View File

@ -16,3 +16,4 @@ e071fb045bd9e8574947acff7196360bc0270e68 1.5
dcc5427f99f51a978386a0dd770467cd911ac84b 1.6 dcc5427f99f51a978386a0dd770467cd911ac84b 1.6
58dbef4aef3d45c7a3da6945e53c9667c0f02d5b 1.7 58dbef4aef3d45c7a3da6945e53c9667c0f02d5b 1.7
3696d77aaf02f5d15728dde3b9e35abcaf291496 1.7.1 3696d77aaf02f5d15728dde3b9e35abcaf291496 1.7.1
d3e6fa22ae45b38b1bdb0d813390365e5930360b 1.8

View File

@ -1,7 +1,7 @@
MIT/X Consortium License MIT/X Consortium License
(C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
(C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com> (C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
# dmenu - dynamic menu # dmenu - dynamic menu
# (C)opyright MMVI Anselm R. Garbe # (C)opyright MMVII Anselm R. Garbe
include config.mk include config.mk

View File

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 1.8 VERSION = 1.9
# Customize below to fit your system # Customize below to fit your system

12
dmenu.1
View File

@ -57,16 +57,16 @@ dmenu is completely controlled by the keyboard. The following keys are recognize
Appends the character to the text in the input field. This works as a filter: Appends the character to the text in the input field. This works as a filter:
only items containing this text will be displayed. only items containing this text will be displayed.
.TP .TP
.B Left/Right .B Left/Right (Mod1-h/Mod1-l)
Select the previous/next item. Select the previous/next item.
.TP .TP
.B PageUp/PageDown .B PageUp/PageDown (Mod1-k/Mod1-j)
Select the first item of the previous/next 'page' of items. Select the first item of the previous/next 'page' of items.
.TP .TP
.B Home/End .B Home/End (Mod1-g/Mod1-G)
Select the first/last item. Select the first/last item.
.TP .TP
.B Tab .B Tab (Control-i)
Copy the selected item to the input field. Copy the selected item to the input field.
.TP .TP
.B Return .B Return
@ -74,13 +74,13 @@ Confirm selection and quit (print the selected item to standard output). Returns
.B 0 .B 0
on termination. on termination.
.TP .TP
.B Shift-Return .B Shift-Return (Control-j)
Confirm selection and quit (print the text in the input field to standard output). Confirm selection and quit (print the text in the input field to standard output).
Returns Returns
.B 0 .B 0
on termination. on termination.
.TP .TP
.B Escape .B Escape (Control-bracketleft)
Quit without selecting an item. Returns Quit without selecting an item. Returns
.B 1 .B 1
on termination. on termination.

View File

@ -1,4 +1,4 @@
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */

2
draw.c
View File

@ -1,4 +1,4 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com> /* (C)opyright MMIV-MMVII Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dmenu.h" #include "dmenu.h"

34
main.c
View File

@ -1,5 +1,5 @@
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com> * (C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dmenu.h" #include "dmenu.h"
@ -15,6 +15,8 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
typedef struct Item Item; typedef struct Item Item;
struct Item { struct Item {
Item *next; /* traverses all items */ Item *next; /* traverses all items */
@ -31,6 +33,7 @@ static int ret = 0;
static int nitem = 0; static int nitem = 0;
static unsigned int cmdw = 0; static unsigned int cmdw = 0;
static unsigned int promptw = 0; static unsigned int promptw = 0;
static unsigned int numlockmask = 0;
static Bool running = True; static Bool running = True;
static Item *allitems = NULL; /* first of all items */ static Item *allitems = NULL; /* first of all items */
static Item *item = NULL; /* first of pattern matching items */ static Item *item = NULL; /* first of pattern matching items */
@ -164,21 +167,30 @@ kpress(XKeyEvent * e) {
switch (ksym) { switch (ksym) {
default: /* ignore other control sequences */ default: /* ignore other control sequences */
return; return;
case XK_bracketleft:
ksym = XK_Escape;
break; break;
case XK_h: case XK_h:
case XK_H: case XK_H:
ksym = XK_BackSpace; ksym = XK_BackSpace;
break; break;
case XK_i:
case XK_I:
ksym = XK_Tab;
break;
case XK_j:
case XK_J:
ksym = XK_Return;
break;
case XK_u: case XK_u:
case XK_U: case XK_U:
text[0] = 0; text[0] = 0;
match(text); match(text);
drawmenu(); drawmenu();
return; return;
break;
} }
} }
if(e->state & Mod1Mask) { if(CLEANMASK(e->state) & Mod1Mask) {
switch(ksym) { switch(ksym) {
default: return; default: return;
case XK_h: case XK_h:
@ -338,10 +350,11 @@ main(int argc, char *argv[]) {
char *selbg = SELBGCOLOR; char *selbg = SELBGCOLOR;
char *selfg = SELFGCOLOR; char *selfg = SELFGCOLOR;
fd_set rd; fd_set rd;
int i; int i, j;
struct timeval timeout; struct timeval timeout;
Item *itm; Item *itm;
XEvent ev; XEvent ev;
XModifierKeymap *modmap;
XSetWindowAttributes wa; XSetWindowAttributes wa;
timeout.tv_usec = 0; timeout.tv_usec = 0;
@ -373,7 +386,7 @@ main(int argc, char *argv[]) {
if(++i < argc) timeout.tv_sec = atoi(argv[i]); if(++i < argc) timeout.tv_sec = atoi(argv[i]);
} }
else if(!strncmp(argv[i], "-v", 3)) { else if(!strncmp(argv[i], "-v", 3)) {
fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); fputs("dmenu-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
else else
@ -399,6 +412,15 @@ main(int argc, char *argv[]) {
if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
goto UninitializedEnd; goto UninitializedEnd;
maxname = readstdin(); maxname = readstdin();
/* init modifier map */
modmap = XGetModifierMapping(dpy);
for (i = 0; i < 8; i++) {
for (j = 0; j < modmap->max_keypermod; j++) {
if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
numlockmask = (1 << i);
}
}
XFreeModifiermap(modmap);
/* style */ /* style */
dc.norm[ColBG] = getcolor(normbg); dc.norm[ColBG] = getcolor(normbg);
dc.norm[ColFG] = getcolor(normfg); dc.norm[ColFG] = getcolor(normfg);

2
util.c
View File

@ -1,4 +1,4 @@
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dmenu.h" #include "dmenu.h"