From af34cca93b2954a43804e278267454bb0cf67a67 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 29 Oct 2023 18:14:34 +0530 Subject: applied grid patch --- dmenu.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'dmenu.c') diff --git a/dmenu.c b/dmenu.c index 9f17c7d..69a5e07 100644 --- a/dmenu.c +++ b/dmenu.c @@ -84,7 +84,7 @@ calcoffsets(void) int i, n; if (lines > 0) - n = lines * bh; + n = lines * columns * bh; else n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); /* calculate which items will begin the next page and previous page */ @@ -212,9 +212,15 @@ drawmenu(void) } if (lines > 0) { - /* draw vertical list */ - for (item = curr; item != next; item = item->right) - drawitem(item, x, y += bh, mw - x); + /* 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 + ); } else if (matches) { /* draw horizontal list */ x += inputw; @@ -799,14 +805,19 @@ main(int argc, char *argv[]) } else if (i + 1 == argc) usage(); /* 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]); + } else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ - lineheight = atoi(argv[++i]); + //lineheight = atoi(argv[++i]); lineheight = MAX(lineheight, min_lineheight); - } - else if (!strcmp(argv[i], "-m")) + } else if (!strcmp(argv[i], "-m")) { + if (columns == 0) columns = 1; mon = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if (!strcmp(argv[i], "-fn")) /* font or font set */ -- cgit v1.2.3