Follow-up on pull request #16 this change refactors and combines
the highlight and fuzzy highlight patches into one highlight
function.
Overall it does not make any sense using:
- fuzzy highlighting when exact matching is used or
- exact highlighting when fuzzy matching is used
As such it makes sense to combine the two such that:
- exact highlighting is used when exact matching is used and
- fuzzy highlighting is used when fuzzy matching is used
The FUZZYHIGHLIGHT_PATCH toggle has been removed in favour of
HIGHLIGHT_PATCH. The FUZZYMATCH_PATCH toggle controls whether
fuzzy matching is enabled. Enable both FUZZYMATCH_PATCH and
HIGHLIGHT_PATCH to enable fuzzy highlighting.
Additionally the fuzzy highlight patch only supported single-byte
characters and would break when encountering multi-byte UTF-8
characters. This was reported ref. #24.
This refactoring includes a change to work out the UTF-8 character
length for a given character rather than assuming that every
character uses one byte.
The highlight feature by default overrides other colour schemes and
may in the process partially or fully obscure that an item has already
been output (or is scheduled for output using the multiselect patch).
In this context the highlighting does not add any valuable information
given that the user has already selected the item. Overall it seems
more user-friendly to skip drawing highlights for outputted items.
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