arp242 / uni

Query the Unicode database from the commandline, with good support for emojis
MIT License
790 stars 19 forks source link

Custom columns #20

Closed skuzzymiglet closed 3 years ago

skuzzymiglet commented 3 years ago

Thanks for writing uni, I find it very useful!

I've found myself trying to make an easy reference to Unicode-related data over time, such as

and more will probably be added in the future. I could put each one in Markdown format but it would be nice if they could integrate with uni.

Hardcoding these into the program itself would probably be feature creep, but a way to integrate different data would be really useful.

arp242 commented 3 years ago

I did some work on a -format [..] flag a while ago in a local branch, but I haven't really felt like working on it in a while, so ... no real ETA 😅 This is really a thing I wrote for my own purposes in my spare time, so it's kind of a "best effort, when I feel like it".

I'll be happy to review patches in a timely fashion though, if you feel like writing one.

Maybe I made it too fancy as well ... I had an entire mini-language to control column width and left/right alignment and whatnot, while all that's really needed is a list of columns to print in what order (width for alignment can just remain hard-coded really).

arp242 commented 3 years ago

There is now the -format flag; I added X11 keysyms for this as well:

% uni i -q -f '%(cpoint) %(name): %(keysym)' €
U+20AC EURO SIGN: EuroSign

See uni help in master; there are some other incompatible changes too (see changelog). I'll release version 2.0 at some point – need to refactor this a bit as the implementation isn't too great (but it works).


I didn't add Vim digraphs, mostly because I couldn't be bothered to get a nice list of digraphs as it's a bit of work and I never use it myself; if you can add a codepoint → digraph mapping then I can do the rest (that part is easy). Having a script to generate that would be best, as that would make it easy to update.

Just a simple text file is enough, but for extra points you can make it as a map[rune]string map in the unidata package similar to unidata/enitities.go or keysyms.go files.

skuzzymiglet commented 3 years ago

I don't know whether I still use Vim digraphs enough to justify needing them in uni, but I did assemble this list a year ago, with this old Python script. Also, it's an RFC: https://tools.ietf.org/html/rfc1345.

arp242 commented 3 years ago

Ah, right; I didn't know there's an RFC for it; I never used this Vim feature. I added that RFC list (minus some of the stuff not in Unicode) with the added Euro and Rouble signs from Vim as %(digraph):

[~c/uni](master)% uni i 'ëé§' -f '%(name l:auto)  %(digraph)'
name                                 digraph
LATIN SMALL LETTER E WITH DIAERESIS  e:
LATIN SMALL LETTER E WITH ACUTE      e'
SECTION SIGN                         SE