[CONTACT]

[ABOUT]

[POLICY]

git clone dmenu dmenu Log gph

Found at: gopher.r-36.net:70/scm/dmenu/commit/bb3e33def3e5156594ac59b75dc52798accbebcd.gph

tno -m, cleanup - dmenu - Dmenu fork with xft fonts.

git clone git://r-36.net/dmenu

Log

Files

Refs

README

LICENSE

---

commit bb3e33def3e5156594ac59b75dc52798accbebcd

parent 3a60b19514705f7f61908fd727d2e69565ee1947

Author: Connor Lane Smith <cls@lubutu.com>

Date:   Wed, 18 May 2011 16:20:03 +0100
no -m, cleanup
Diffstat:
  dmenu.1                             |      17 ++++++-----------
  dmenu.c                             |      35 ++++++++++++++++---------------
  draw.c                              |      22 +++++++++-------------
3 files changed, 33 insertions(+), 41 deletions(-)
---

diff --git a/dmenu.1 b/dmenu.1

t@@ -8,8 +8,6 @@ dmenu \- dynamic menu
 .RB [ \-i ]
 .RB [ \-l
 .IR lines ]
-.RB [ \-m
-.IR monitor ]
 .RB [ \-p
 .IR prompt ]
 .RB [ \-fn
t@@ -58,9 +56,6 @@ dmenu matches menu items case insensitively.
 .BI \-l " lines"
 dmenu lists items vertically, with the given number of lines.
 .TP
-.BI \-m " monitor"
-dmenu appears on the given Xinerama screen.
-.TP
 .BI \-p " prompt"
 defines the prompt to be displayed to the left of the input field.
 .TP
t@@ -86,23 +81,23 @@ defines the selected foreground color.
 prints version information to stdout, then exits.
 .SH USAGE
 dmenu is completely controlled by the keyboard.  Besides standard Unix line
-editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the
+editing and item selection (arrow keys, page up/down, home and end), the
 following keys are recognized:
 .TP
-.B Tab (Control\-i)
+.B Tab (Ctrl\-i)
 Copy the selected item to the input field.
 .TP
-.B Return (Control\-j)
+.B Return (Ctrl\-j)
 Confirm selection.  Prints the selected item to stdout and exits, returning
 success.
 .TP
-.B Shift\-Return (Control\-Shift\-j)
+.B Shift\-Return (Ctrl\-Shift\-j)
 Confirm input.  Prints the input text to stdout and exits, returning success.
 .TP
-.B Escape (Control\-c)
+.B Escape (Ctrl\-c)
 Exit without selecting an item, returning failure.
 .TP
-.B Control\-y
+.B Ctrl\-y
 Paste the current X selection into the input field.
 .SH SEE ALSO
 .BR dwm (1)

diff --git a/dmenu.c b/dmenu.c

t@@ -36,13 +36,12 @@ static void paste(void);
 static void readstdin(void);
 static void run(void);
 static void setup(void);
+static void usage(void);
 static char text[BUFSIZ] = "";
 static int bh, mw, mh;
-static int inputw;
+static int inputw, promptw;
 static int lines = 0;
-static int monitor = -1;
-static int promptw;
 static size_t cursor = 0;
 static const char *font = NULL;
 static const char *prompt = NULL;
t@@ -70,7 +69,7 @@ main(int argc, char *argv[]) {
         for(i = 1; i < argc; i++)
                 /* single flags */
                 if(!strcmp(argv[i], "-v")) {
-                        fputs("dmenu-"VERSION", © 2006-2011 dmenu engineers, see LICENSE for details\n", stdout);
+                        puts("dmenu-"VERSION", © 2006-2011 dmenu engineers, see LICENSE for details");
                         exit(EXIT_SUCCESS);
                 }
                 else if(!strcmp(argv[i], "-b"))
t@@ -80,12 +79,10 @@ main(int argc, char *argv[]) {
                 else if(!strcmp(argv[i], "-i"))
                         fstrncmp = strncasecmp;
                 else if(i+1 == argc)
-                        goto usage;
+                        usage();
                 /* double flags */
                 else if(!strcmp(argv[i], "-l"))
                         lines = atoi(argv[++i]);
-                else if(!strcmp(argv[i], "-m"))
-                        monitor = atoi(argv[++i]);
                 else if(!strcmp(argv[i], "-p"))
                         prompt = argv[++i];
                 else if(!strcmp(argv[i], "-fn"))
t@@ -99,7 +96,7 @@ main(int argc, char *argv[]) {
                 else if(!strcmp(argv[i], "-sf"))
                         selfgcolor = argv[++i];
                 else
-                        goto usage;
+                        usage();
         dc = initdc();
         initfont(dc, font);
t@@ -114,12 +111,8 @@ main(int argc, char *argv[]) {
         }
         setup();
         run();
-        return EXIT_FAILURE;
-usage:
-        fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
-              "             [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
-        return EXIT_FAILURE;
+        return EXIT_FAILURE;  /* should not reach */
 }
 void
t@@ -452,7 +445,7 @@ readstdin(void) {
         char buf[sizeof text], *p, *maxstr = NULL;
         size_t i, max = 0, size = 0;
-        for(i = 0; fgets(buf, sizeof buf, stdin); items[++i].text = NULL) {
+        for(i = 0; fgets(buf, sizeof buf, stdin); i++) {
                 if(i+1 >= size / sizeof *items)
                         if(!(items = realloc(items, (size += BUFSIZ))))
                                 eprintf("cannot realloc %u bytes:", size);
t@@ -463,6 +456,8 @@ readstdin(void) {
                 if(strlen(items[i].text) > max)
                         max = strlen(maxstr = items[i].text);
         }
+        if(items)
+                items[i].text = NULL;
         inputw = maxstr ? textw(dc, maxstr) : 0;
 }
t@@ -519,8 +514,7 @@ setup(void) {
                 XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
                 for(i = 0; i < n-1; i++)
-                        if((monitor == info[i].screen_number)
-                        || (monitor < 0 && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)))
+                        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);
t@@ -534,8 +528,8 @@ setup(void) {
                 y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh;
                 mw = DisplayWidth(dc->dpy, screen);
         }
-        inputw = MIN(inputw, mw/3);
         promptw = prompt ? textw(dc, prompt) : 0;
+        inputw = MIN(inputw, mw/3);
         match(False);
         /* menu window */
t@@ -551,3 +545,10 @@ setup(void) {
         resizedc(dc, mw, mh);
         drawmenu();
 }
+
+void
+usage(void) {
+        fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n"
+              "             [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
+        exit(EXIT_FAILURE);
+}

diff --git a/draw.c b/draw.c

t@@ -9,21 +9,17 @@
 #define MAX(a, b)  ((a) > (b) ? (a) : (b))
 #define MIN(a, b)  ((a) < (b) ? (a) : (b))
-#define DEFFONT    "fixed"
+#define DEFAULTFN  "fixed"
 static Bool loadfont(DC *dc, const char *fontstr);
 void
 drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) {
-        XRectangle r;
-
-        r.x = dc->x + x;
-        r.y = dc->y + y;
-        r.width  = fill ? w : w-1;
-        r.height = fill ? h : h-1;
-
         XSetForeground(dc->dpy, dc->gc, color);
-        (fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1);
+        if(fill)
+                XFillRectangle(dc->dpy, dc->canvas, dc->gc, dc->x + x, dc->y + y, w, h);
+        else
+                XDrawRectangle(dc->dpy, dc->canvas, dc->gc, dc->x + x, dc->y + y, w-1, h-1);
 }
 void
t@@ -65,7 +61,7 @@ eprintf(const char *fmt, ...) {
         vfprintf(stderr, fmt, ap);
         va_end(ap);
-        if(fmt[strlen(fmt)-1] == ':') {
+        if(fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':') {
                 fputc(' ', stderr);
                 perror(NULL);
         }
t@@ -113,11 +109,11 @@ initdc(void) {
 void
 initfont(DC *dc, const char *fontstr) {
-        if(!loadfont(dc, fontstr ? fontstr : DEFFONT)) {
+        if(!loadfont(dc, fontstr ? fontstr : DEFAULTFN)) {
                 if(fontstr != NULL)
                         fprintf(stderr, "cannot load font '%s'\n", fontstr);
-                if(fontstr == NULL || !loadfont(dc, DEFFONT))
-                        eprintf("cannot load font '%s'\n", DEFFONT);
+                if(fontstr == NULL || !loadfont(dc, DEFAULTFN))
+                        eprintf("cannot load font '%s'\n", DEFAULTFN);
         }
         dc->font.height = dc->font.ascent + dc->font.descent;
 }
.


AD:

NEW PAGES:

[ODDNUGGET]

[GOPHER]