commit - d058e835708d530d74f7e82d643f48d4ad62e3a4
commit + 745c46d8fa810bbf45ef16e79a0f84c787f1a670
blob - 9406af6f55fabce82a986ae2b9238e907fb82109
blob + 3cc8b32e9615b533dccc803c255f37dba97bc108
--- config.mk
+++ config.mk
# dmenu version
-VERSION = 3.5
+VERSION = 3.6
# Customize below to fit your system
blob - f772634aeeb23f6cc99fce5a68b4fddbab2b9c9d
blob + 7dac2a12a831c27c46df45918aa660b2485c4bfd
--- dmenu.1
+++ dmenu.1
defines the x coordinate dmenu appears at (0 by default).
.TP
.B \-y
-defines the y coordinate dmenu appears at (0 by default).
+defines the y coordinate dmenu appears at (0 by default). If it is negative,
+dmenu will appear with the bottom at the given positive coordinate. It it is
+-0, dmenu appears at the screen bottom.
.TP
.B \-w
defines the width of the dmenu window (screen width by default).
blob - 5f81d253d4c50f3e9ab2891055278f1edd3b45c4
blob + 688fabf26a4aa39d5c912f7276d6e29b6911cb59
--- dmenu.c
+++ dmenu.c
typedef struct Item Item;
struct Item {
+ char *text;
+ Bool matched;
Item *next; /* traverses all items */
Item *left, *right; /* traverses items matching current search pattern */
- char *text;
};
/* forward declarations */
Item *appenditem(Item *i, Item *last);
void calcoffsets(void);
+char *cistrstr(const char *s, const char *sub);
void cleanup(void);
void drawmenu(void);
void drawtext(const char *text, unsigned long col[ColLast]);
void readstdin(void);
void run(void);
void setup(int x, int y, int w);
-char *cistrstr(const char *s, const char *sub);
unsigned int textnw(const char *text, unsigned int len);
unsigned int textw(const char *text);
}
}
+char *
+cistrstr(const char *s, const char *sub) {
+ int c, csub;
+ unsigned int len;
+
+ if(!sub)
+ return (char *)s;
+ if((c = *sub++) != 0) {
+ c = tolower(c);
+ len = strlen(sub);
+ do {
+ do {
+ if((csub = *s++) == 0)
+ return (NULL);
+ }
+ while(tolower(csub) != c);
+ }
+ while(strncasecmp(s, sub, len) != 0);
+ s--;
+ }
+ return (char *)s;
+}
+
void
cleanup(void) {
Item *itm;
item = j = NULL;
nitem = 0;
for(i = allitems; i; i = i->next)
- if(!fstrncmp(pattern, i->text, plen)
- || fstrstr(i->text, pattern))
+ if((i->matched = !fstrncmp(pattern, i->text, plen)))
j = appenditem(i, j);
+ for(i = allitems; i; i = i->next)
+ if(!i->matched && fstrstr(i->text, pattern))
+ j = appenditem(i, j);
curr = prev = next = sel = item;
calcoffsets();
}
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
mw = w ? w : DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
+ if(y < 0) {
+ if(y == (int)(unsigned int)-1)
+ y = DisplayHeight(dpy, screen) - mh;
+ else
+ y = (-1 * y) - mh;
+ }
win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
XMapRaised(dpy, win);
}
-char *
-cistrstr(const char *s, const char *sub) {
- int c, csub;
- unsigned int len;
-
- if(!sub)
- return (char *)s;
- if((c = *sub++) != 0) {
- c = tolower(c);
- len = strlen(sub);
- do {
- do {
- if((csub = *s++) == 0)
- return (NULL);
- }
- while(tolower(csub) != c);
- }
- while(strncasecmp(s, sub, len) != 0);
- s--;
- }
- return (char *)s;
-}
-
unsigned int
textnw(const char *text, unsigned int len) {
XRectangle r;
if(++i < argc) x = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-y")) {
- if(++i < argc) y = atoi(argv[i]);
+ if(++i < argc) {
+ if(!strcmp(argv[i], "-0"))
+ y = (int)(unsigned int)-1;
+ else
+ y = atoi(argv[i]);
+ }
}
else if(!strcmp(argv[i], "-w")) {
if(++i < argc) w = atoi(argv[i]);