Compare commits
No commits in common. "22ee8cfc6571e784901211cefc7b843c606cbc34" and "e1e1de7b3b8399cba90ddca9613f837b2dbef7b9" have entirely different histories.
22ee8cfc65
...
e1e1de7b3b
2
Makefile
2
Makefile
|
@ -29,7 +29,7 @@ stest: stest.o
|
||||||
$(CC) -o $@ stest.o $(LDFLAGS)
|
$(CC) -o $@ stest.o $(LDFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz config.h
|
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
|
||||||
|
|
||||||
dist: clean
|
dist: clean
|
||||||
mkdir -p dmenu-$(VERSION)
|
mkdir -p dmenu-$(VERSION)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
static const char *fonts[] = {
|
static const char *fonts[] = {
|
||||||
"monospace:size=12"
|
"monospace:size=10"
|
||||||
};
|
};
|
||||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
static const char *colors[SchemeLast][2] = {
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
@ -21,6 +21,3 @@ static unsigned int lines = 0;
|
||||||
* for example: " /?\"&[]"
|
* for example: " /?\"&[]"
|
||||||
*/
|
*/
|
||||||
static const char worddelimiters[] = " ";
|
static const char worddelimiters[] = " ";
|
||||||
static unsigned int borderwidth = 5;
|
|
||||||
static unsigned int bordervisible = 0;
|
|
||||||
static const unsigned int gappx = 15;
|
|
||||||
|
|
26
config.h
26
config.h
|
@ -1,26 +0,0 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
/* Default settings; can be overriden by command line. */
|
|
||||||
|
|
||||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
|
||||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
|
||||||
static const char *fonts[] = {
|
|
||||||
"monospace:size=12"
|
|
||||||
};
|
|
||||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
|
||||||
static const char *colors[SchemeLast][2] = {
|
|
||||||
/* fg bg */
|
|
||||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
|
||||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
|
||||||
[SchemeOut] = { "#000000", "#00ffff" },
|
|
||||||
};
|
|
||||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
|
||||||
static unsigned int lines = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Characters not considered part of a word while deleting words
|
|
||||||
* for example: " /?\"&[]"
|
|
||||||
*/
|
|
||||||
static const char worddelimiters[] = " ";
|
|
||||||
static unsigned int borderwidth = 5;
|
|
||||||
static unsigned int bordervisible = 0;
|
|
||||||
static const unsigned int gappx = 15;
|
|
|
@ -1,5 +1,5 @@
|
||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = bit_1.0
|
VERSION = 5.1
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
@ -17,7 +17,6 @@ FREETYPELIBS = -lfontconfig -lXft
|
||||||
FREETYPEINC = /usr/include/freetype2
|
FREETYPEINC = /usr/include/freetype2
|
||||||
# OpenBSD (uncomment)
|
# OpenBSD (uncomment)
|
||||||
#FREETYPEINC = $(X11INC)/freetype2
|
#FREETYPEINC = $(X11INC)/freetype2
|
||||||
#MANPREFIX = ${PREFIX}/man
|
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I$(X11INC) -I$(FREETYPEINC)
|
INCS = -I$(X11INC) -I$(FREETYPEINC)
|
||||||
|
|
57
dmenu.c
57
dmenu.c
|
@ -55,9 +55,6 @@ static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static int dmx = gappx;
|
|
||||||
static int dmy = gappx;
|
|
||||||
|
|
||||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
static char *(*fstrstr)(const char *, const char *) = strstr;
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
|
||||||
|
@ -520,9 +517,9 @@ insert:
|
||||||
case XK_Tab:
|
case XK_Tab:
|
||||||
if (!sel)
|
if (!sel)
|
||||||
return;
|
return;
|
||||||
cursor = strnlen(sel->text, sizeof text - 1);
|
strncpy(text, sel->text, sizeof text - 1);
|
||||||
memcpy(text, sel->text, cursor);
|
text[sizeof text - 1] = '\0';
|
||||||
text[cursor] = '\0';
|
cursor = strlen(text);
|
||||||
match();
|
match();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -552,18 +549,18 @@ paste(void)
|
||||||
static void
|
static void
|
||||||
readstdin(void)
|
readstdin(void)
|
||||||
{
|
{
|
||||||
char *line = NULL;
|
char buf[sizeof text], *p;
|
||||||
size_t i, junk, size = 0;
|
size_t i, size = 0;
|
||||||
ssize_t len;
|
|
||||||
|
|
||||||
/* read each line from stdin and add it to the item list */
|
/* read each line from stdin and add it to the item list */
|
||||||
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
|
for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
|
||||||
if (i + 1 >= size / sizeof *items)
|
if (i + 1 >= size / sizeof *items)
|
||||||
if (!(items = realloc(items, (size += BUFSIZ))))
|
if (!(items = realloc(items, (size += BUFSIZ))))
|
||||||
die("cannot realloc %zu bytes:", size);
|
die("cannot realloc %zu bytes:", size);
|
||||||
if (line[len - 1] == '\n')
|
if ((p = strchr(buf, '\n')))
|
||||||
line[len - 1] = '\0';
|
*p = '\0';
|
||||||
items[i].text = line;
|
if (!(items[i].text = strdup(buf)))
|
||||||
|
die("cannot strdup %zu bytes:", strlen(buf) + 1);
|
||||||
items[i].out = 0;
|
items[i].out = 0;
|
||||||
}
|
}
|
||||||
if (items)
|
if (items)
|
||||||
|
@ -661,9 +658,9 @@ setup(void)
|
||||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
x = info[i].x_org + dmx;
|
x = info[i].x_org;
|
||||||
y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
mw = info[i].width - dmx * 2;
|
mw = info[i].width;
|
||||||
XFree(info);
|
XFree(info);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -671,27 +668,21 @@ setup(void)
|
||||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
die("could not get embedding window attributes: 0x%lx",
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
parentwin);
|
parentwin);
|
||||||
x = dmx;
|
x = 0;
|
||||||
y = topbar ? dmy : wa.height - mh - dmy;
|
y = topbar ? 0 : wa.height - mh;
|
||||||
mw = wa.width - dmx * 2;
|
mw = wa.width;
|
||||||
}
|
}
|
||||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
inputw = mw / 3; /* input width: ~33% of monitor width */
|
inputw = mw / 3; /* input width: ~30% of monitor width */
|
||||||
match();
|
match();
|
||||||
|
|
||||||
/* create menu window */
|
/* create menu window */
|
||||||
swa.override_redirect = True;
|
swa.override_redirect = True;
|
||||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
win = XCreateWindow(dpy, parentwin, x, y - (topbar ? 0 : borderwidth * 2), mw - borderwidth * 2, mh, borderwidth,
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
if (borderwidth) {
|
|
||||||
if (bordervisible)
|
|
||||||
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
|
||||||
else
|
|
||||||
XSetWindowBorder(dpy, win, scheme[SchemeNorm][ColBg].pixel);
|
|
||||||
}
|
|
||||||
XSetClassHint(dpy, win, &ch);
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,9 +710,9 @@ setup(void)
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
" [-g gap] [-bw borderwidth] [-bv bordervisible]\n"
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
|
||||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -747,8 +738,6 @@ main(int argc, char *argv[])
|
||||||
/* these options take one argument */
|
/* these options take one argument */
|
||||||
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||||
lines = atoi(argv[++i]);
|
lines = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-g"))
|
|
||||||
dmx = dmy = atoi(argv[++i]);
|
|
||||||
else if (!strcmp(argv[i], "-m"))
|
else if (!strcmp(argv[i], "-m"))
|
||||||
mon = atoi(argv[++i]);
|
mon = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
|
@ -765,10 +754,6 @@ main(int argc, char *argv[])
|
||||||
colors[SchemeSel][ColFg] = argv[++i];
|
colors[SchemeSel][ColFg] = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||||
embed = argv[++i];
|
embed = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-bw"))
|
|
||||||
borderwidth = atoi(argv[++i]);
|
|
||||||
else if (!strcmp(argv[i], "-bv"))
|
|
||||||
bordervisible = atoi(argv[++i]);
|
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
|
13
drw.c
13
drw.c
|
@ -133,6 +133,19 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
die("no font specified.");
|
die("no font specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||||
|
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||||
|
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||||
|
* https://lists.suckless.org/dev/1701/30932.html
|
||||||
|
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
||||||
|
* and lots more all over the internet.
|
||||||
|
*/
|
||||||
|
FcBool iscol;
|
||||||
|
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
||||||
|
XftFontClose(drw->dpy, xfont);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
font = ecalloc(1, sizeof(Fnt));
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
font->xfont = xfont;
|
font->xfont = xfont;
|
||||||
font->pattern = pattern;
|
font->pattern = pattern;
|
||||||
|
|
23
util.c
23
util.c
|
@ -6,9 +6,18 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void
|
void *
|
||||||
die(const char *fmt, ...)
|
ecalloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if (!(p = calloc(nmemb, size)))
|
||||||
|
die("calloc:");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
die(const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -24,13 +33,3 @@ die(const char *fmt, ...)
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
ecalloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (!(p = calloc(nmemb, size)))
|
|
||||||
die("calloc:");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue