On Sat, Aug 07, 2021 at 09:39:44PM -0400, Miles Alan wrote: > On Sat, Aug 7, 2021, at 9:34 PM, m...@milesalan.com wrote: > > - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > > > w; len--) > > - drw_font_getexts(usedfont, utf8str, len, &ew, > > NULL); > > + if (ew > w) > > + for (ew = 0, len = 0; ew < w - lpad * 2 && len > > < MIN(utf8strlen, > > sizeof(buf) - 1); len++) > > + drw_font_getexts(usedfont, utf8str, > > len, &ew, NULL); > > + else > > + len = MIN(utf8strlen, sizeof(buf) - 1); > > To test, try selecting previous/next items with the following (adjust -c as > needed): > for i in $(seq 20); do > cat /dev/urandom | base64 | tr -d '\n' | head -c 1000000 > done | ./dmenu -l 10 >
Hi Miles, Thanks for the patch. It uses indeed less resources for very long lines and it makes more sense to do it this way. A small change for the test script, you probably want to add a newline (echo) between it: for i in $(seq 20); do cat /dev/urandom | base64 | tr -d '\n' | head -c 1000000 echo done | ./dmenu -l 10 I synced the code to dwm and the libsl repository too. -- Kind regards, Hiltjo