applied Connor's patch, thanks!
This commit is contained in:
parent
7082ba1e10
commit
37236f8840
45
dmenu.c
45
dmenu.c
|
@ -52,6 +52,7 @@ static void calcoffsetsh(void);
|
||||||
static void calcoffsetsv(void);
|
static void calcoffsetsv(void);
|
||||||
static char *cistrstr(const char *s, const char *sub);
|
static char *cistrstr(const char *s, const char *sub);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
|
static void drawmenu(void);
|
||||||
static void drawmenuh(void);
|
static void drawmenuh(void);
|
||||||
static void drawmenuv(void);
|
static void drawmenuv(void);
|
||||||
static void drawtext(const char *text, unsigned long col[ColLast]);
|
static void drawtext(const char *text, unsigned long col[ColLast]);
|
||||||
|
@ -95,7 +96,6 @@ static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
static Bool vlist = False;
|
static Bool vlist = False;
|
||||||
static unsigned int lines = 5;
|
static unsigned int lines = 5;
|
||||||
static void (*calcoffsets)(void) = calcoffsetsh;
|
static void (*calcoffsets)(void) = calcoffsetsh;
|
||||||
static void (*drawmenu)(void) = drawmenuh;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
appenditem(Item *i, Item **list, Item **last) {
|
appenditem(Item *i, Item **list, Item **last) {
|
||||||
|
@ -200,7 +200,7 @@ cleanup(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
drawcursor(void) {
|
drawcursor(void) {
|
||||||
XRectangle r = { dc.x, dc.y + 2, 1, dc.h - 4 };
|
XRectangle r = { dc.x, dc.y + 2, 1, dc.font.height - 2 };
|
||||||
|
|
||||||
r.x += textnw(text, cursor) + dc.font.height / 2;
|
r.x += textnw(text, cursor) + dc.font.height / 2;
|
||||||
|
|
||||||
|
@ -209,9 +209,7 @@ drawcursor(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawmenuh(void) {
|
drawmenu(void) {
|
||||||
Item *i;
|
|
||||||
|
|
||||||
dc.x = 0;
|
dc.x = 0;
|
||||||
dc.y = 0;
|
dc.y = 0;
|
||||||
dc.w = mw;
|
dc.w = mw;
|
||||||
|
@ -231,6 +229,19 @@ drawmenuh(void) {
|
||||||
drawcursor();
|
drawcursor();
|
||||||
dc.x += cmdw;
|
dc.x += cmdw;
|
||||||
if(curr) {
|
if(curr) {
|
||||||
|
if(vlist)
|
||||||
|
drawmenuv();
|
||||||
|
else
|
||||||
|
drawmenuh();
|
||||||
|
}
|
||||||
|
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
||||||
|
XFlush(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawmenuh(void) {
|
||||||
|
Item *i;
|
||||||
|
|
||||||
dc.w = spaceitem;
|
dc.w = spaceitem;
|
||||||
drawtext((curr && curr->left) ? "<" : NULL, dc.norm);
|
drawtext((curr && curr->left) ? "<" : NULL, dc.norm);
|
||||||
dc.x += dc.w;
|
dc.x += dc.w;
|
||||||
|
@ -245,30 +256,12 @@ drawmenuh(void) {
|
||||||
dc.x = mw - spaceitem;
|
dc.x = mw - spaceitem;
|
||||||
dc.w = spaceitem;
|
dc.w = spaceitem;
|
||||||
drawtext(next ? ">" : NULL, dc.norm);
|
drawtext(next ? ">" : NULL, dc.norm);
|
||||||
}
|
|
||||||
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
|
||||||
XFlush(dpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawmenuv(void) {
|
drawmenuv(void) {
|
||||||
Item *i;
|
Item *i;
|
||||||
|
|
||||||
dc.x = 0;
|
|
||||||
dc.y = 0;
|
|
||||||
dc.w = mw;
|
|
||||||
dc.h = mh;
|
|
||||||
drawtext(NULL, dc.norm);
|
|
||||||
/* print prompt? */
|
|
||||||
if(promptw) {
|
|
||||||
dc.w = promptw;
|
|
||||||
drawtext(prompt, dc.sel);
|
|
||||||
}
|
|
||||||
dc.x += promptw;
|
|
||||||
dc.w = mw - promptw;
|
|
||||||
/* print command */
|
|
||||||
drawtext(text[0] ? text : NULL, dc.norm);
|
|
||||||
if(curr) {
|
|
||||||
dc.x = 0;
|
dc.x = 0;
|
||||||
dc.w = mw;
|
dc.w = mw;
|
||||||
dc.y += dc.font.height + 2;
|
dc.y += dc.font.height + 2;
|
||||||
|
@ -278,9 +271,6 @@ drawmenuv(void) {
|
||||||
dc.y += dc.font.height + 2;
|
dc.y += dc.font.height + 2;
|
||||||
}
|
}
|
||||||
drawtext(NULL, dc.norm);
|
drawtext(NULL, dc.norm);
|
||||||
}
|
|
||||||
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
|
||||||
XFlush(dpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -786,8 +776,7 @@ main(int argc, char *argv[]) {
|
||||||
else if(!strcmp(argv[i], "-l")) {
|
else if(!strcmp(argv[i], "-l")) {
|
||||||
vlist = True;
|
vlist = True;
|
||||||
calcoffsets = calcoffsetsv;
|
calcoffsets = calcoffsetsv;
|
||||||
drawmenu = drawmenuv;
|
if(++i < argc) lines = atoi(argv[i]);
|
||||||
if(++i < argc) lines += atoi(argv[i]);
|
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[i], "-fn")) {
|
else if(!strcmp(argv[i], "-fn")) {
|
||||||
if(++i < argc) font = argv[i];
|
if(++i < argc) font = argv[i];
|
||||||
|
|
Loading…
Reference in New Issue