Compare commits
No commits in common. "6de825a6092d8a70c1d4d45f184d41c147262690" and "bcbc1ef5c4cf4875a4d66e7dc0919da88a6096a5" have entirely different histories.
6de825a609
...
bcbc1ef5c4
10
Makefile
10
Makefile
|
@ -6,7 +6,13 @@ include config.mk
|
||||||
SRC = drw.c dmenu.c stest.c util.c
|
SRC = drw.c dmenu.c stest.c util.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: dmenu stest
|
all: options dmenu stest
|
||||||
|
|
||||||
|
options:
|
||||||
|
@echo dmenu build options:
|
||||||
|
@echo "CFLAGS = $(CFLAGS)"
|
||||||
|
@echo "LDFLAGS = $(LDFLAGS)"
|
||||||
|
@echo "CC = $(CC)"
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
@ -55,4 +61,4 @@ uninstall:
|
||||||
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
|
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
|
||||||
$(DESTDIR)$(MANPREFIX)/man1/stest.1
|
$(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||||
|
|
||||||
.PHONY: all clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
|
23
config.h
23
config.h
|
@ -1,23 +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[] = {
|
|
||||||
"Mononoki Nerd Font:size=16"
|
|
||||||
};
|
|
||||||
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", "#318d56" },
|
|
||||||
[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[] = " ";
|
|
|
@ -1,5 +1,5 @@
|
||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 5.3
|
VERSION = 5.2
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
5
dmenu.1
5
dmenu.1
|
@ -3,7 +3,7 @@
|
||||||
dmenu \- dynamic menu
|
dmenu \- dynamic menu
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B dmenu
|
.B dmenu
|
||||||
.RB [ \-bfivP ]
|
.RB [ \-bfiv ]
|
||||||
.RB [ \-l
|
.RB [ \-l
|
||||||
.IR lines ]
|
.IR lines ]
|
||||||
.RB [ \-m
|
.RB [ \-m
|
||||||
|
@ -47,9 +47,6 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||||
.B \-i
|
.B \-i
|
||||||
dmenu matches menu items case insensitively.
|
dmenu matches menu items case insensitively.
|
||||||
.TP
|
.TP
|
||||||
.B \-P
|
|
||||||
dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored.
|
|
||||||
.TP
|
|
||||||
.BI \-l " lines"
|
.BI \-l " lines"
|
||||||
dmenu lists items vertically, with the given number of lines.
|
dmenu lists items vertically, with the given number of lines.
|
||||||
.TP
|
.TP
|
||||||
|
|
42
dmenu.c
42
dmenu.c
|
@ -22,6 +22,7 @@
|
||||||
/* macros */
|
/* macros */
|
||||||
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||||
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
|
@ -36,7 +37,7 @@ struct item {
|
||||||
static char text[BUFSIZ] = "";
|
static char text[BUFSIZ] = "";
|
||||||
static char *embed;
|
static char *embed;
|
||||||
static int bh, mw, mh;
|
static int bh, mw, mh;
|
||||||
static int inputw = 0, promptw, passwd = 0;
|
static int inputw = 0, promptw;
|
||||||
static int lrpad; /* sum of left and right padding */
|
static int lrpad; /* sum of left and right padding */
|
||||||
static size_t cursor;
|
static size_t cursor;
|
||||||
static struct item *items = NULL;
|
static struct item *items = NULL;
|
||||||
|
@ -148,7 +149,6 @@ drawmenu(void)
|
||||||
unsigned int curpos;
|
unsigned int curpos;
|
||||||
struct item *item;
|
struct item *item;
|
||||||
int x = 0, y = 0, w;
|
int x = 0, y = 0, w;
|
||||||
char *censort;
|
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
@ -160,12 +160,7 @@ drawmenu(void)
|
||||||
/* draw input field */
|
/* draw input field */
|
||||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
if (passwd) {
|
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
||||||
censort = ecalloc(1, sizeof(text));
|
|
||||||
memset(censort, '.', strlen(text));
|
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
|
|
||||||
free(censort);
|
|
||||||
} else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
|
||||||
|
|
||||||
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||||
if ((curpos += lrpad / 2 - 1) < w) {
|
if ((curpos += lrpad / 2 - 1) < w) {
|
||||||
|
@ -555,27 +550,19 @@ static void
|
||||||
readstdin(void)
|
readstdin(void)
|
||||||
{
|
{
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t i, itemsiz = 0, linesiz = 0;
|
size_t i, junk, size = 0;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
if(passwd){
|
|
||||||
inputw = lines = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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, &linesiz, stdin)) != -1; i++) {
|
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++) {
|
||||||
if (i + 1 >= itemsiz) {
|
if (i + 1 >= size / sizeof *items)
|
||||||
itemsiz += 256;
|
if (!(items = realloc(items, (size += BUFSIZ))))
|
||||||
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
die("cannot realloc %zu bytes:", size);
|
||||||
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
|
|
||||||
}
|
|
||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
line[len - 1] = '\0';
|
line[len - 1] = '\0';
|
||||||
if (!(items[i].text = strdup(line)))
|
items[i].text = line;
|
||||||
die("strdup:");
|
|
||||||
|
|
||||||
items[i].out = 0;
|
items[i].out = 0;
|
||||||
|
line = NULL; /* next call of getline() allocates a new line */
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
if (items)
|
if (items)
|
||||||
|
@ -695,7 +682,7 @@ setup(void)
|
||||||
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, root, x, y, mw, mh, 0,
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
XSetClassHint(dpy, win, &ch);
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
@ -710,7 +697,6 @@ setup(void)
|
||||||
|
|
||||||
XMapRaised(dpy, win);
|
XMapRaised(dpy, win);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
XReparentWindow(dpy, win, parentwin, x, y);
|
|
||||||
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||||
for (i = 0; i < du && dws[i] != win; ++i)
|
for (i = 0; i < du && dws[i] != win; ++i)
|
||||||
|
@ -726,7 +712,7 @@ setup(void)
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
die("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,9 +734,7 @@ main(int argc, char *argv[])
|
||||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||||
fstrncmp = strncasecmp;
|
fstrncmp = strncasecmp;
|
||||||
fstrstr = cistrstr;
|
fstrstr = cistrstr;
|
||||||
} else if (!strcmp(argv[i], "-P")) /* is the input a password */
|
} else if (i + 1 == argc)
|
||||||
passwd = 1;
|
|
||||||
else if (i + 1 == argc)
|
|
||||||
usage();
|
usage();
|
||||||
/* 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 */
|
||||||
|
|
13
dmenu_path
Executable file
13
dmenu_path
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
|
||||||
|
cache="$cachedir/dmenu_run"
|
||||||
|
|
||||||
|
[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
|
||||||
|
|
||||||
|
IFS=:
|
||||||
|
if stest -dqr -n "$cache" $PATH; then
|
||||||
|
stest -flx $PATH | sort -u | tee "$cache"
|
||||||
|
else
|
||||||
|
cat "$cache"
|
||||||
|
fi
|
2
dmenu_run
Executable file
2
dmenu_run
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
116
drw.c
116
drw.c
|
@ -9,40 +9,54 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define UTF_INVALID 0xFFFD
|
#define UTF_INVALID 0xFFFD
|
||||||
|
#define UTF_SIZ 4
|
||||||
|
|
||||||
static int
|
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
utf8decode(const char *s_in, long *u, int *err)
|
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
|
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
|
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||||
|
|
||||||
|
static long
|
||||||
|
utf8decodebyte(const char c, size_t *i)
|
||||||
{
|
{
|
||||||
static const unsigned char lens[] = {
|
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||||
/* 0XXXX */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||||
/* 10XXX */ 0, 0, 0, 0, 0, 0, 0, 0, /* invalid */
|
return (unsigned char)c & ~utfmask[*i];
|
||||||
/* 110XX */ 2, 2, 2, 2,
|
return 0;
|
||||||
/* 1110X */ 3, 3,
|
|
||||||
/* 11110 */ 4,
|
|
||||||
/* 11111 */ 0, /* invalid */
|
|
||||||
};
|
|
||||||
static const unsigned char leading_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
|
||||||
static const unsigned int overlong[] = { 0x0, 0x80, 0x0800, 0x10000 };
|
|
||||||
|
|
||||||
const unsigned char *s = (const unsigned char *)s_in;
|
|
||||||
int len = lens[*s >> 3];
|
|
||||||
*u = UTF_INVALID;
|
|
||||||
*err = 1;
|
|
||||||
if (len == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
long cp = s[0] & leading_mask[len - 1];
|
|
||||||
for (int i = 1; i < len; ++i) {
|
|
||||||
if (s[i] == '\0' || (s[i] & 0xC0) != 0x80)
|
|
||||||
return i;
|
|
||||||
cp = (cp << 6) | (s[i] & 0x3F);
|
|
||||||
}
|
}
|
||||||
/* out of range, surrogate, overlong encoding */
|
|
||||||
if (cp > 0x10FFFF || (cp >> 11) == 0x1B || cp < overlong[len - 1])
|
|
||||||
return len;
|
|
||||||
|
|
||||||
*err = 0;
|
static size_t
|
||||||
*u = cp;
|
utf8validate(long *u, size_t i)
|
||||||
|
{
|
||||||
|
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
for (i = 1; *u > utfmax[i]; ++i)
|
||||||
|
;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
utf8decode(const char *c, long *u, size_t clen)
|
||||||
|
{
|
||||||
|
size_t i, j, len, type;
|
||||||
|
long udecoded;
|
||||||
|
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
if (!clen)
|
||||||
|
return 0;
|
||||||
|
udecoded = utf8decodebyte(c[0], &len);
|
||||||
|
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||||
|
return 1;
|
||||||
|
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||||
|
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||||
|
if (type)
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
if (j < len)
|
||||||
|
return 0;
|
||||||
|
*u = udecoded;
|
||||||
|
utf8validate(u, len);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,11 +238,11 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
int ty, ellipsis_x = 0;
|
int i, ty, ellipsis_x = 0;
|
||||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *usedfont, *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
int utf8strlen, utf8charlen, utf8err, render = x || y || w || h;
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset;
|
||||||
|
@ -237,8 +251,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0, overflow = 0;
|
int charexists = 0, overflow = 0;
|
||||||
/* keep track of a couple codepoints for which we have no match. */
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
static unsigned int nomatches[128], ellipsis_width, invalid_width;
|
enum { nomatches_len = 64 };
|
||||||
static const char invalid[] = "<EFBFBD>";
|
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||||
|
static unsigned int ellipsis_width = 0;
|
||||||
|
|
||||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -258,14 +273,12 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
if (!ellipsis_width && render)
|
if (!ellipsis_width && render)
|
||||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
if (!invalid_width && render)
|
|
||||||
invalid_width = drw_fontset_getwidth(drw, invalid);
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ew = ellipsis_len = utf8err = utf8charlen = utf8strlen = 0;
|
ew = ellipsis_len = utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
utf8charlen = utf8decode(text, &utf8codepoint, &utf8err);
|
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
if (charexists) {
|
if (charexists) {
|
||||||
|
@ -287,9 +300,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
else
|
else
|
||||||
utf8strlen = ellipsis_len;
|
utf8strlen = ellipsis_len;
|
||||||
} else if (curfont == usedfont) {
|
} else if (curfont == usedfont) {
|
||||||
|
utf8strlen += utf8charlen;
|
||||||
text += utf8charlen;
|
text += utf8charlen;
|
||||||
utf8strlen += utf8err ? 0 : utf8charlen;
|
ew += tmpw;
|
||||||
ew += utf8err ? 0 : tmpw;
|
|
||||||
} else {
|
} else {
|
||||||
nextfont = curfont;
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
|
@ -297,7 +310,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow || !charexists || nextfont || utf8err)
|
if (overflow || !charexists || nextfont)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
|
@ -312,12 +325,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
x += ew;
|
x += ew;
|
||||||
w -= ew;
|
w -= ew;
|
||||||
}
|
}
|
||||||
if (utf8err && (!render || invalid_width < w)) {
|
|
||||||
if (render)
|
|
||||||
drw_text(drw, x, y, w, h, 0, invalid, invert);
|
|
||||||
x += invalid_width;
|
|
||||||
w -= invalid_width;
|
|
||||||
}
|
|
||||||
if (render && overflow)
|
if (render && overflow)
|
||||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
|
@ -331,14 +338,11 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
* character must be drawn. */
|
* character must be drawn. */
|
||||||
charexists = 1;
|
charexists = 1;
|
||||||
|
|
||||||
hash = (unsigned int)utf8codepoint;
|
for (i = 0; i < nomatches_len; ++i) {
|
||||||
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||||
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
if (utf8codepoint == nomatches.codepoint[i])
|
||||||
h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
|
|
||||||
h1 = (hash >> 17) % LENGTH(nomatches);
|
|
||||||
/* avoid expensive XftFontMatch call when we know we won't find a match */
|
|
||||||
if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
|
|
||||||
goto no_match;
|
goto no_match;
|
||||||
|
}
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
|
@ -367,7 +371,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
curfont->next = usedfont;
|
curfont->next = usedfont;
|
||||||
} else {
|
} else {
|
||||||
xfont_free(usedfont);
|
xfont_free(usedfont);
|
||||||
nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||||
no_match:
|
no_match:
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
|
|
15
shell.nix
15
shell.nix
|
@ -1,15 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
|
|
||||||
pkgs.mkShell {
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.gnumake
|
|
||||||
pkgs.gcc
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.xorg.libX11
|
|
||||||
pkgs.xorg.libXft
|
|
||||||
pkgs.xorg.libXinerama
|
|
||||||
pkgs.xorg.libXext
|
|
||||||
pkgs.fontconfig
|
|
||||||
pkgs.freetype
|
|
||||||
];
|
|
||||||
}
|
|
1
util.h
1
util.h
|
@ -3,7 +3,6 @@
|
||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||||
#define LENGTH(X) (sizeof (X) / sizeof (X)[0])
|
|
||||||
|
|
||||||
void die(const char *fmt, ...);
|
void die(const char *fmt, ...);
|
||||||
void *ecalloc(size_t nmemb, size_t size);
|
void *ecalloc(size_t nmemb, size_t size);
|
||||||
|
|
Loading…
Reference in a new issue