Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
b76632b9e3 | |||
f8f5b27036 | |||
d6bf35caad | |||
507c030b5b | |||
0245394e4d | |||
b6cd6ed266 | |||
09813fcf2c | |||
64d68b7de9 | |||
eaf8909378 | |||
c0fcfb7827 | |||
a45d6983ab | |||
08420a935b | |||
deea1fb5ab | |||
771c0cb607 | |||
43a19425af |
2
.hgtags
2
.hgtags
@ -16,3 +16,5 @@ e071fb045bd9e8574947acff7196360bc0270e68 1.5
|
||||
dcc5427f99f51a978386a0dd770467cd911ac84b 1.6
|
||||
58dbef4aef3d45c7a3da6945e53c9667c0f02d5b 1.7
|
||||
3696d77aaf02f5d15728dde3b9e35abcaf291496 1.7.1
|
||||
d3e6fa22ae45b38b1bdb0d813390365e5930360b 1.8
|
||||
c7f5f4d543170f03d70468e98a3a0ec8d2c4161b 1.9
|
||||
|
4
LICENSE
4
LICENSE
@ -1,7 +1,7 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
(C)opyright MMVI 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 Anselm R. Garbe <garbeam 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
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
# dmenu - dynamic menu
|
||||
# (C)opyright MMVI Anselm R. Garbe
|
||||
# (C)opyright MMVII Anselm R. Garbe
|
||||
|
||||
include config.mk
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dmenu version
|
||||
VERSION = 1.8
|
||||
VERSION = 2.0
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
14
dmenu.1
14
dmenu.1
@ -57,30 +57,30 @@ 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:
|
||||
only items containing this text will be displayed.
|
||||
.TP
|
||||
.B Left/Right
|
||||
.B Left/Right (Mod1-h/Mod1-l)
|
||||
Select the previous/next item.
|
||||
.TP
|
||||
.B PageUp/PageDown
|
||||
.B PageUp/PageDown (Mod1-k/Mod1-j)
|
||||
Select the first item of the previous/next 'page' of items.
|
||||
.TP
|
||||
.B Home/End
|
||||
.B Home/End (Mod1-g/Mod1-G)
|
||||
Select the first/last item.
|
||||
.TP
|
||||
.B Tab
|
||||
.B Tab (Control-i)
|
||||
Copy the selected item to the input field.
|
||||
.TP
|
||||
.B Return
|
||||
.B Return (Control-j)
|
||||
Confirm selection and quit (print the selected item to standard output). Returns
|
||||
.B 0
|
||||
on termination.
|
||||
.TP
|
||||
.B Shift-Return
|
||||
.B Shift-Return (Control-Shift-j)
|
||||
Confirm selection and quit (print the text in the input field to standard output).
|
||||
Returns
|
||||
.B 0
|
||||
on termination.
|
||||
.TP
|
||||
.B Escape
|
||||
.B Escape (Control-bracketleft)
|
||||
Quit without selecting an item. Returns
|
||||
.B 1
|
||||
on termination.
|
||||
|
10
dmenu.h
10
dmenu.h
@ -1,14 +1,14 @@
|
||||
/* (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.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define NORMBGCOLOR "#333366"
|
||||
#define NORMFGCOLOR "#cccccc"
|
||||
#define SELBGCOLOR "#666699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define NORMBGCOLOR "#eeeeee"
|
||||
#define NORMFGCOLOR "#222222"
|
||||
#define SELBGCOLOR "#006699"
|
||||
#define SELFGCOLOR "#ffffff"
|
||||
#define SPACE 30 /* px */
|
||||
|
||||
/* color */
|
||||
|
2
draw.c
2
draw.c
@ -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.
|
||||
*/
|
||||
#include "dmenu.h"
|
||||
|
40
main.c
40
main.c
@ -1,5 +1,5 @@
|
||||
/* (C)opyright MMVI 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 Anselm R. Garbe <garbeam 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.
|
||||
*/
|
||||
#include "dmenu.h"
|
||||
@ -15,6 +15,8 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||
|
||||
typedef struct Item Item;
|
||||
struct Item {
|
||||
Item *next; /* traverses all items */
|
||||
@ -26,11 +28,12 @@ struct Item {
|
||||
|
||||
static char text[4096];
|
||||
static char *prompt = NULL;
|
||||
static int mx, my, mw, mh;
|
||||
static int mw, mh;
|
||||
static int ret = 0;
|
||||
static int nitem = 0;
|
||||
static unsigned int cmdw = 0;
|
||||
static unsigned int promptw = 0;
|
||||
static unsigned int numlockmask = 0;
|
||||
static Bool running = True;
|
||||
static Item *allitems = NULL; /* first of all items */
|
||||
static Item *item = NULL; /* first of pattern matching items */
|
||||
@ -164,21 +167,30 @@ kpress(XKeyEvent * e) {
|
||||
switch (ksym) {
|
||||
default: /* ignore other control sequences */
|
||||
return;
|
||||
case XK_bracketleft:
|
||||
ksym = XK_Escape;
|
||||
break;
|
||||
case XK_h:
|
||||
case XK_H:
|
||||
ksym = XK_BackSpace;
|
||||
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:
|
||||
text[0] = 0;
|
||||
match(text);
|
||||
drawmenu();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(e->state & Mod1Mask) {
|
||||
if(CLEANMASK(e->state) & Mod1Mask) {
|
||||
switch(ksym) {
|
||||
default: return;
|
||||
case XK_h:
|
||||
@ -338,10 +350,11 @@ main(int argc, char *argv[]) {
|
||||
char *selbg = SELBGCOLOR;
|
||||
char *selfg = SELFGCOLOR;
|
||||
fd_set rd;
|
||||
int i;
|
||||
int i, j, my;
|
||||
struct timeval timeout;
|
||||
Item *itm;
|
||||
XEvent ev;
|
||||
XModifierKeymap *modmap;
|
||||
XSetWindowAttributes wa;
|
||||
|
||||
timeout.tv_usec = 0;
|
||||
@ -373,7 +386,7 @@ main(int argc, char *argv[]) {
|
||||
if(++i < argc) timeout.tv_sec = atoi(argv[i]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else
|
||||
@ -399,6 +412,15 @@ main(int argc, char *argv[]) {
|
||||
if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
|
||||
goto UninitializedEnd;
|
||||
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 */
|
||||
dc.norm[ColBG] = getcolor(normbg);
|
||||
dc.norm[ColFG] = getcolor(normfg);
|
||||
@ -409,12 +431,12 @@ main(int argc, char *argv[]) {
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
|
||||
mx = my = 0;
|
||||
my = 0;
|
||||
mw = DisplayWidth(dpy, screen);
|
||||
mh = dc.font.height + 2;
|
||||
if(bottom)
|
||||
my += DisplayHeight(dpy, screen) - mh;
|
||||
win = XCreateWindow(dpy, root, mx, my, mw, mh, 0,
|
||||
win = XCreateWindow(dpy, root, 0, 0, mw, mh, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent,
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
|
Reference in New Issue
Block a user