kenshaw / wofimoji

A emoji picker for wofi
MIT License
2 stars 1 forks source link

select unicode characters #4

Open mvdan opened 3 months ago

mvdan commented 3 months ago

I know people whose names use letters that I can't easily type on my keyboard, like "ß". It would be neat to be able to open wofimoji in a way that I can type "sharp s" and be able to select the character.

This might be fairly tricky to implement efficiently. Other projects implement this and are very slow, like rofimoji -f all. The only way I can see to implement this would be to get rune names in a range one by one via https://pkg.go.dev/golang.org/x/text/unicode/runenames#Name, which unfortunately seems to do a relatively expensive binary search.

https://github.com/golang/go/issues/32937 exists as a sort of similar upstream proposal, but I think that's more for direct lookups, not fuzzy matching.

I think the fastest way, given that the runenames package appears to generate a list of runes paired with a list of rune names would be to expose a new API in that package that allows us to iterate through all the known rune names in a range, meaning that we would do a linear iteration through the names in a range rather than a linear Visit of all the runes in a range multiplied by a binary search of each rune name via the existing API. Shouldn't be too hard to do via a patch upstream, if they will take it.

kenshaw commented 3 months ago

Sure, I'm open to anything. Don't most keyboards have shortcuts though for those combination letters? (yes, you would need to be using the corresponding keyboard variant ...)

kenshaw commented 3 months ago

@mvdan I just pushed a quick hack that will show any named unicode rune, when passing --unicode -- this is disabled by default, because the performance in wofi for anything more than a couple hundred line entries is extremely bad. Generating the roughly 35,000 lines for all of the available namedrunes takes about 100ms on my fairly beefy desktop, which is well under the threshold for human perception (approx 200ms).

The limitation here really seems to be wofi. For example, the 1200 or so emojis currently that get displayed works "instantly" for me, but even limiting it to the first 500 named unicode runes makes it almost unusable.

I'd appreciate your feedback if this is what you were looking for, and how to make this more usable. Using specified tables/ranges would work fine, sure, but what would that look like on the command-line?