grid-nodoc.patch (1522B)
1 diff --git a/dmenu.c b/dmenu.c 2 index 6b8f51b..d79b6bb 100644 3 --- a/dmenu.c 4 +++ b/dmenu.c 5 @@ -77,7 +77,7 @@ calcoffsets(void) 6 int i, n; 7 8 if (lines > 0) 9 - n = lines * bh; 10 + n = lines * columns * bh; 11 else 12 n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); 13 /* calculate which items will begin the next page and previous page */ 14 @@ -152,9 +152,15 @@ drawmenu(void) 15 } 16 17 if (lines > 0) { 18 - /* draw vertical list */ 19 - for (item = curr; item != next; item = item->right) 20 - drawitem(item, x, y += bh, mw - x); 21 + /* draw grid */ 22 + int i = 0; 23 + for (item = curr; item != next; item = item->right, i++) 24 + drawitem( 25 + item, 26 + x + ((i / lines) * ((mw - x) / columns)), 27 + y + (((i % lines) + 1) * bh), 28 + (mw - x) / columns 29 + ); 30 } else if (matches) { 31 /* draw horizontal list */ 32 x += inputw; 33 @@ -708,9 +714,13 @@ main(int argc, char *argv[]) 34 } else if (i + 1 == argc) 35 usage(); 36 /* these options take one argument */ 37 - else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ 38 + else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */ 39 + columns = atoi(argv[++i]); 40 + if (lines == 0) lines = 1; 41 + } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */ 42 lines = atoi(argv[++i]); 43 - else if (!strcmp(argv[i], "-m")) 44 + if (columns == 0) columns = 1; 45 + } else if (!strcmp(argv[i], "-m")) 46 mon = atoi(argv[++i]); 47 else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ 48 prompt = argv[++i]; 49 -- 50 2.23.1 51