Julien Jehannet avatar Julien Jehannet committed 71c63e0 Merge

(merge)

Comments (0)

Files changed (3)

+diff -up dmenu-4.0/dmenu.1 dmenu-4.0_ms_nl/dmenu.1
+--- dmenu-4.0/dmenu.1	2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_ms_nl/dmenu.1	2009-11-19 23:01:15.000000000 +0100
+@@ -11,6 +11,8 @@ dmenu \- dynamic menu
+ .RB [ \-p " <prompt>"]
+ .RB [ \-sb " <color>"]
+ .RB [ \-sf " <color>"]
++.RB [ \-ms ]
++.RB [ \-nl ]
+ .RB [ \-v ]
+ .SH DESCRIPTION
+ .SS Overview
+@@ -44,6 +46,12 @@ defines the selected background color (#
+ .B \-sf <color>
+ defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
+ .TP
++.B \-ms
++multi-select; selecting an item and pressing return won't terminate dmenu.
++.TP
++.B \-nl
++seperates standard output by newlines.
++.TP
+ .B \-v
+ prints version information to standard output, then exits.
+ .SH USAGE
+diff -up dmenu-4.0/dmenu.c dmenu-4.0_ms_nl/dmenu.c
+--- dmenu-4.0/dmenu.c	2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_ms_nl/dmenu.c	2009-11-19 23:04:59.000000000 +0100
+@@ -69,6 +69,7 @@ static int textw(const char *text);
+ /* variables */
+ static char *maxname = NULL;
+ static char *prompt = NULL;
++static char *nl = "";
+ static char text[4096];
+ static int cmdw = 0;
+ static int promptw = 0;
+@@ -77,6 +78,7 @@ static int screen;
+ static unsigned int mw, mh;
+ static unsigned int numlockmask = 0;
+ static Bool running = True;
++static Bool multiselect = False;
+ static Display *dpy;
+ static DC dc;
+ static Item *allitems = NULL;	/* first of all items */
+@@ -448,13 +450,13 @@ kpress(XKeyEvent * e) {
+ 		break;
+ 	case XK_Return:
+ 		if((e->state & ShiftMask) && *text)
+-			fprintf(stdout, "%s", text);
++			fprintf(stdout, "%s%s", text, nl);
+ 		else if(sel)
+-			fprintf(stdout, "%s", sel->text);
++			fprintf(stdout, "%s%s", sel->text, nl);
+ 		else if(*text)
+-			fprintf(stdout, "%s", text);
++			fprintf(stdout, "%s%s", text, nl);
+ 		fflush(stdout);
+-		running = False;
++		running = multiselect;
+ 		break;
+ 	case XK_Right:
+ 		if(!(sel && sel->right))
+@@ -694,11 +696,15 @@ main(int argc, char *argv[]) {
+ 		else if(!strcmp(argv[i], "-sf")) {
+ 			if(++i < argc) selfgcolor = argv[i];
+ 		}
++		else if(!strcmp(argv[i], "-ms"))
++			multiselect = True;
++		else if(!strcmp(argv[i], "-nl"))
++			nl = "\n";
+ 		else if(!strcmp(argv[i], "-v"))
+ 			eprint("dmenu-"VERSION", © 2006-2008 dmenu engineers, see LICENSE for details\n");
+ 		else
+ 			eprint("usage: dmenu [-i] [-b] [-fn <font>] [-nb <color>] [-nf <color>]\n"
+-			       "             [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
++			       "             [-p <prompt>] [-sb <color>] [-sf <color>] [-ms] [-nl] [-v]\n");
+ 	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ 		fprintf(stderr, "warning: no locale support\n");
+ 	if(!(dpy = XOpenDisplay(NULL)))
+diff -r 2b9683c50723 -r ebcc0d8213e0 dmenu.c
+--- a/dmenu.c	Wed Dec 01 20:25:10 2010 +0000
++++ b/dmenu.c	Tue Dec 14 15:53:44 2010 +0300
+@@ -7,6 +7,7 @@
+ #include <X11/Xlib.h>
+ #include <X11/Xatom.h>
+ #include <X11/Xutil.h>
++#include <X11/Xresource.h>
+ #ifdef XINERAMA
+ #include <X11/extensions/Xinerama.h>
+ #endif
+@@ -37,6 +38,7 @@
+ static void run(void);
+ static void setup(void);
+ static void usage(void);
++static void read_resourses(void);
+ 
+ static char text[BUFSIZ];
+ static int bh, mw, mh;
+@@ -47,10 +49,10 @@
+ static size_t cursor = 0;
+ static const char *font = NULL;
+ static const char *prompt = NULL;
+-static const char *normbgcolor = "#cccccc";
+-static const char *normfgcolor = "#000000";
+-static const char *selbgcolor  = "#0066ff";
+-static const char *selfgcolor  = "#ffffff";
++static const char *normbgcolor = NULL;
++static const char *normfgcolor = NULL;
++static const char *selbgcolor  = NULL;
++static const char *selfgcolor  = NULL;
+ static unsigned long normcol[ColLast];
+ static unsigned long selcol[ColLast];
+ static Atom utf8;
+@@ -101,6 +103,7 @@
+ 			usage();
+ 
+ 	dc = initdc();
++	read_resourses();
+ 	initfont(dc, font);
+ 	readstdin();
+ 	setup();
+@@ -109,6 +112,42 @@
+ 	return EXIT_FAILURE;  /* should not reach */
+ }
+ 
++/* Set font and colors from X resources database if they are not set
++ * from command line */
++void
++read_resourses(void) {
++	XrmDatabase xdb;
++	char* xrm;
++	char* datatype[20];
++	XrmValue xvalue;
++
++	XrmInitialize();
++	xrm = XResourceManagerString(dc->dpy);
++	if( xrm != NULL ) {
++		xdb = XrmGetStringDatabase(xrm);
++		if( font == NULL && XrmGetResource(xdb, "dmenu.font", "*", datatype, &xvalue) == True )
++			font = strdup(xvalue.addr);
++		if( normfgcolor == NULL && XrmGetResource(xdb, "dmenu.foreground", "*", datatype, &xvalue) == True )
++			normfgcolor = strdup(xvalue.addr);
++		if( normbgcolor == NULL && XrmGetResource(xdb, "dmenu.background", "*", datatype, &xvalue) == True )
++			normbgcolor = strdup(xvalue.addr);
++		if( selfgcolor == NULL && XrmGetResource(xdb, "dmenu.selforeground", "*", datatype, &xvalue) == True )
++			selfgcolor = strdup(xvalue.addr);
++		if( selbgcolor == NULL && XrmGetResource(xdb, "dmenu.selbackground", "*", datatype, &xvalue) == True )
++			selbgcolor = strdup(xvalue.addr);
++		XrmDestroyDatabase(xdb);
++	}
++	/* Set default colors if they are not set */
++	if( normbgcolor == NULL )
++		normbgcolor = "#cccccc";
++	if( normfgcolor == NULL )
++		normfgcolor = "#000000";
++	if( selbgcolor == NULL )
++		selbgcolor  = "#0066ff";
++	if( selfgcolor == NULL )
++		selfgcolor  = "#ffffff";
++}
++
+ void
+ appenditem(Item *item, Item **list, Item **last) {
+ 	if(!*last)
 dmenu-config.h
+dmenu-xrdb.diff
+dmenu-ms_nl.diff
 dwm-config.h
 dmenu-xresources.diff
 dwm-current_desktop.diff
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.