applied Connor's patch, thanks!
This commit is contained in:
parent
7082ba1e10
commit
37236f8840
77
dmenu.c
77
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,56 +229,48 @@ drawmenuh(void) {
|
|||||||
drawcursor();
|
drawcursor();
|
||||||
dc.x += cmdw;
|
dc.x += cmdw;
|
||||||
if(curr) {
|
if(curr) {
|
||||||
dc.w = spaceitem;
|
if(vlist)
|
||||||
drawtext((curr && curr->left) ? "<" : NULL, dc.norm);
|
drawmenuv();
|
||||||
dc.x += dc.w;
|
else
|
||||||
/* determine maximum items */
|
drawmenuh();
|
||||||
for(i = curr; i != next; i=i->right) {
|
|
||||||
dc.w = textw(i->text);
|
|
||||||
if(dc.w > mw / 3)
|
|
||||||
dc.w = mw / 3;
|
|
||||||
drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
|
|
||||||
dc.x += dc.w;
|
|
||||||
}
|
|
||||||
dc.x = mw - spaceitem;
|
|
||||||
dc.w = spaceitem;
|
|
||||||
drawtext(next ? ">" : NULL, dc.norm);
|
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawmenuh(void) {
|
||||||
|
Item *i;
|
||||||
|
|
||||||
|
dc.w = spaceitem;
|
||||||
|
drawtext((curr && curr->left) ? "<" : NULL, dc.norm);
|
||||||
|
dc.x += dc.w;
|
||||||
|
/* determine maximum items */
|
||||||
|
for(i = curr; i != next; i=i->right) {
|
||||||
|
dc.w = textw(i->text);
|
||||||
|
if(dc.w > mw / 3)
|
||||||
|
dc.w = mw / 3;
|
||||||
|
drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
|
||||||
|
dc.x += dc.w;
|
||||||
|
}
|
||||||
|
dc.x = mw - spaceitem;
|
||||||
|
dc.w = spaceitem;
|
||||||
|
drawtext(next ? ">" : NULL, dc.norm);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawmenuv(void) {
|
drawmenuv(void) {
|
||||||
Item *i;
|
Item *i;
|
||||||
|
|
||||||
dc.x = 0;
|
dc.x = 0;
|
||||||
dc.y = 0;
|
|
||||||
dc.w = mw;
|
dc.w = mw;
|
||||||
dc.h = mh;
|
dc.y += dc.font.height + 2;
|
||||||
drawtext(NULL, dc.norm);
|
/* determine maximum items */
|
||||||
/* print prompt? */
|
for(i = curr; i != next; i=i->right) {
|
||||||
if(promptw) {
|
drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
|
||||||
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.w = mw;
|
|
||||||
dc.y += dc.font.height + 2;
|
dc.y += dc.font.height + 2;
|
||||||
/* determine maximum items */
|
|
||||||
for(i = curr; i != next; i=i->right) {
|
|
||||||
drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
|
|
||||||
dc.y += dc.font.height + 2;
|
|
||||||
}
|
|
||||||
drawtext(NULL, dc.norm);
|
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
|
drawtext(NULL, dc.norm);
|
||||||
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
Block a user