Compare commits
5 Commits
07314a14de
...
0023d6c2cd
Author | SHA1 | Date |
---|---|---|
Victor Timofei | 0023d6c2cd | |
Victor Timofei | c67ba38005 | |
Victor Timofei | b319d66e78 | |
Victor Timofei | 9f6960d2fc | |
Victor Timofei | 6b8becb2a4 |
|
@ -2,7 +2,7 @@
|
||||||
/* Default settings; can be overriden by command line. */
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
static const unsigned int alpha = 0xf0;
|
static const unsigned int alpha = 0x0b;
|
||||||
static const int border_width = 0; /* for alpha patch */
|
static const int border_width = 0; /* for alpha patch */
|
||||||
static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
|
static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
|
||||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
@ -25,8 +25,9 @@ static const unsigned int alphas[SchemeLast][2] = {
|
||||||
[SchemeOut] = { OPAQUE, alpha },
|
[SchemeOut] = { OPAQUE, alpha },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
/* -l and -g options; controls number of lines and columns in grid if > 0 */
|
||||||
static unsigned int lines = 0;
|
static unsigned int lines = 0;
|
||||||
|
static unsigned int columns = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Characters not considered part of a word while deleting words
|
* Characters not considered part of a word while deleting words
|
||||||
|
|
7
dmenu.1
7
dmenu.1
|
@ -4,6 +4,8 @@ dmenu \- dynamic menu
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B dmenu
|
.B dmenu
|
||||||
.RB [ \-bfiv ]
|
.RB [ \-bfiv ]
|
||||||
|
.RB [ \-g
|
||||||
|
.IR columns ]
|
||||||
.RB [ \-l
|
.RB [ \-l
|
||||||
.IR lines ]
|
.IR lines ]
|
||||||
.RB [ \-m
|
.RB [ \-m
|
||||||
|
@ -55,8 +57,11 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||||
.B \-i
|
.B \-i
|
||||||
dmenu matches menu items case insensitively.
|
dmenu matches menu items case insensitively.
|
||||||
.TP
|
.TP
|
||||||
|
.BI \-g " columns"
|
||||||
|
dmenu lists items in a grid with the given number of columns.
|
||||||
|
.TP
|
||||||
.BI \-l " lines"
|
.BI \-l " lines"
|
||||||
dmenu lists items vertically, with the given number of lines.
|
dmenu lists items in a grid with the given number of lines.
|
||||||
.TP
|
.TP
|
||||||
.BI \-m " monitor"
|
.BI \-m " monitor"
|
||||||
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||||
|
|
32
dmenu.c
32
dmenu.c
|
@ -90,7 +90,7 @@ calcoffsets(void)
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
if (lines > 0)
|
if (lines > 0)
|
||||||
n = lines * bh;
|
n = lines * columns * bh;
|
||||||
else
|
else
|
||||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||||
/* calculate which items will begin the next page and previous page */
|
/* calculate which items will begin the next page and previous page */
|
||||||
|
@ -207,9 +207,15 @@ drawmenu(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
/* draw vertical list */
|
/* draw grid */
|
||||||
for (item = curr; item != next; item = item->right)
|
int i = 0;
|
||||||
drawitem(item, x, y += bh, mw - x);
|
for (item = curr; item != next; item = item->right, i++)
|
||||||
|
drawitem(
|
||||||
|
item,
|
||||||
|
x + ((i / lines) * ((mw - x) / columns)),
|
||||||
|
y + (((i % lines) + 1) * bh),
|
||||||
|
(mw - x) / columns
|
||||||
|
);
|
||||||
} else if (matches) {
|
} else if (matches) {
|
||||||
/* draw horizontal list */
|
/* draw horizontal list */
|
||||||
x += inputw;
|
x += inputw;
|
||||||
|
@ -751,6 +757,7 @@ setup(void)
|
||||||
bh = drw->fonts->h + 2;
|
bh = drw->fonts->h + 2;
|
||||||
lines = MAX(lines, 0);
|
lines = MAX(lines, 0);
|
||||||
mh = (lines + 1) * bh;
|
mh = (lines + 1) * bh;
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
i = 0;
|
i = 0;
|
||||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||||
|
@ -777,9 +784,9 @@ setup(void)
|
||||||
if (INTERSECT(x, y, 1, 1, info[i]))
|
if (INTERSECT(x, y, 1, 1, info[i]))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
x = info[i].x_org;
|
|
||||||
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
|
||||||
mw = info[i].width;
|
mw = info[i].width;
|
||||||
|
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
XFree(info);
|
XFree(info);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -787,11 +794,10 @@ setup(void)
|
||||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
die("could not get embedding window attributes: 0x%lx",
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
parentwin);
|
parentwin);
|
||||||
x = 0;
|
|
||||||
y = topbar ? 0 : wa.height - mh;
|
|
||||||
mw = wa.width;
|
mw = wa.width;
|
||||||
|
x = (wa.width - mw) / 2;
|
||||||
|
y = (wa.height - mh) / 2;
|
||||||
}
|
}
|
||||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
|
||||||
inputw = MIN(inputw, mw/3);
|
inputw = MIN(inputw, mw/3);
|
||||||
match();
|
match();
|
||||||
|
|
||||||
|
@ -860,9 +866,13 @@ main(int argc, char *argv[])
|
||||||
} else if (i + 1 == argc)
|
} else if (i + 1 == argc)
|
||||||
usage();
|
usage();
|
||||||
/* these options take one argument */
|
/* these options take one argument */
|
||||||
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
||||||
|
columns = atoi(argv[++i]);
|
||||||
|
if (lines == 0) lines = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
||||||
lines = atoi(argv[++i]);
|
lines = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-m"))
|
if (columns == 0) columns = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-m"))
|
||||||
mon = atoi(argv[++i]);
|
mon = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
prompt = argv[++i];
|
prompt = argv[++i];
|
||||||
|
|
Loading…
Reference in New Issue