kas-gui / kas-text

Rich text processing
Apache License 2.0
58 stars 2 forks source link

Feature: display-order bidi navigation #36

Open dhardy opened 3 years ago

dhardy commented 3 years ago

Currently our API recommends using an external library such as unicode-segmentation in order to navigate "left/right" by one glyph. This results in logical-order text navigation (or optionally, reversed logical order navigation for RTL lines).

We should add support for display-order navigation, which is much easier within this library than externally.

We might try using glyphs within glyph-runs (TextDisplay::runs[run].glyphs). Caveat: the runs on a line are not in display order. We could thus compare glyphs using Glyph::position or we could store runs in display order (simply remove the sort_by_key line within wrap_lines.rs, but then we have to fix a couple of algorithms currently expecting logical-order runs).

We also have to consider the position at the end of each run, which may or may not coincide with the start of another run, and if it does may or may not coincide with the text index of that position.

(I consider this low priority. Contributions welcome.)