This commit is contained in:
DarthMooMancer
2025-08-08 16:08:29 -04:00
parent 8738b54566
commit 5d4ec31a60
9 changed files with 105 additions and 306 deletions
+21 -65
View File
@@ -48,7 +48,19 @@ static XIC xic;
static Drw *drw;
static Clr *scheme[SchemeLast];
#include "config.h"
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
static const char *fonts[] = {
"CaskaydiaCove NFM style:SemiBold:size=11"
};
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
[SchemeNorm] = { "#D3C6AA", "#272E33" },
[SchemeSel] = { "#272E33", "#DBBC7F" },
[SchemeOut] = { "#E67E80", "#272E33" },
};
static unsigned int lines = 0;
static const char worddelimiters[] = " ";
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr;
@@ -79,7 +91,7 @@ calcoffsets(void)
int i, n;
if (lines > 0)
n = lines * columns * bh;
n = lines * bh;
else
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
/* calculate which items will begin the next page and previous page */
@@ -164,15 +176,10 @@ drawmenu(void)
}
if (lines > 0) {
/* draw grid */
int i = 0;
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
);
/* draw vertical list */
for (item = curr; item != next; item = item->right)
drawitem(item, x, y += bh, mw - x);
} else if (matches) {
/* draw horizontal list */
x += inputw;
@@ -329,8 +336,6 @@ keypress(XKeyEvent *ev)
int len;
KeySym ksym = NoSymbol;
Status status;
int i, offscreen = 0;
struct item *tmpsel;
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
switch (status) {
@@ -462,27 +467,6 @@ insert:
calcoffsets();
break;
case XK_Left:
if (columns > 1) {
if (!sel)
return;
tmpsel = sel;
for (i = 0; i < lines; i++) {
if (!tmpsel->left || tmpsel->left->right != tmpsel) {
if (offscreen)
break;
return;
}
if (tmpsel == curr)
offscreen = 1;
tmpsel = tmpsel->left;
}
sel = tmpsel;
if (offscreen) {
curr = prev;
calcoffsets();
}
break;
}
case XK_KP_Left:
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
cursor = nextrune(-1);
@@ -523,27 +507,6 @@ insert:
sel->out = 1;
break;
case XK_Right:
if (columns > 1) {
if (!sel)
return;
tmpsel = sel;
for (i = 0; i < lines; i++) {
if (!tmpsel->right || tmpsel->right->left != tmpsel) {
if (offscreen)
break;
return;
}
tmpsel = tmpsel->right;
if (tmpsel == next)
offscreen = 1;
}
sel = tmpsel;
if (offscreen) {
curr = next;
calcoffsets();
}
break;
}
case XK_KP_Right:
if (text[cursor] != '\0') {
cursor = nextrune(+1);
@@ -735,10 +698,7 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++)
/* these options take no arguments */
if (!strcmp(argv[i], "-v")) { /* prints version information */
puts("dmenu-"VERSION);
exit(0);
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
@@ -748,13 +708,9 @@ main(int argc, char *argv[])
} else if (i + 1 == argc)
usage();
/* these options take one argument */
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 */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]);
if (columns == 0) columns = 1;
} else if (!strcmp(argv[i], "-m"))
else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i];