Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
fix input text matching
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
32a8330
..
4f22ffe
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-7,6
+7,7
@@
#include <string.h>
#include <strings.h>
#include <time.h>
#include <string.h>
#include <strings.h>
#include <time.h>
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
@@
-207,7
+208,7
@@
match(void)
char buf[sizeof text], *s;
int i, tokc = 0;
char buf[sizeof text], *s;
int i, tokc = 0;
- size_t len;
+ size_t len
, textsize
;
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
strcpy(buf, text);
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
strcpy(buf, text);
@@
-218,6
+219,7
@@
match(void)
len = tokc ? strlen(tokv[0]) : 0;
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
len = tokc ? strlen(tokv[0]) : 0;
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
+ textsize = strlen(text);
for (item = items; item && item->text; item++) {
for (i = 0; i < tokc; i++)
if (!fstrstr(item->text, tokv[i]))
for (item = items; item && item->text; item++) {
for (i = 0; i < tokc; i++)
if (!fstrstr(item->text, tokv[i]))
@@
-225,7
+227,7
@@
match(void)
if (i != tokc) /* not all tokens match */
continue;
/* exact matches go first, then prefixes, then substrings */
if (i != tokc) /* not all tokens match */
continue;
/* exact matches go first, then prefixes, then substrings */
- if (!tokc || !fstrncmp(t
okv[0], item->text, len + 1
))
+ if (!tokc || !fstrncmp(t
ext, item->text, textsize
))
appenditem(item, &matches, &matchend);
else if (!fstrncmp(tokv[0], item->text, len))
appenditem(item, &lprefix, &prefixend);
appenditem(item, &matches, &matchend);
else if (!fstrncmp(tokv[0], item->text, len))
appenditem(item, &lprefix, &prefixend);
@@
-319,6
+321,7
@@
keypress(XKeyEvent *ev)
insert(NULL, nextrune(-1) - cursor);
break;
case XK_y: /* paste selection */
insert(NULL, nextrune(-1) - cursor);
break;
case XK_y: /* paste selection */
+ case XK_Y:
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
utf8, utf8, win, CurrentTime);
return;
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
utf8, utf8, win, CurrentTime);
return;
@@
-622,7
+625,7
@@
main(int argc, char *argv[])
if (!strcmp(argv[i], "-v")) { /* prints version information */
puts("dmenu-"VERSION);
exit(0);
if (!strcmp(argv[i], "-v")) { /* prints version information */
puts("dmenu-"VERSION);
exit(0);
- } else if (!strcmp(argv[i], "-b"))
/* appears at the bottom of the screen */
+ } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
topbar = false;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = true;
topbar = false;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = true;