cleanup
This commit is contained in:
parent
6cc0b0dc08
commit
1654d6cd62
4 changed files with 18 additions and 19 deletions
19
Makefile
19
Makefile
|
@ -3,6 +3,9 @@
|
|||
|
||||
include config.mk
|
||||
|
||||
SRC = dmenu.c draw.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: options dmenu
|
||||
|
||||
options:
|
||||
|
@ -11,22 +14,24 @@ options:
|
|||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
|
||||
dmenu: dmenu.o draw.o
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ dmenu.o draw.o ${LDFLAGS}
|
||||
|
||||
.c.o: config.mk
|
||||
.c.o:
|
||||
@echo CC -c $<
|
||||
@${CC} -c $< ${CFLAGS}
|
||||
|
||||
${OBJ}: config.mk
|
||||
|
||||
dmenu: ${OBJ}
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
||||
clean:
|
||||
@echo cleaning
|
||||
@rm -f dmenu dmenu.o draw.o dmenu-${VERSION}.tar.gz
|
||||
@rm -f dmenu ${OBJ} dmenu-${VERSION}.tar.gz
|
||||
|
||||
dist: clean
|
||||
@echo creating dist tarball
|
||||
@mkdir -p dmenu-${VERSION}
|
||||
@cp LICENSE Makefile README config.mk dmenu.1 dmenu.c draw.c draw.h dmenu_path dmenu_run dmenu-${VERSION}
|
||||
@cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_path dmenu_run ${SRC} dmenu-${VERSION}
|
||||
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
|
||||
@gzip dmenu-${VERSION}.tar
|
||||
@rm -rf dmenu-${VERSION}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
# dmenu version
|
||||
VERSION = 4.3
|
||||
|
||||
# dmenu_path cache (absolute or relative to $HOME)
|
||||
CACHE = .dmenu_cache
|
||||
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
@ -21,7 +17,7 @@ INCS = -I${X11INC}
|
|||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" -DCACHE=\"${CACHE}\" ${XINERAMAFLAGS}
|
||||
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = -s ${LIBS}
|
||||
|
||||
|
|
4
dmenu.1
4
dmenu.1
|
@ -31,9 +31,9 @@ dmenu \- dynamic menu
|
|||
.B dmenu
|
||||
is a dynamic menu for X, originally designed for
|
||||
.BR dwm (1).
|
||||
It manages huge numbers of user-defined menu items efficiently.
|
||||
It manages huge numbers of user\-defined menu items efficiently.
|
||||
.P
|
||||
dmenu reads a list of newline-separated items from stdin and creates a menu.
|
||||
dmenu reads a list of newline\-separated items from stdin and creates a menu.
|
||||
When the user selects an item or enters any text and presses Return, their
|
||||
choice is printed to stdout and dmenu terminates.
|
||||
.P
|
||||
|
|
8
draw.c
8
draw.c
|
@ -25,14 +25,13 @@ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsign
|
|||
(fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
drawtext(DC *dc, const char *text, unsigned long col[ColLast]) {
|
||||
char buf[256];
|
||||
char buf[BUFSIZ];
|
||||
size_t mn, n = strlen(text);
|
||||
|
||||
/* shorten text if necessary */
|
||||
for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) > dc->w - dc->font.height/2; mn--)
|
||||
for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) + dc->font.height/2 > dc->w; mn--)
|
||||
if(mn == 0)
|
||||
return;
|
||||
memcpy(buf, text, mn);
|
||||
|
@ -157,12 +156,11 @@ void
|
|||
resizedc(DC *dc, unsigned int w, unsigned int h) {
|
||||
if(dc->canvas)
|
||||
XFreePixmap(dc->dpy, dc->canvas);
|
||||
|
||||
dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
|
||||
DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));
|
||||
dc->x = dc->y = 0;
|
||||
dc->w = w;
|
||||
dc->h = h;
|
||||
dc->invert = False;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue