HACKER Q&A
📣 java-man

Bidirectional Text Navigation


This question is specifically for people who use right-to-left OSes and software (Arabic, Hebrew, Farsi, etc.)

When navigating (using cursor arrow keys) or editing "mixed" text (text that contains a mixture of right-to-left (RTL) and left-to-right (LTR) segments, what is your expectation (or wish) regarding the caret movement and appearance?

A bit of background. It looks like initially, many software packages employed what we might call a "visual" navigation, that is, repeating RIGHT arrow key would move the caret one symbol to the right, regardless of the directionality of the text. Some time after 2007, it seems, there was a switch to a "logical" navigation when the movement of the caret is governed by the position of the insertion index in the underlying (unicode) text. In this mode, repeatedly pressing RIGHT key results in the caret switching direction when it crosses the boundary between segments having a different orientation.

When it comes to the caret appearance, a number of options can be seen:

1. caret is unchanged

2. caret shows a little directionality indicator that looks like a little pennant or line

3. a dual or split caret

So the questions I have are:

1. Is there a consensus currently as to how the caret navigation should work in mixed text?

2. How should, in your opinion, the ideal navigation work?

3. How, in your opinion, should software indicate the insertion point for the next typed character?

4. Is there an example of software designed for your writing system, that get all of it right?

Your answers will affect the direction of a certain open source platform.

Thank you so much in advance!


  👤 obahareth Accepted Answer ✓
I'm bilingual and frequently use English and Arabic together.

What I'm used to is that the caret is unchanged.

The best setup I've seen out there is web browsers with dir set to auto and using properties like padding-start instead of padding-left.

If I start a block with an LTR character the content is automatically left-aligned and vice versa.

The annoying issue comes up when you have bidi characters in the middle of RTL (e.g. Comma or exclamation mark), all tools I've currently seen just break, I have no idea where the cursor is, or where it will move to when I press my arrow keys. I would prefer that bidi characters are treated the same way as the paragraph or block they're in.

I wrote an article a while back with some GIFs that showcases these difficulties:

https://blog.prototypr.io/the-case-of-the-jumping-dot-17f97a...

I've not found any software that gets it all right when it comes to mixed direction content, but for RTL-only then most of the popular word processors (e.g. Google Docs) are quite good with some tweaking.

Happy to chat more on this.


👤 yonatan8070
In my opinion Android does it perfectly, if a block starts with an RTL character it will be right-aligned, and if it's an LTR character it will be left-aligned

As for mixed, the cursor moves continously through text (visually, not by index)

I like the way it works, the only times I need to fight with it is if I want to mix languages and start with an English term, but the majority of the sentence is in Hebrew, since the structure of the whole thing will get mangled


👤 java-man