Item *next; /* traverses all items */
Item *left, *right; /* traverses items matching current search pattern */
Item *next; /* traverses all items */
Item *left, *right; /* traverses items matching current search pattern */
-void setup(int x, int y, int w);
-char *cistrstr(const char *s, const char *sub);
+void setup(Bool topbar);
unsigned int textnw(const char *text, unsigned int len);
unsigned int textw(const char *text);
unsigned int textnw(const char *text, unsigned int len);
unsigned int textw(const char *text);
int (*fstrncmp)(const char *, const char *, size_t n) = strncmp;
char *(*fstrstr)(const char *, const char *) = strstr;
int (*fstrncmp)(const char *, const char *, size_t n) = strncmp;
char *(*fstrstr)(const char *, const char *) = strstr;
+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;
+}
+
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
len = strlen(text);
buf[0] = 0;
num = XLookupString(e, buf, sizeof buf, &ksym, 0);
len = strlen(text);
buf[0] = 0;
num = XLookupString(e, buf, sizeof buf, &ksym, 0);
- if(!fstrncmp(pattern, i->text, plen))
- j = appenditem(i, j);
+ if(!fstrncmp(pattern, i->text, plen + 1))
+ appenditem(i, &lexact, &exactend);
+ else if(!fstrncmp(pattern, i->text, plen))
+ appenditem(i, &lprefix, &prefixend);
+ appenditem(i, &lsubstr, &substrend);
+ if(lexact) {
+ item = lexact;
+ itemend = exactend;
+ }
+ if(lprefix) {
+ if(itemend) {
+ itemend->right = lprefix;
+ lprefix->left = itemend;
+ }
+ else
+ item = lprefix;
+ itemend = prefixend;
+ }
+ if(lsubstr) {
+ if(itemend) {
+ itemend->right = lsubstr;
+ lsubstr->left = itemend;
+ }
+ else
+ item = lsubstr;
+ }
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
+#if XINERAMA
+ if(XineramaIsActive(dpy)) {
+ info = XineramaQueryScreens(dpy, &i);
+ x = info[0].x_org;
+ y = topbar ? info[0].y_org : info[0].y_org + info[0].height - mh;
+ mw = info[0].width;
+ XFree(info);
+ }
+ else
+#endif
+ {
+ x = 0;
+ y = topbar ? 0 : DisplayHeight(dpy, screen) - mh;
+ mw = DisplayWidth(dpy, screen);
+ }
+
win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
-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;
-}
-
else if(!strcmp(argv[i], "-fn")) {
if(++i < argc) font = argv[i];
}
else if(!strcmp(argv[i], "-fn")) {
if(++i < argc) font = argv[i];
}
else if(!strcmp(argv[i], "-sf")) {
if(++i < argc) selfg = argv[i];
}
else if(!strcmp(argv[i], "-sf")) {
if(++i < argc) selfg = argv[i];
}
- else if(!strcmp(argv[i], "-x")) {
- if(++i < argc) x = atoi(argv[i]);
- }
- else if(!strcmp(argv[i], "-y")) {
- if(++i < argc) y = atoi(argv[i]);
- }
- else if(!strcmp(argv[i], "-w")) {
- if(++i < argc) w = atoi(argv[i]);
- }
else if(!strcmp(argv[i], "-v"))
eprint("dmenu-"VERSION", © 2006-2008 dmenu engineers, see LICENSE for details\n");
else
else if(!strcmp(argv[i], "-v"))
eprint("dmenu-"VERSION", © 2006-2008 dmenu engineers, see LICENSE for details\n");
else
- eprint("usage: dmenu [-i] [-fn <font>] [-nb <color>] [-nf <color>]\n"
- " [-p <prompt>] [-sb <color>] [-sf <color>]\n"
- " [-x <x>] [-y <y>] [-w <w>] [-v]\n");
+ eprint("usage: dmenu [-i] [-b] [-fn <font>] [-nb <color>] [-nf <color>]\n"
+ " [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");