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 */
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.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
mw = w ? w : DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
mw = w ? w : DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
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;
-}
-
if(++i < argc) x = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-y")) {
if(++i < argc) x = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-y")) {
}
else if(!strcmp(argv[i], "-w")) {
if(++i < argc) w = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-w")) {
if(++i < argc) w = atoi(argv[i]);