cleanup 1654d6cd
Connor Lane Smith · 2011-05-15 02:37 4 file(s) · +18 −19
Makefile +12 −7
3 3
4 4
include config.mk
5 5
6 +
SRC = dmenu.c draw.c
7 +
OBJ = ${SRC:.c=.o}
8 +
6 9
all: options dmenu
7 10
8 11
options:
11 14
	@echo "LDFLAGS  = ${LDFLAGS}"
12 15
	@echo "CC       = ${CC}"
13 16
14 -
dmenu: dmenu.o draw.o
15 -
	@echo CC -o $@
16 -
	@${CC} -o $@ dmenu.o draw.o ${LDFLAGS}
17 -
18 -
.c.o: config.mk
17 +
.c.o:
19 18
	@echo CC -c $<
20 19
	@${CC} -c $< ${CFLAGS}
21 20
21 +
${OBJ}: config.mk
22 +
23 +
dmenu: ${OBJ}
24 +
	@echo CC -o $@
25 +
	@${CC} -o $@ ${OBJ} ${LDFLAGS}
26 +
22 27
clean:
23 28
	@echo cleaning
24 -
	@rm -f dmenu dmenu.o draw.o dmenu-${VERSION}.tar.gz
29 +
	@rm -f dmenu ${OBJ} dmenu-${VERSION}.tar.gz
25 30
26 31
dist: clean
27 32
	@echo creating dist tarball
28 33
	@mkdir -p dmenu-${VERSION}
29 -
	@cp LICENSE Makefile README config.mk dmenu.1 dmenu.c draw.c draw.h dmenu_path dmenu_run dmenu-${VERSION}
34 +
	@cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_path dmenu_run ${SRC} dmenu-${VERSION}
30 35
	@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
31 36
	@gzip dmenu-${VERSION}.tar
32 37
	@rm -rf dmenu-${VERSION}
config.mk +1 −5
1 1
# dmenu version
2 2
VERSION = 4.3
3 3
4 -
# dmenu_path cache (absolute or relative to $HOME)
5 -
CACHE = .dmenu_cache
6 -
7 -
8 4
# paths
9 5
PREFIX = /usr/local
10 6
MANPREFIX = ${PREFIX}/share/man
21 17
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
22 18
23 19
# flags
24 -
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" -DCACHE=\"${CACHE}\" ${XINERAMAFLAGS}
20 +
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
25 21
CFLAGS   = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
26 22
LDFLAGS  = -s ${LIBS}
27 23
dmenu.1 +2 −2
31 31
.B dmenu
32 32
is a dynamic menu for X, originally designed for
33 33
.BR dwm (1).
34 -
It manages huge numbers of user-defined menu items efficiently.
34 +
It manages huge numbers of user\-defined menu items efficiently.
35 35
.P
36 -
dmenu reads a list of newline-separated items from stdin and creates a menu.
36 +
dmenu reads a list of newline\-separated items from stdin and creates a menu.
37 37
When the user selects an item or enters any text and presses Return, their
38 38
choice is printed to stdout and dmenu terminates.
39 39
.P
draw.c +3 −5
25 25
	(fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1);
26 26
}
27 27
28 -
29 28
void
30 29
drawtext(DC *dc, const char *text, unsigned long col[ColLast]) {
31 -
	char buf[256];
30 +
	char buf[BUFSIZ];
32 31
	size_t mn, n = strlen(text);
33 32
34 33
	/* shorten text if necessary */
35 -
	for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) > dc->w - dc->font.height/2; mn--)
34 +
	for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) + dc->font.height/2 > dc->w; mn--)
36 35
		if(mn == 0)
37 36
			return;
38 37
	memcpy(buf, text, mn);
157 156
resizedc(DC *dc, unsigned int w, unsigned int h) {
158 157
	if(dc->canvas)
159 158
		XFreePixmap(dc->dpy, dc->canvas);
159 +
160 160
	dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
161 161
	                           DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));
162 -
	dc->x = dc->y = 0;
163 162
	dc->w = w;
164 163
	dc->h = h;
165 -
	dc->invert = False;
166 164
}
167 165
168 166
int