Re: [dev] [dmenu] An x, y, w patch for dmenu 4.4

2011-08-21 Thread anonymous
On Sun, Aug 21, 2011 at 02:24:27PM -0400, Kurt H Maier wrote:
> On Sun, Aug 21, 2011 at 12:52 PM, Bastien Dejean  wrote:
> > https://bbs.archlinux.org/viewtopic.php?id=124915
> 
> If it's not important enough to copy and paste the text from the
> stupid forum, it's not important enough for us to read.
> 
> 

It is attached.




Re: [dev] [dmenu] An x, y, w patch for dmenu 4.4

2011-08-21 Thread Kurt H Maier
On Sun, Aug 21, 2011 at 12:52 PM, Bastien Dejean  wrote:
> https://bbs.archlinux.org/viewtopic.php?id=124915

If it's not important enough to copy and paste the text from the
stupid forum, it's not important enough for us to read.


-- 
# Kurt H Maier



[dev] [dmenu] An x, y, w patch for dmenu 4.4

2011-08-21 Thread Bastien Dejean
https://bbs.archlinux.org/viewtopic.php?id=124915
diff -u dmenu-4.4/dmenu.1 dmenu/dmenu.1
--- dmenu-4.4/dmenu.1   2011-07-19 22:31:28.0 +0200
+++ dmenu/dmenu.1   2011-08-06 23:18:20.0 +0200
@@ -41,6 +41,9 @@
 .B \-b
 dmenu appears at the bottom of the screen.
 .TP
+.B \-q
+dmenu will not show any items if the search string is empty.
+.TP
 .B \-f
 dmenu grabs the keyboard before reading stdin.  This is faster, but may lock up
 X if stdin is from a terminal.
@@ -57,6 +60,15 @@
 .BI \-fn " font"
 defines the font or font set used.
 .TP
+.BI \-x " xoffset"
+defines the offset from the left border of the screen.
+.TP
+.BI \-y " yoffset"
+defines the offset from the top border of the screen.
+.TP
+.BI \-w " width"
+defines the desired menu window width.
+.TP
 .BI \-nb " color"
 defines the normal background color.
 .IR #RGB ,
diff -u dmenu-4.4/dmenu.c dmenu/dmenu.c
--- dmenu-4.4/dmenu.c   2011-07-19 22:31:28.0 +0200
+++ dmenu/dmenu.c   2011-08-06 23:17:53.0 +0200
@@ -42,6 +42,9 @@
 static int bh, mw, mh;
 static int inputw, promptw;
 static int lines = 0;
+static int xoffset = 0;
+static int yoffset = 0;
+static int width = 0;
 static size_t cursor = 0;
 static const char *font = NULL;
 static const char *prompt = NULL;
@@ -53,6 +56,7 @@
 static unsigned long selcol[ColLast];
 static Atom utf8;
 static Bool topbar = True;
+static Bool quiet = False;
 static DC *dc;
 static Item *items = NULL;
 static Item *matches, *matchend;
@@ -75,6 +79,8 @@
}
else if(!strcmp(argv[i], "-b"))
topbar = False;
+   else if(!strcmp(argv[i], "-q"))
+   quiet = True;
else if(!strcmp(argv[i], "-f"))
fast = True;
else if(!strcmp(argv[i], "-i")) {
@@ -84,6 +90,12 @@
else if(i+1 == argc)
usage();
/* double flags */
+   else if(!strcmp(argv[i], "-x"))
+   xoffset = atoi(argv[++i]);
+   else if(!strcmp(argv[i], "-y"))
+   yoffset = atoi(argv[++i]);
+   else if(!strcmp(argv[i], "-w"))
+   width = atoi(argv[++i]);
else if(!strcmp(argv[i], "-l"))
lines = atoi(argv[++i]);
else if(!strcmp(argv[i], "-p"))
@@ -177,28 +189,30 @@
if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)
drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol));
 
-   if(lines > 0) {
-   dc->w = mw - dc->x;
-   for(item = curr; item != next; item = item->right) {
-   dc->y += dc->h;
-   drawtext(dc, item->text, (item == sel) ? selcol : 
normcol);
-   }
-   }
-   else if(matches) {
-   dc->x += inputw;
-   dc->w = textw(dc, "<");
-   if(curr->left)
-   drawtext(dc, "<", normcol);
-   for(item = curr; item != next; item = item->right) {
-   dc->x += dc->w;
-   dc->w = MIN(textw(dc, item->text), mw - dc->x - 
textw(dc, ">"));
-   drawtext(dc, item->text, (item == sel) ? selcol : 
normcol);
-   }
-   dc->w = textw(dc, ">");
-   dc->x = mw - dc->w;
-   if(next)
-   drawtext(dc, ">", normcol);
-   }
+if(!quiet || strlen(text) > 0) {
+if(lines > 0) {
+dc->w = mw - dc->x;
+for(item = curr; item != next; item = item->right) {
+dc->y += dc->h;
+drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+}
+}
+else if(matches) {
+dc->x += inputw;
+dc->w = textw(dc, "<");
+if(curr->left)
+drawtext(dc, "<", normcol);
+for(item = curr; item != next; item = item->right) {
+dc->x += dc->w;
+dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, 
">"));
+drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+}
+dc->w = textw(dc, ">");
+dc->x = mw - dc->w;
+if(next)
+drawtext(dc, ">", normcol);
+}
+}
mapdc(dc, win, mw, mh);
 }
 
@@ -501,7 +515,7 @@
if(INRECT(x, y, info[i].x_org, info[i].y_org, 
info[i].width, info[i].height))
break;
x = info[i].x_org;
-   y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+   y = info[i].y_org + (topbar ? yoffset : info[i].height - mh - 
yoffset);
mw = info[i].width;
XFree(info);
}
@@ -509,9 +523,13 @@
 #endif
{
x = 0;
-   y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh;
+