~gnkv/dmenu

dmenu: init personal fork
ba1a347d — Hiltjo Posthuma 1 year, 3 months ago
readstdin: allocate amount of items

Keep track of the amount of items (not a total buffer size), allocate an array of
new items. For now change BUFSIZ bytes to 256 * sizeof(struct item)).
bcbc1ef5 — Hiltjo Posthuma 1 year, 3 months ago
readstdin: add a comment

Maybe too obvious / redundant, but OK.
fix leak when getline fails

according to the getline(3) documentation, the calling code needs to
free the buffer even if getline fails.

dmenu currently doesn't do that which results in a small leak in case of
failure (e.g when piped /dev/null)

	$ ./dmenu < /dev/null
	==8201==ERROR: LeakSanitizer: detected memory leaks
	Direct leak of 120 byte(s) in 1 object(s) allocated from:
	    #0 0x7f6bf5785ef7 in malloc
	    #1 0x7f6bf538ec84 in __getdelim
	    #2 0x405d0c in readstdin dmenu.c:557

moving `line = NULL` inside the loop body wasn't strictly necessary, but
IMO it makes it more apparent that `line` is getting cleared to NULL
after each successful iteration.
e42c0366 — Hiltjo Posthuma 1 year, 3 months ago
dmenu: small XmbLookupString code improvements

* Increase the length of composed strings to the same limit as st (32 to 64 bytes).
* Initialize ksym to NoSymbol to be safe: currently this is not an issue though.
* Add comments to clarify the return values of XmbLookupString a bit.
1d2b462a — Hiltjo Posthuma 1 year, 4 months ago
bump version to 5.2
dmenu: use die() to print the usage message
fce06f43 — Hiltjo Posthuma 1 year, 5 months ago
remove workaround for a crash with color emojis on some systems, now fixed in libXft 2.3.5

https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
1e8c5b68 — Hiltjo Posthuma 1 year, 5 months ago
fix a regression in the previous commit for tab complete

Reported by Santtu Lakkala <inz@inz.fi>, thanks!
tab-complete: figure out the size before copying

we already need to know the string length since `cursor` needs to be
adjusted.

so just calculate the length beforehand and use `memcpy` to copy exactly
as much as needed (as opposed to `strncpy` which always writes `n`
bytes).
readstdin: use getline(3)

currently readstdin():
   - fgets() into a local buffer,
   - strchr() the buffer to eleminate the newline
   - stdups() the buffer into items

a simpler way is to just use getline(3), which will do the allocation
for us; eliminating the need for stdup()-ing.

additionally getline returns back the amount of bytes read, which
eliminates the need for strchr()-ing to find the newline.
e35976f4 — Hiltjo Posthuma 1 year, 6 months ago
sync code-style patch from libsl
28fb3e28 — Hiltjo Posthuma 1 year, 9 months ago
Makefile: add manual path for OpenBSD
fe5d5c67 — Hiltjo Posthuma 1 year, 9 months ago
fix incorrect comment, math is hard
e1e1de7b — Hiltjo Posthuma 1 year, 9 months ago
inputw: improve correctness and startup performance, by NRK

Always use ~30% of the monitor width for the input in horizontal mode.

Patch adapted from NRK patches.
This also does not calculate inputw when using vertical mode anymore (because
the code is removed).
drw_text: account for fallback fonts in ellipsis_width

additionally, ellipsis_width (which shouldn't change) is made static to
avoid re-calculating it on each drw_text() call.
drw_text: don't segfault when called with 0 width

this patch just rejects *any* 0 width draws, which is surely an error by
the caller.

this also guards against cases where the width is too small for the
ellipsis to fit, so ellipsis_w will remain 0.
reported by Bakkeby <bakkeby@gmail.com>
e73651f1 — Hiltjo Posthuma 1 year, 10 months ago
fix UB with the function iscntrl()

From commit 6818e07291f3b2913e687c8ec3d3fe4711724050 by NRK, thanks
31fa07b9 — Hiltjo Posthuma 1 year, 10 months ago
Revert "avoid redraw when there's no change"

This reverts commit 6818e07291f3b2913e687c8ec3d3fe4711724050.

This broke keys such as ^W to delete-backward-word
avoid redraw when there's no change

while i was timing the performance issue, i noticed that there was lots
of random redrawing going on.

turns out there were coming from here; if someone presses CTRL/ALT etc
without pressing anything else, nothing will be inserted, so nothing
will change. but the code will `break`, go down and do a needless redraw.

this patch changes it to simply return if the keypress iscntrl()

also avoid potential UB by casting *buf into an unsigned char.
Next