adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 125 forks source link

Attempt to track cursor more accurately by caching widths of grapheme's #362

Closed jamesragray closed 1 year ago

jamesragray commented 1 year ago

Not heavily tested. Just used it with my editor with a few emoji's.

jamesragray commented 1 year ago

One thing I need to check is that if two Graphemes consist of the same sequence of dchars then they produce the same hash. Another thing is whether one needs to worry about the graphemeWidth associative array becoming too large.

adamdruppe commented 9 months ago

I'm gonna have to actually revert this or something, it caused a major performance regression to the point where in some cases you can see the characters write out one at a time.

jamesragray commented 9 months ago

That sounds bad. Revert it for now and I will try and make a new pull request when I have time.

adamdruppe commented 9 months ago

An alternative might be to make the cursorX/Y getters go ahead and fetch if there's been a write since last time you asked. I might do that.

adamdruppe commented 9 months ago

This is my idea:

https://github.com/adamdruppe/arsd/commit/0ba0dc222ed131b17f464a89068b4dfe5961b068

Don't even try to guess, just track if it might have changed since the last call, and if so, query the terminal for an authoritative answer.

If it passes your tests we can tag.