marijnh/CodeMirror — pull request #2244 by nournia (2014-02-09 13:50:41+00:00)
Title: Right to Left Layout

I've added `rtlLayout` option for using CodeMirror as a right to left text editor. Provided example page shows its usage which is in Persian language (just like Arabic). I created this example to explain how it should work and at the moment it has some issues.

Rendered text and its styling is correct. But in this mode [bidi algorithm](http://marijnhaverbeke.nl/blog/cursor-in-bidi-text.html)'s behavior must be changed. For example, in the following image, when I put my cursor in the **beginning of the line**, it stands after # character:

![cursor in beginning of the line](https://f.cloud.github.com/assets/370741/2119821/5870e61a-918d-11e3-969c-9e316fe86a5b.png)

Also behavior of multi-cursor algorithm, must be changed. Following image shows that when I move cursor to beginning character of word, it shows two cursor. When you are typing Left to Right, this behavior is right because editor doesn't know your next character is RTL or LTR, but in `rtlLayout` it is nonsense. In this state if you type RTL or LTR characters, CodeMirror append them under gray cursor which is correct behavior and the black cursor is useless:

![multi-cursor](https://f.cloud.github.com/assets/370741/2119830/248458a4-918e-11e3-89da-b2cc7b997eca.png)

Finally, mouse click and text selection is completely non-predictable. The correct behavior is obvious: put cursor just under mouse position.

These is similar pull request #1103 which targets same problem but it seems that its changes are removed now. As I said, I've created this simple example for making clear the expected behavior of editor in Right to Left mode, so questions are welcome.