diff options
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | dmenu.c | 21 | ||||
-rw-r--r-- | draw.c | 11 |
3 files changed, 19 insertions, 15 deletions
@@ -18,7 +18,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} | |||
18 | 18 | ||
19 | # flags | 19 | # flags |
20 | CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} | 20 | CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} |
21 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} | 21 | CFLAGS = -ansi -pedantic -Wall -Os ${INCS} ${CPPFLAGS} |
22 | LDFLAGS = -s ${LIBS} | 22 | LDFLAGS = -s ${LIBS} |
23 | 23 | ||
24 | # compiler and linker | 24 | # compiler and linker |
@@ -3,6 +3,7 @@ | |||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <strings.h> | ||
6 | #include <unistd.h> | 7 | #include <unistd.h> |
7 | #include <X11/Xlib.h> | 8 | #include <X11/Xlib.h> |
8 | #include <X11/Xatom.h> | 9 | #include <X11/Xatom.h> |
@@ -231,13 +232,14 @@ insert(const char *str, ssize_t n) { | |||
231 | void | 232 | void |
232 | keypress(XKeyEvent *ev) { | 233 | keypress(XKeyEvent *ev) { |
233 | char buf[32]; | 234 | char buf[32]; |
234 | size_t len; | ||
235 | KeySym ksym; | 235 | KeySym ksym; |
236 | 236 | ||
237 | len = strlen(text); | ||
238 | XLookupString(ev, buf, sizeof buf, &ksym, NULL); | 237 | XLookupString(ev, buf, sizeof buf, &ksym, NULL); |
239 | if(ev->state & ControlMask) | 238 | if(ev->state & ControlMask) { |
240 | switch(tolower(ksym)) { | 239 | KeySym lower, upper; |
240 | |||
241 | XConvertCase(ksym, &lower, &upper); | ||
242 | switch(lower) { | ||
241 | default: | 243 | default: |
242 | return; | 244 | return; |
243 | case XK_a: | 245 | case XK_a: |
@@ -290,13 +292,14 @@ keypress(XKeyEvent *ev) { | |||
290 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); | 292 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); |
291 | return; | 293 | return; |
292 | } | 294 | } |
295 | } | ||
293 | switch(ksym) { | 296 | switch(ksym) { |
294 | default: | 297 | default: |
295 | if(!iscntrl(*buf)) | 298 | if(!iscntrl(*buf)) |
296 | insert(buf, strlen(buf)); | 299 | insert(buf, strlen(buf)); |
297 | break; | 300 | break; |
298 | case XK_Delete: | 301 | case XK_Delete: |
299 | if(cursor == len) | 302 | if(text[cursor] == '\0') |
300 | return; | 303 | return; |
301 | cursor = nextrune(+1); | 304 | cursor = nextrune(+1); |
302 | case XK_BackSpace: | 305 | case XK_BackSpace: |
@@ -304,8 +307,8 @@ keypress(XKeyEvent *ev) { | |||
304 | insert(NULL, nextrune(-1) - cursor); | 307 | insert(NULL, nextrune(-1) - cursor); |
305 | break; | 308 | break; |
306 | case XK_End: | 309 | case XK_End: |
307 | if(cursor < len) { | 310 | if(text[cursor] != '\0') { |
308 | cursor = len; | 311 | cursor = strlen(text); |
309 | break; | 312 | break; |
310 | } | 313 | } |
311 | if(next) { | 314 | if(next) { |
@@ -358,7 +361,7 @@ keypress(XKeyEvent *ev) { | |||
358 | fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout); | 361 | fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout); |
359 | exit(EXIT_SUCCESS); | 362 | exit(EXIT_SUCCESS); |
360 | case XK_Right: | 363 | case XK_Right: |
361 | if(cursor < len) { | 364 | if(text[cursor] != '\0') { |
362 | cursor = nextrune(+1); | 365 | cursor = nextrune(+1); |
363 | break; | 366 | break; |
364 | } | 367 | } |
@@ -385,7 +388,7 @@ void | |||
385 | match(Bool sub) { | 388 | match(Bool sub) { |
386 | size_t len = strlen(text); | 389 | size_t len = strlen(text); |
387 | Item *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; | 390 | Item *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; |
388 | Item *item, *next = NULL; | 391 | Item *item, *next; |
389 | 392 | ||
390 | lexact = lprefix = lsubstr = exactend = prefixend = substrend = NULL; | 393 | lexact = lprefix = lsubstr = exactend = prefixend = substrend = NULL; |
391 | for(item = sub ? matches : items; item && item->text; item = next) { | 394 | for(item = sub ? matches : items; item && item->text; item = next) { |
@@ -15,12 +15,13 @@ static Bool loadfont(DC *dc, const char *fontstr); | |||
15 | 15 | ||
16 | void | 16 | void |
17 | drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) { | 17 | drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) { |
18 | XRectangle r = { dc->x + x, dc->y + y, w, h }; | 18 | XRectangle r; |
19 | |||
20 | r.x = dc->x + x; | ||
21 | r.y = dc->y + y; | ||
22 | r.width = fill ? w : w-1; | ||
23 | r.height = fill ? h : h-1; | ||
19 | 24 | ||
20 | if(!fill) { | ||
21 | r.width -= 1; | ||
22 | r.height -= 1; | ||
23 | } | ||
24 | XSetForeground(dc->dpy, dc->gc, color); | 25 | XSetForeground(dc->dpy, dc->gc, color); |
25 | (fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1); | 26 | (fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1); |
26 | } | 27 | } |