Compare commits

..

6 Commits
1.3 ... 1.5

4 changed files with 28 additions and 22 deletions

View File

@ -10,3 +10,5 @@ d046c818ea467555cc338751c9bf3024609f1f12 0.9
9e11140d4cc3eecac3b0ab752f91528fd5e04be8 1.0 9e11140d4cc3eecac3b0ab752f91528fd5e04be8 1.0
e8c1e9733752db12f2dbd1fa93c46f5806242ba9 1.1 e8c1e9733752db12f2dbd1fa93c46f5806242ba9 1.1
bee7fe6d1189174d0204ca3195b83cdc1bb4f82e 1.2 bee7fe6d1189174d0204ca3195b83cdc1bb4f82e 1.2
2eb9997be51cb1b11a8900728ccc0904f9371157 1.3
df3fbb050004c544d14e43c36f6a94cca6ed4a69 1.4

View File

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 1.3 VERSION = 1.5
# Customize below to fit your system # Customize below to fit your system

4
draw.c
View File

@ -35,8 +35,8 @@ drawtext(const char *text, unsigned long col[ColLast]) {
return; return;
w = 0; w = 0;
olen = len = strlen(text); olen = len = strlen(text);
if(len >= sizeof(buf)) if(len >= sizeof buf)
len = sizeof(buf) - 1; len = sizeof buf - 1;
memcpy(buf, text, len); memcpy(buf, text, len);
buf[len] = 0; buf[len] = 0;
h = dc.font.ascent + dc.font.descent; h = dc.font.ascent + dc.font.descent;

42
main.c
View File

@ -11,7 +11,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/time.h> #include <sys/time.h>
#include <X11/cursorfont.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
@ -145,7 +144,7 @@ kpress(XKeyEvent * e) {
len = strlen(text); len = strlen(text);
buf[0] = 0; buf[0] = 0;
num = XLookupString(e, buf, sizeof(buf), &ksym, 0); num = XLookupString(e, buf, sizeof buf, &ksym, 0);
if(IsFunctionKey(ksym) || IsKeypadKey(ksym) if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
|| IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
|| IsPrivateKeypadKey(ksym)) || IsPrivateKeypadKey(ksym))
@ -182,7 +181,7 @@ kpress(XKeyEvent * e) {
case XK_Tab: case XK_Tab:
if(!sel) if(!sel)
return; return;
strncpy(text, sel->text, sizeof(text)); strncpy(text, sel->text, sizeof text);
match(text); match(text);
break; break;
case XK_Right: case XK_Right:
@ -222,9 +221,9 @@ kpress(XKeyEvent * e) {
if(num && !iscntrl((int) buf[0])) { if(num && !iscntrl((int) buf[0])) {
buf[num] = 0; buf[num] = 0;
if(len > 0) if(len > 0)
strncat(text, buf, sizeof(text)); strncat(text, buf, sizeof text);
else else
strncpy(text, buf, sizeof(text)); strncpy(text, buf, sizeof text);
match(text); match(text);
} }
} }
@ -239,7 +238,7 @@ readstdin(void) {
Item *i, *new; Item *i, *new;
i = 0; i = 0;
while(fgets(buf, sizeof(buf), stdin)) { while(fgets(buf, sizeof buf, stdin)) {
len = strlen(buf); len = strlen(buf);
if (buf[len - 1] == '\n') if (buf[len - 1] == '\n')
buf[len - 1] = 0; buf[len - 1] = 0;
@ -286,18 +285,24 @@ main(int argc, char *argv[]) {
timeout.tv_sec = 3; timeout.tv_sec = 3;
/* command line args */ /* command line args */
for(i = 1; i < argc; i++) for(i = 1; i < argc; i++)
if(!strncmp(argv[i], "-font", 6)) if(!strncmp(argv[i], "-font", 6)) {
font = argv[++i]; if(++i < argc) font = argv[i];
else if(!strncmp(argv[i], "-normbg", 8)) }
normbg = argv[++i]; else if(!strncmp(argv[i], "-normbg", 8)) {
else if(!strncmp(argv[i], "-normfg", 8)) if(++i < argc) normbg = argv[i];
normfg = argv[++i]; }
else if(!strncmp(argv[i], "-selbg", 7)) else if(!strncmp(argv[i], "-normfg", 8)) {
selbg = argv[++i]; if(++i < argc) normfg = argv[i];
else if(!strncmp(argv[i], "-selfg", 7)) }
selfg = argv[++i]; else if(!strncmp(argv[i], "-selbg", 7)) {
else if(!strncmp(argv[i], "-t", 3)) if(++i < argc) selbg = argv[i];
timeout.tv_sec = atoi(argv[++i]); }
else if(!strncmp(argv[i], "-selfg", 7)) {
if(++i < argc) selfg = argv[i];
}
else if(!strncmp(argv[i], "-t", 3)) {
if(++i < argc) timeout.tv_sec = atoi(argv[i]);
}
else if(!strncmp(argv[i], "-v", 3)) { else if(!strncmp(argv[i], "-v", 3)) {
fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -340,7 +345,6 @@ main(int argc, char *argv[]) {
DefaultDepth(dpy, screen), CopyFromParent, DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen), DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
/* pixmap */ /* pixmap */
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen)); dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, 0); dc.gc = XCreateGC(dpy, root, 0, 0);