Add -itt/-itb option for positioning items above/below prompt
This commit is contained in:
parent
6b6d5b77c5
commit
da05068117
|
@ -211,6 +211,12 @@ in the config files.
|
||||||
`-c, --center`
|
`-c, --center`
|
||||||
: Position spmenu at the center of the screen
|
: Position spmenu at the center of the screen
|
||||||
|
|
||||||
|
`-itt, --item-top`
|
||||||
|
: Position items above all other elements
|
||||||
|
|
||||||
|
`-itb, --item-bottom`
|
||||||
|
: Position items below all other elements
|
||||||
|
|
||||||
`-hm, --hide-mode`
|
`-hm, --hide-mode`
|
||||||
: Hide mode indicator
|
: Hide mode indicator
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,8 @@ spmenu = {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
/* Line options */
|
/* Line options */
|
||||||
line = ( { height = 1; // Height of each line (px)
|
line = ( { itemposition = 0; // Item position (0: Bottom, 1: Top)
|
||||||
|
height = 1; // Height of each line (px)
|
||||||
lines = 0; // Number of lines (number)
|
lines = 0; // Number of lines (number)
|
||||||
columns = 10; // Number of columns (number)
|
columns = 10; // Number of columns (number)
|
||||||
overridelines = 1; // Allow overriding lines using keybinds (0/1)
|
overridelines = 1; // Allow overriding lines using keybinds (0/1)
|
||||||
|
|
|
@ -126,6 +126,10 @@ void readargs(int argc, char *argv[]) {
|
||||||
menuposition = 1;
|
menuposition = 1;
|
||||||
} else if (!strcmp(argv[i], "-c") || (!strcmp(argv[i], "--center"))) { // appears at the center of the screen
|
} else if (!strcmp(argv[i], "-c") || (!strcmp(argv[i], "--center"))) { // appears at the center of the screen
|
||||||
menuposition = 2;
|
menuposition = 2;
|
||||||
|
} else if (!strcmp(argv[i], "-itt") || (!strcmp(argv[i], "--item-top"))) { // items are placed above prompt
|
||||||
|
itemposition = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-itb") || (!strcmp(argv[i], "--item-bottom"))) { // items are placed below prompt
|
||||||
|
menuposition = 0;
|
||||||
} else if (!strcmp(argv[i], "-nm") || (!strcmp(argv[i], "--normal"))) { // normal mode
|
} else if (!strcmp(argv[i], "-nm") || (!strcmp(argv[i], "--normal"))) { // normal mode
|
||||||
mode = 0;
|
mode = 0;
|
||||||
} else if (!strcmp(argv[i], "-im") || (!strcmp(argv[i], "--insert"))) { // insert mode
|
} else if (!strcmp(argv[i], "-im") || (!strcmp(argv[i], "--insert"))) { // insert mode
|
||||||
|
@ -663,6 +667,8 @@ void usage(int status) {
|
||||||
"spmenu -t, --top Position spmenu at the top of the screen\n"
|
"spmenu -t, --top Position spmenu at the top of the screen\n"
|
||||||
"spmenu -b, --bottom Position spmenu at the bottom of the screen\n"
|
"spmenu -b, --bottom Position spmenu at the bottom of the screen\n"
|
||||||
"spmenu -c, --center Position spmenu at the center of the screen\n"
|
"spmenu -c, --center Position spmenu at the center of the screen\n"
|
||||||
|
"spmenu -itt, --item-top Position items above all other elements\n"
|
||||||
|
"spmenu -itb, --item-bottom Position items below all other elements\n"
|
||||||
, status ? stderr : stdout);
|
, status ? stderr : stdout);
|
||||||
|
|
||||||
// more args
|
// more args
|
||||||
|
|
|
@ -753,6 +753,7 @@ void conf_init(void) {
|
||||||
config_setting_t *conf = config_setting_get_elem(line_setting, i);
|
config_setting_t *conf = config_setting_get_elem(line_setting, i);
|
||||||
|
|
||||||
// look up
|
// look up
|
||||||
|
config_setting_lookup_int(conf, "itemposition", &itemposition); // spmenu.line.itemposition
|
||||||
config_setting_lookup_int(conf, "height", &lineheight); // spmenu.line.height
|
config_setting_lookup_int(conf, "height", &lineheight); // spmenu.line.height
|
||||||
config_setting_lookup_int(conf, "lines", &lines); // spmenu.line.lines
|
config_setting_lookup_int(conf, "lines", &lines); // spmenu.line.lines
|
||||||
config_setting_lookup_int(conf, "columns", &columns); // spmenu.line.columns
|
config_setting_lookup_int(conf, "columns", &columns); // spmenu.line.columns
|
||||||
|
|
35
libs/draw.c
35
libs/draw.c
|
@ -686,39 +686,58 @@ void drawmenu_layer(void) {
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
get_mh();
|
get_mh();
|
||||||
|
|
||||||
|
int nh = 1;
|
||||||
|
|
||||||
// sp.bh must be removed from menu height resizing later
|
// sp.bh must be removed from menu height resizing later
|
||||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
||||||
y -= sp.bh;
|
y -= sp.bh;
|
||||||
|
nh = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hidemode) {
|
||||||
|
modew = pango_mode ? TEXTWM(tx.modetext) : TEXTW(tx.modetext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideprompt) {
|
if (!hideprompt) {
|
||||||
w = sp.promptw;
|
w = sp.promptw;
|
||||||
x = drawprompt(x, y, w);
|
x = drawprompt(x, y + (nh ? lines ? itemposition ? (sp.mh - sp.bh) : 0 : 0 : 0), w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideinput) {
|
if (!hideinput) {
|
||||||
w = (lines > 0 || !matches) ? sp.mw - x : sp.inputw;
|
w = (lines > 0 || !matches) ? sp.mw - x : sp.inputw;
|
||||||
x = drawinput(x, y, w);
|
x = drawinput(x, y + (nh ? lines ? itemposition ? (sp.mh - sp.bh) : 0 : 0 : 0), w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidemode) modew = pango_mode ? TEXTWM(tx.modetext) : TEXTW(tx.modetext);
|
|
||||||
|
|
||||||
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
||||||
if (!hideitem) drawitem(x, y, w);
|
if (!hideitem) {
|
||||||
|
drawitem(x, y - (nh ? lines ? itemposition ? sp.bh : 0 : 0 : 0), w);
|
||||||
|
}
|
||||||
|
|
||||||
if (!hidematchcount) {
|
if (!hidematchcount) {
|
||||||
w = numberw;
|
w = numberw;
|
||||||
drawnumber(sp.mw - numberw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w);
|
drawnumber(
|
||||||
|
sp.mw - numberw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh,
|
||||||
|
y + (nh ? lines ? itemposition ? (sp.mh - sp.bh) : 0 : 0 : 0),
|
||||||
|
w
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidemode) {
|
if (!hidemode) {
|
||||||
w = modew;
|
w = modew;
|
||||||
drawmode(sp.mw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w);
|
drawmode(
|
||||||
|
sp.mw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh,
|
||||||
|
y + (nh ? lines ? itemposition ? (sp.mh - sp.bh) : 0 : 0 : 0),
|
||||||
|
w
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidecaps) {
|
if (!hidecaps) {
|
||||||
w = capsw;
|
w = capsw;
|
||||||
drawcaps(sp.mw - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w);
|
drawcaps(
|
||||||
|
sp.mw - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh,
|
||||||
|
y + (nh ? lines ? itemposition ? (sp.mh - sp.bh) : 0 : 0 : 0),
|
||||||
|
w
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USEX
|
#if USEX
|
||||||
|
|
|
@ -103,6 +103,7 @@ static int regex = 0; /* Whether or not to enable regex ma
|
||||||
static char *listfile = NULL; /* File to read entries from instead of stdin. NULL means read from stdin instead. */
|
static char *listfile = NULL; /* File to read entries from instead of stdin. NULL means read from stdin instead. */
|
||||||
|
|
||||||
/* Line options */
|
/* Line options */
|
||||||
|
static int itemposition = 1; /* Item position (0: Bottom, 1: Top) */
|
||||||
static int lineheight = 1; /* Line height (0: Calculate automatically) */
|
static int lineheight = 1; /* Line height (0: Calculate automatically) */
|
||||||
static int lines = 0; /* Default number of lines */
|
static int lines = 0; /* Default number of lines */
|
||||||
static int columns = 10; /* Default number of columns */
|
static int columns = 10; /* Default number of columns */
|
||||||
|
|
|
@ -438,6 +438,7 @@ void theme_load(void) {
|
||||||
config_setting_t *conf = config_setting_get_elem(line_setting, i);
|
config_setting_t *conf = config_setting_get_elem(line_setting, i);
|
||||||
|
|
||||||
// look up
|
// look up
|
||||||
|
config_setting_lookup_int(conf, "itemposition", &itemposition); // theme.line.itemposition
|
||||||
config_setting_lookup_int(conf, "height", &lineheight); // theme.line.height
|
config_setting_lookup_int(conf, "height", &lineheight); // theme.line.height
|
||||||
config_setting_lookup_int(conf, "indentitems", &indentitems); // theme.line.indentitems
|
config_setting_lookup_int(conf, "indentitems", &indentitems); // theme.line.indentitems
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,9 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
|
||||||
|
|
||||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
} else if (lines && ey < h + menumarginv && ey > menumarginv) {
|
} else if (!itemposition && lines && ey <= h + menumarginv && ey >= menumarginv) {
|
||||||
|
yp = 1;
|
||||||
|
} else if (itemposition && lines && ey >= (sp.mh - h) + menumarginv) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
} else if (!lines) {
|
} else if (!lines) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
|
@ -320,7 +322,7 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
|
||||||
|
|
||||||
ey -= menumarginv;
|
ey -= menumarginv;
|
||||||
|
|
||||||
if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) {
|
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) || itemposition) {
|
||||||
ey += h;
|
ey += h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ void buttonpress_x11(XEvent *e) {
|
||||||
|
|
||||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
} else if (lines && ev->y < h + menumarginv && ev->y > menumarginv) {
|
} else if (!itemposition && lines && ev->y <= h + menumarginv && ev->y >= menumarginv) {
|
||||||
|
yp = 1;
|
||||||
|
} else if (itemposition && lines && ev->y >= (sp.mh - h) + menumarginv) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
} else if (!lines) {
|
} else if (!lines) {
|
||||||
yp = 1;
|
yp = 1;
|
||||||
|
@ -69,7 +71,7 @@ void buttonpress_x11(XEvent *e) {
|
||||||
|
|
||||||
ev->y -= menumarginv;
|
ev->y -= menumarginv;
|
||||||
|
|
||||||
if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) {
|
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) || itemposition) {
|
||||||
ev->y += h;
|
ev->y += h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
spmenu.1
6
spmenu.1
|
@ -239,6 +239,12 @@ Position spmenu at the bottom of the screen
|
||||||
\f[V]-c, --center\f[R]
|
\f[V]-c, --center\f[R]
|
||||||
Position spmenu at the center of the screen
|
Position spmenu at the center of the screen
|
||||||
.TP
|
.TP
|
||||||
|
\f[V]-itt, --item-top\f[R]
|
||||||
|
Position items above all other elements
|
||||||
|
.TP
|
||||||
|
\f[V]-itb, --item-bottom\f[R]
|
||||||
|
Position items below all other elements
|
||||||
|
.TP
|
||||||
\f[V]-hm, --hide-mode\f[R]
|
\f[V]-hm, --hide-mode\f[R]
|
||||||
Hide mode indicator
|
Hide mode indicator
|
||||||
.TP
|
.TP
|
||||||
|
|
Loading…
Reference in a new issue