Expand vertical dmenu to full screen (10 lines, 240x296) and rename St menu item to Terminal
This commit is contained in:
@@ -23,7 +23,7 @@ static const char *defaultcolors[SchemeLast][2] = {
|
||||
[SchemeOut] = { "#ffffff", "#383838" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 9;
|
||||
static unsigned int lines = 10;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
|
||||
@@ -23,7 +23,7 @@ static const char *defaultcolors[SchemeLast][2] = {
|
||||
[SchemeOut] = { "#ffffff", "#383838" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 9;
|
||||
static unsigned int lines = 10;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
|
||||
+21
-14
@@ -45,7 +45,7 @@ struct item {
|
||||
static char numbers[NUMBERSBUFSIZE] = "";
|
||||
static char text[BUFSIZ] = "";
|
||||
static char *embed;
|
||||
static int bh, mw, mh;
|
||||
static int bh, item_bh, mw, mh;
|
||||
static int inputw = 0, promptw;
|
||||
static int lrpad; /* sum of left and right padding */
|
||||
static size_t cursor;
|
||||
@@ -182,7 +182,7 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
x + indentx - (lrpad / 2) - 1,
|
||||
y,
|
||||
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||
bh, 0, highlight, 0
|
||||
(lines > 0 ? item_bh : bh), 0, highlight, 0
|
||||
);
|
||||
highlight[strlen(token)] = restorechar;
|
||||
|
||||
@@ -202,7 +202,7 @@ drawitem(struct item *item, int x, int y, int w)
|
||||
else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
|
||||
int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
int r = drw_text(drw, x, y, w, (lines > 0 ? item_bh : bh), lrpad / 2, item->text, 0);
|
||||
drawhighlights(item, x, y, w);
|
||||
return r;
|
||||
}
|
||||
@@ -269,8 +269,11 @@ drawmenu(void)
|
||||
if (lines > 0) {
|
||||
/* draw vertical list */
|
||||
x -= lrpad / 2;
|
||||
for (item = curr; item != next; item = item->right)
|
||||
drawitem(item, 0, y += bh, mw);
|
||||
y = bh;
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
drawitem(item, 0, y, mw);
|
||||
y += item_bh;
|
||||
}
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
@@ -682,13 +685,14 @@ motionnotify(XEvent *e)
|
||||
|
||||
if (lines > 0) {
|
||||
/* vertical list: (ctrl)left-click on item */
|
||||
y = bh;
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
y += h;
|
||||
if (ev->y >= y && ev->y <= (y + h)) {
|
||||
if (ev->y >= y && ev->y < (y + item_bh)) {
|
||||
sel = item;
|
||||
drawmenu();
|
||||
return;
|
||||
}
|
||||
y += item_bh;
|
||||
}
|
||||
/* display page up/down or jump top/bottom as appropriate */
|
||||
if(ev->y > mh || ev->y < 0){
|
||||
@@ -810,9 +814,9 @@ buttonpress(XEvent *e)
|
||||
if (lines > 0) {
|
||||
/* vertical list: (ctrl)left-click on item */
|
||||
w = mw - x;
|
||||
y = bh;
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
y += h;
|
||||
if (ev->y >= y && ev->y <= (y + h)) {
|
||||
if (ev->y >= y && ev->y < (y + item_bh)) {
|
||||
puts(item->text);
|
||||
if (!(ev->state & ControlMask))
|
||||
exit(0);
|
||||
@@ -823,6 +827,7 @@ buttonpress(XEvent *e)
|
||||
}
|
||||
return;
|
||||
}
|
||||
y += item_bh;
|
||||
}
|
||||
} else if (matches) {
|
||||
/* left-click on left arrow */
|
||||
@@ -910,7 +915,6 @@ readstdin(void)
|
||||
if (items)
|
||||
items[i].text = NULL;
|
||||
inputw = (items && lines == 0 && !centered) ? TEXTW(items[imax].text) : 0;
|
||||
lines = MIN(lines, i);
|
||||
}
|
||||
|
||||
#include <poll.h>
|
||||
@@ -1154,6 +1158,7 @@ setup(void)
|
||||
const int bar_h = 24;
|
||||
bh = drw->fonts->h + 2;
|
||||
bh = MAX(bh, lineheight);
|
||||
item_bh = bh;
|
||||
lines = MAX(lines, 0);
|
||||
mh = (lines + 1) * bh;
|
||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
@@ -1185,9 +1190,10 @@ setup(void)
|
||||
break;
|
||||
|
||||
avail_h = MAX((int)bh * 2, (int)info[i].height - bar_h);
|
||||
if (lines > 0 && (int)mh > avail_h) {
|
||||
if (lines > 0) {
|
||||
lines = MAX(1, (avail_h / (int)bh) - 1);
|
||||
mh = (lines + 1) * bh;
|
||||
mh = avail_h;
|
||||
item_bh = (mh - bh) / (int)lines;
|
||||
}
|
||||
x = info[i].x_org;
|
||||
mw = info[i].width;
|
||||
@@ -1203,9 +1209,10 @@ setup(void)
|
||||
parentwin);
|
||||
|
||||
avail_h = MAX((int)bh * 2, (int)wa.height - bar_h);
|
||||
if (lines > 0 && (int)mh > avail_h) {
|
||||
if (lines > 0) {
|
||||
lines = MAX(1, (avail_h / (int)bh) - 1);
|
||||
mh = (lines + 1) * bh;
|
||||
mh = avail_h;
|
||||
item_bh = (mh - bh) / (int)lines;
|
||||
}
|
||||
x = 0;
|
||||
mw = wa.width;
|
||||
|
||||
Reference in New Issue
Block a user