Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
drawing border around sel item
[dmenu.git]
/
main.c
diff --git
a/main.c
b/main.c
index
f151819
..
14581c4
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-77,39
+77,38
@@
drawmenu()
dc.y = 0;
dc.w = mw;
dc.h = mh;
dc.y = 0;
dc.w = mw;
dc.h = mh;
- drawtext(NULL, False
, False
);
+ drawtext(NULL, False);
/* print command */
if(cmdw && item)
dc.w = cmdw;
/* print command */
if(cmdw && item)
dc.w = cmdw;
- drawtext(text[0] ? text : NULL, False
, False
);
+ drawtext(text[0] ? text : NULL, False);
dc.x += cmdw;
if(curr) {
dc.w = SPACE;
dc.x += cmdw;
if(curr) {
dc.w = SPACE;
- drawtext((curr && curr->left) ? "<" : NULL, False
, False
);
+ drawtext((curr && curr->left) ? "<" : NULL, False);
dc.x += dc.w;
/* determine maximum items */
for(i = curr; i != next; i=i->right) {
dc.x += dc.w;
/* determine maximum items */
for(i = curr; i != next; i=i->right) {
- dc.border = False;
dc.w = textw(i->text);
if(dc.w > mw / 3)
dc.w = mw / 3;
dc.w = textw(i->text);
if(dc.w > mw / 3)
dc.w = mw / 3;
- drawtext(i->text, sel == i
, sel == i
);
+ drawtext(i->text, sel == i);
dc.x += dc.w;
}
dc.x = mw - SPACE;
dc.w = SPACE;
dc.x += dc.w;
}
dc.x = mw - SPACE;
dc.w = SPACE;
- drawtext(next ? ">" : NULL, False
, False
);
+ drawtext(next ? ">" : NULL, False);
}
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
XFlush(dpy);
}
static void
}
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
XFlush(dpy);
}
static void
-
input
(char *pattern)
+
match
(char *pattern)
{
unsigned int plen;
Item *i, *j;
{
unsigned int plen;
Item *i, *j;
@@
-173,18
+172,16
@@
kpress(XKeyEvent * e)
return;
break;
case XK_h:
return;
break;
case XK_h:
+ case XK_H:
ksym = XK_BackSpace;
break;
ksym = XK_BackSpace;
break;
- case XK_U:
case XK_u:
case XK_u:
+ case XK_U:
text[0] = 0;
text[0] = 0;
-
input
(text);
+
match
(text);
drawmenu();
return;
break;
drawmenu();
return;
break;
- case XK_bracketleft:
- ksym = XK_Escape;
- break;
}
}
switch(ksym) {
}
}
switch(ksym) {
@@
-201,7
+198,7
@@
kpress(XKeyEvent * e)
if(!sel)
return;
strncpy(text, sel->text, sizeof(text));
if(!sel)
return;
strncpy(text, sel->text, sizeof(text));
-
input
(text);
+
match
(text);
break;
case XK_Right:
if(!(sel && sel->right))
break;
case XK_Right:
if(!(sel && sel->right))
@@
-233,9
+230,9
@@
kpress(XKeyEvent * e)
prev_nitem = nitem;
do {
text[--i] = 0;
prev_nitem = nitem;
do {
text[--i] = 0;
-
input
(text);
+
match
(text);
} while(i && nitem && prev_nitem == nitem);
} while(i && nitem && prev_nitem == nitem);
-
input
(text);
+
match
(text);
}
break;
default:
}
break;
default:
@@
-245,14
+242,14
@@
kpress(XKeyEvent * e)
strncat(text, buf, sizeof(text));
else
strncpy(text, buf, sizeof(text));
strncat(text, buf, sizeof(text));
else
strncpy(text, buf, sizeof(text));
-
input
(text);
+
match
(text);
}
}
drawmenu();
}
static char *
}
}
drawmenu();
}
static char *
-read
input
()
+read
stdin
()
{
static char *maxname = NULL;
char *p, buf[1024];
{
static char *maxname = NULL;
char *p, buf[1024];
@@
-309,7
+306,7
@@
main(int argc, char *argv[])
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
- maxname = read
input
();
+ maxname = read
stdin
();
/* grab as early as possible, but after reading all items!!! */
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
/* grab as early as possible, but after reading all items!!! */
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
@@
-319,7
+316,6
@@
main(int argc, char *argv[])
/* style */
dc.bg = getcolor(BGCOLOR);
dc.fg = getcolor(FGCOLOR);
/* style */
dc.bg = getcolor(BGCOLOR);
dc.fg = getcolor(FGCOLOR);
- dc.border = getcolor(BORDERCOLOR);
setfont(FONT);
wa.override_redirect = 1;
setfont(FONT);
wa.override_redirect = 1;
@@
-346,7
+342,7
@@
main(int argc, char *argv[])
cmdw = mw / 3;
text[0] = 0;
cmdw = mw / 3;
text[0] = 0;
-
input
(text);
+
match
(text);
XMapRaised(dpy, win);
drawmenu();
XSync(dpy, False);
XMapRaised(dpy, win);
drawmenu();
XSync(dpy, False);