Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
c65fdd6252 | |||
8c20e5dbd3 | |||
26fbf124fa | |||
194d890517 | |||
f633276774 | |||
bb480fb4b0 | |||
95b19f75cc | |||
3d25a327aa | |||
d78bcf247f | |||
afaf66dc99 |
3
.hgtags
3
.hgtags
@ -9,3 +9,6 @@ d352e9dc112ee96aa5cad961a0ed880ae9ce7276 0.3
|
||||
d046c818ea467555cc338751c9bf3024609f1f12 0.9
|
||||
9e11140d4cc3eecac3b0ab752f91528fd5e04be8 1.0
|
||||
e8c1e9733752db12f2dbd1fa93c46f5806242ba9 1.1
|
||||
bee7fe6d1189174d0204ca3195b83cdc1bb4f82e 1.2
|
||||
2eb9997be51cb1b11a8900728ccc0904f9371157 1.3
|
||||
df3fbb050004c544d14e43c36f6a94cca6ed4a69 1.4
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dmenu version
|
||||
VERSION = 1.2
|
||||
VERSION = 1.5
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
4
draw.c
4
draw.c
@ -35,8 +35,8 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
return;
|
||||
w = 0;
|
||||
olen = len = strlen(text);
|
||||
if(len >= sizeof(buf))
|
||||
len = sizeof(buf) - 1;
|
||||
if(len >= sizeof buf)
|
||||
len = sizeof buf - 1;
|
||||
memcpy(buf, text, len);
|
||||
buf[len] = 0;
|
||||
h = dc.font.ascent + dc.font.descent;
|
||||
|
45
main.c
45
main.c
@ -11,7 +11,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
@ -145,7 +144,7 @@ kpress(XKeyEvent * e) {
|
||||
|
||||
len = strlen(text);
|
||||
buf[0] = 0;
|
||||
num = XLookupString(e, buf, sizeof(buf), &ksym, 0);
|
||||
num = XLookupString(e, buf, sizeof buf, &ksym, 0);
|
||||
if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
|
||||
|| IsMiscFunctionKey(ksym) || IsPFKey(ksym)
|
||||
|| IsPrivateKeypadKey(ksym))
|
||||
@ -182,7 +181,7 @@ kpress(XKeyEvent * e) {
|
||||
case XK_Tab:
|
||||
if(!sel)
|
||||
return;
|
||||
strncpy(text, sel->text, sizeof(text));
|
||||
strncpy(text, sel->text, sizeof text);
|
||||
match(text);
|
||||
break;
|
||||
case XK_Right:
|
||||
@ -222,9 +221,9 @@ kpress(XKeyEvent * e) {
|
||||
if(num && !iscntrl((int) buf[0])) {
|
||||
buf[num] = 0;
|
||||
if(len > 0)
|
||||
strncat(text, buf, sizeof(text));
|
||||
strncat(text, buf, sizeof text);
|
||||
else
|
||||
strncpy(text, buf, sizeof(text));
|
||||
strncpy(text, buf, sizeof text);
|
||||
match(text);
|
||||
}
|
||||
}
|
||||
@ -239,7 +238,7 @@ readstdin(void) {
|
||||
Item *i, *new;
|
||||
|
||||
i = 0;
|
||||
while(fgets(buf, sizeof(buf), stdin)) {
|
||||
while(fgets(buf, sizeof buf, stdin)) {
|
||||
len = strlen(buf);
|
||||
if (buf[len - 1] == '\n')
|
||||
buf[len - 1] = 0;
|
||||
@ -286,18 +285,24 @@ main(int argc, char *argv[]) {
|
||||
timeout.tv_sec = 3;
|
||||
/* command line args */
|
||||
for(i = 1; i < argc; i++)
|
||||
if(!strncmp(argv[i], "-font", 6))
|
||||
font = argv[++i];
|
||||
else if(!strncmp(argv[i], "-normbg", 8))
|
||||
normbg = argv[++i];
|
||||
else if(!strncmp(argv[i], "-normfg", 8))
|
||||
normfg = argv[++i];
|
||||
else if(!strncmp(argv[i], "-selbg", 7))
|
||||
selbg = argv[++i];
|
||||
else if(!strncmp(argv[i], "-selfg", 7))
|
||||
selfg = argv[++i];
|
||||
else if(!strncmp(argv[i], "-t", 3))
|
||||
timeout.tv_sec = atoi(argv[++i]);
|
||||
if(!strncmp(argv[i], "-font", 6)) {
|
||||
if(++i < argc) font = argv[i];
|
||||
}
|
||||
else if(!strncmp(argv[i], "-normbg", 8)) {
|
||||
if(++i < argc) normbg = argv[i];
|
||||
}
|
||||
else if(!strncmp(argv[i], "-normfg", 8)) {
|
||||
if(++i < argc) normfg = argv[i];
|
||||
}
|
||||
else if(!strncmp(argv[i], "-selbg", 7)) {
|
||||
if(++i < argc) selbg = 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)) {
|
||||
fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
@ -340,7 +345,6 @@ main(int argc, char *argv[]) {
|
||||
DefaultDepth(dpy, screen), CopyFromParent,
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
|
||||
/* pixmap */
|
||||
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
@ -356,7 +360,7 @@ main(int argc, char *argv[]) {
|
||||
XSync(dpy, False);
|
||||
|
||||
/* main event loop */
|
||||
while(running && !XNextEvent(dpy, &ev)) {
|
||||
while(running && !XNextEvent(dpy, &ev))
|
||||
switch (ev.type) {
|
||||
default: /* ignore all crap */
|
||||
break;
|
||||
@ -368,7 +372,6 @@ main(int argc, char *argv[]) {
|
||||
drawmenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
while(allitems) {
|
||||
|
13
util.c
13
util.c
@ -9,21 +9,12 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* static */
|
||||
|
||||
static void
|
||||
badmalloc(unsigned int size) {
|
||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void *
|
||||
emalloc(unsigned int size) {
|
||||
void *res = malloc(size);
|
||||
|
||||
if(!res)
|
||||
badmalloc(size);
|
||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -42,6 +33,6 @@ estrdup(const char *str) {
|
||||
void *res = strdup(str);
|
||||
|
||||
if(!res)
|
||||
badmalloc(strlen(str));
|
||||
eprint("fatal: could not malloc() %u bytes\n", strlen(str));
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user