1. use `unsigned int` to store the codepoints, this avoids waste on
common case where `long` is 64bits. and POSIX guarantees `int` to be
at least 32bits so there's no risk of truncation.
2. since switching to `unsigned int` cuts down the memory requirement by
half, double the cache size from 64 to 128.
3. instead of a linear search, use a simple hash-table for O(1) lookups.
ref.
https://git.suckless.org/dmenu/commit/7ab0cb5ef0e19352fc5d64ae0d57a5cf4540acbf.html
fix BadMatch error when embedding on some windows
When embedded into another window, dmenu will fail with the BadMatch
error if that window have not the same colormap/depth/visual as the
root window.
That happens because dmenu inherits the colormap/depth/visual from
its parent, but draws on a pixmap created based on the root window
using a GC created for the root window (see drw.c). A BadMatch will
occur when copying the content of the pixmap into dmenu's window.
A solution is to create dmenu's window inside root and then reparent
it if embeded.
See this mail[1] on ports@openbsd.org mailing list for context.
[1]: https://marc.info/?l=openbsd-ports&m=168072150814664&w=2
Ref.
https://git.suckless.org/dmenu/commit/0fe460dbd469a1d5b6a7140d0e1801935e4a923b.html
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.
Ref.
https://git.suckless.org/dmenu/commit/e42c03663442f5fb2f66dd59cc5bfdc61c53192c.html
This patch is simpler than, and superior to, the TSV patch and as
such takes precedence if both are combined.
Also addressed some compatibility issues and compilation errors.
Reasoning:
- the patch is old and incompatible and conflicts with so many
other patches
- the functionality is rather limited especially considering that
it is generally possible to convert json data to work with the
TSV patch or the separator patch
- the patch is for dmenu 4.9, which means that since February 2009
nobody has bothered upgrading this patch to 5.0 or 5.1, which
again implies that not many people actually use or rely on this
patch
The json patch may be re-introduced into dmenu-flexipatch in the
future, but in that case it would be a bespoke version that is
designed around some of the other patches and takes more liberties
rather than trying to adhere to what is available at
https://tools.suckless.org/dmenu/patches/json/
Example using jq to convert json data to TSV format:
$ cat ~/.bookmarks
{
"uggah": "buggah",
"hello": "there",
"bye": "tomorrow"
}
$ cat ~/.bookmarks | jq -r '. | to_entries | .[] | "\(.key)\t\(.value)"'
uggah buggah
hello there
bye tomorrow
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.