Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
follow symlinks
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
2684c91
..
40b220c
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-1,4
+1,4
@@
-/* See LICENSE file for copy
nex
t and license details. */
+/* See LICENSE file for copy
righ
t and license details. */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@
-55,8
+55,8
@@
static Atom utf8;
static Bool topbar = True;
static DC *dc;
static Item *items = NULL;
static Bool topbar = True;
static DC *dc;
static Item *items = NULL;
-static Item *matches, *
sel
;
-static Item *prev, *curr, *next;
+static Item *matches, *
matchend
;
+static Item *prev, *curr, *next
, *sel
;
static Window root, win;
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static Window root, win;
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
@@
-66,7
+66,6
@@
main(int argc, char *argv[]) {
Bool fast = False;
int i;
Bool fast = False;
int i;
- progname = "dmenu";
for(i = 1; i < argc; i++)
/* single flags */
if(!strcmp(argv[i], "-v")) {
for(i = 1; i < argc; i++)
/* single flags */
if(!strcmp(argv[i], "-v")) {
@@
-308,12
+307,15
@@
keypress(XKeyEvent *ev) {
cursor = len;
break;
}
cursor = len;
break;
}
-
while
(next) {
-
sel = curr = next
;
+
if
(next) {
+
curr = matchend
;
calcoffsets();
calcoffsets();
+ curr = prev;
+ calcoffsets();
+ while(next && (curr = curr->right))
+ calcoffsets();
}
}
- while(sel && sel->right)
- sel = sel->right;
+ sel = matchend;
break;
case XK_Escape:
exit(EXIT_FAILURE);
break;
case XK_Escape:
exit(EXIT_FAILURE);
@@
-380,11
+382,10
@@
keypress(XKeyEvent *ev) {
void
match(void) {
void
match(void) {
- size_t len;
- Item *item, *
itemend, *
lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
+ size_t len
= strlen(text)
;
+ Item *item, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
- len = strlen(text);
- matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
+ matches = lexact = lprefix = lsubstr = matchend = exactend = prefixend = substrend = NULL;
for(item = items; item && item->text; item++)
if(!fstrncmp(text, item->text, len + 1))
appenditem(item, &lexact, &exactend);
for(item = items; item && item->text; item++)
if(!fstrncmp(text, item->text, len + 1))
appenditem(item, &lexact, &exactend);
@@
-395,24
+396,25
@@
match(void) {
if(lexact) {
matches = lexact;
if(lexact) {
matches = lexact;
-
item
end = exactend;
+
match
end = exactend;
}
if(lprefix) {
}
if(lprefix) {
- if(
item
end) {
-
item
end->right = lprefix;
- lprefix->left =
item
end;
+ if(
match
end) {
+
match
end->right = lprefix;
+ lprefix->left =
match
end;
}
else
matches = lprefix;
}
else
matches = lprefix;
-
item
end = prefixend;
+
match
end = prefixend;
}
if(lsubstr) {
}
if(lsubstr) {
- if(
item
end) {
-
item
end->right = lsubstr;
- lsubstr->left =
item
end;
+ if(
match
end) {
+
match
end->right = lsubstr;
+ lsubstr->left =
match
end;
}
else
matches = lsubstr;
}
else
matches = lsubstr;
+ matchend = substrend;
}
curr = sel = matches;
calcoffsets();
}
curr = sel = matches;
calcoffsets();
@@
-420,9
+422,8
@@
match(void) {
size_t
nextrune(int incr) {
size_t
nextrune(int incr) {
- size_t n, len;
+ size_t n, len
= strlen(text)
;
- len = strlen(text);
for(n = cursor + incr; n >= 0 && n < len && (text[n] & 0xc0) == 0x80; n += incr);
return n;
}
for(n = cursor + incr; n >= 0 && n < len && (text[n] & 0xc0) == 0x80; n += incr);
return n;
}