Compare commits

..

10 Commits

Author SHA1 Message Date
BitHeaven 22ee8cfc65 little update 2023-04-28 15:55:40 +05:00
BitHeaven-Official 0e98ef6239 Update code to newest version 2023-03-08 14:11:41 +05:00
BitHeaven-Official c1d0361d24 Fix changes 2023-03-08 13:53:26 +05:00
Linux User efccfc9b98 Fix warnings 2022-08-16 19:44:24 +00:00
Linux User 57c922297d Correct height for my DWM build 2022-08-16 19:42:34 +00:00
BitHeaven fb6316d64f
Update Makefile 2022-08-14 00:48:07 +05:00
Linux User b319a691c7 some changes 2022-08-13 16:27:31 +00:00
Hiltjo Posthuma e35976f4a5 sync code-style patch from libsl 2022-08-08 10:42:54 +02:00
Hiltjo Posthuma 28fb3e2812 Makefile: add manual path for OpenBSD 2022-05-01 18:38:25 +02:00
Hiltjo Posthuma fe5d5c6709 fix incorrect comment, math is hard 2022-04-30 13:19:33 +02:00
13 changed files with 81 additions and 48 deletions

View File

@ -29,7 +29,7 @@ stest: stest.o
$(CC) -o $@ stest.o $(LDFLAGS)
clean:
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz config.h
dist: clean
mkdir -p dmenu-$(VERSION)

View File

@ -4,7 +4,7 @@
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=10"
"monospace:size=12"
};
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
@ -21,3 +21,6 @@ static unsigned int lines = 0;
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
static unsigned int borderwidth = 5;
static unsigned int bordervisible = 0;
static const unsigned int gappx = 15;

26
config.h Normal file
View File

@ -0,0 +1,26 @@
/* 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;

View File

@ -1,5 +1,5 @@
# dmenu version
VERSION = 5.1
VERSION = bit_1.0
# paths
PREFIX = /usr/local
@ -17,6 +17,7 @@ FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = $(X11INC)/freetype2
#MANPREFIX = ${PREFIX}/man
# includes and libs
INCS = -I$(X11INC) -I$(FREETYPEINC)

BIN
dmenu Executable file

Binary file not shown.

57
dmenu.c
View File

@ -55,6 +55,9 @@ static Clr *scheme[SchemeLast];
#include "config.h"
static int dmx = gappx;
static int dmy = gappx;
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr;
@ -517,9 +520,9 @@ insert:
case XK_Tab:
if (!sel)
return;
strncpy(text, sel->text, sizeof text - 1);
text[sizeof text - 1] = '\0';
cursor = strlen(text);
cursor = strnlen(sel->text, sizeof text - 1);
memcpy(text, sel->text, cursor);
text[cursor] = '\0';
match();
break;
}
@ -549,18 +552,18 @@ paste(void)
static void
readstdin(void)
{
char buf[sizeof text], *p;
size_t i, size = 0;
char *line = NULL;
size_t i, junk, size = 0;
ssize_t len;
/* read each line from stdin and add it to the item list */
for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
if (i + 1 >= size / sizeof *items)
if (!(items = realloc(items, (size += BUFSIZ))))
die("cannot realloc %zu bytes:", size);
if ((p = strchr(buf, '\n')))
*p = '\0';
if (!(items[i].text = strdup(buf)))
die("cannot strdup %zu bytes:", strlen(buf) + 1);
if (line[len - 1] == '\n')
line[len - 1] = '\0';
items[i].text = line;
items[i].out = 0;
}
if (items)
@ -658,9 +661,9 @@ setup(void)
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
break;
x = info[i].x_org;
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
mw = info[i].width;
x = info[i].x_org + dmx;
y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
mw = info[i].width - dmx * 2;
XFree(info);
} else
#endif
@ -668,21 +671,27 @@ setup(void)
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx",
parentwin);
x = 0;
y = topbar ? 0 : wa.height - mh;
mw = wa.width;
x = dmx;
y = topbar ? dmy : wa.height - mh - dmy;
mw = wa.width - dmx * 2;
}
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
inputw = mw / 3; /* input width: ~30% of monitor width */
inputw = mw / 3; /* input width: ~33% of monitor width */
match();
/* create menu window */
swa.override_redirect = True;
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
win = XCreateWindow(dpy, parentwin, x, y - (topbar ? 0 : borderwidth * 2), mw - borderwidth * 2, mh, borderwidth,
CopyFromParent, CopyFromParent, CopyFromParent,
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);
@ -710,9 +719,9 @@ setup(void)
static void
usage(void)
{
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
exit(1);
die("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]");
}
int
@ -738,6 +747,8 @@ main(int argc, char *argv[])
/* these options take one argument */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]);
else if (!strcmp(argv[i], "-g"))
dmx = dmy = atoi(argv[++i]);
else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
@ -754,6 +765,10 @@ main(int argc, char *argv[])
colors[SchemeSel][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
else if (!strcmp(argv[i], "-bw"))
borderwidth = atoi(argv[++i]);
else if (!strcmp(argv[i], "-bv"))
bordervisible = atoi(argv[++i]);
else
usage();

BIN
dmenu.o Normal file

Binary file not shown.

13
drw.c
View File

@ -133,19 +133,6 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
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->xfont = xfont;
font->pattern = pattern;

BIN
drw.o Normal file

Binary file not shown.

BIN
stest Executable file

Binary file not shown.

BIN
stest.o Normal file

Binary file not shown.

23
util.c
View File

@ -6,18 +6,9 @@
#include "util.h"
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}
void
die(const char *fmt, ...) {
die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -33,3 +24,13 @@ die(const char *fmt, ...) {
exit(1);
}
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}

BIN
util.o Normal file

Binary file not shown.