Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTL Cursor Movement (Backwards) #112

Closed
jcuenod opened this issue Mar 2, 2019 · 10 comments
Closed

CTL Cursor Movement (Backwards) #112

jcuenod opened this issue Mar 2, 2019 · 10 comments
Labels
enhancement This is an enhancement to a feature of Zettlr.

Comments

@jcuenod
Copy link

jcuenod commented Mar 2, 2019

Description

CTL (Complex Text Layout) text is text that involves both LTR (left-to-right) and RTL (right-to-left) content. When using <ctrl>+<left arrow> to jump back over words, the cursor gets stuck on CTL text.

Reproducing

With the text one אלהים" three and the cursor at the end of the line, repeatedly use <ctrl>+<left arrow> to move to the start of the line.

Expected behaviour

The cursor will eventually reach the start of the line

Actual Behaviour

In reality, the cursor jumps backwards and forwards across the RTL text.

Platform

  • OS: Antergos
  • Zettlr Version 1.1.0

Additional information

This is related to the RTL text itself and the quotation mark in the text. אלהים produces this behaviour but שׁני did not when I tested it. I think the quotation mark affects where the cursor lands relative to other text and so is also important in producing this behaviour. I haven't figured out anything more that explains the behaviour. I assume that this is a codemirror bug but I thought I'd start here.

@nathanlesage
Copy link
Member

I knew I would need to face the RTL-issue sooner or later =D

To sum up what I've already done on supporting RTL: Unfortunately, nothing. So there are, if I remember correctly, some settings that can be set on CodeMirror itself to enable better RTL-support. I'm not sure which ones, so if you'd want to supply me with some kind of test Markdown-file containing some Hebrew and English words/phrases/sentences, I could do some testing (I already have quite a collection of different Markdown test files which I open up subsequently before publishing a new release, so this would be the logical next test file).

I'll have a look into it. And in the meantime, please look out for potential other pitfalls that may occur during RTL text usage! :)

@nathanlesage nathanlesage added the enhancement This is an enhancement to a feature of Zettlr. label Mar 2, 2019
@jcuenod
Copy link
Author

jcuenod commented Mar 2, 2019

Okay, another major one is font. I don't know if it's possible to set an alternative font for specific unicode ranges or something like that but right now that's probably Zettlr's biggest weakness handling the Hebrew I'm working with.

@nathanlesage
Copy link
Member

Mh, yes, the fonts are indeed a problem. I'm also in contact with an Islamic Scientist who's also had problems writing Persian and Arabic glyphs, which is why I switched to Liberation Mono for the monospaced fonts. It is really hard to get both the font contain the glyphs and CodeMirror to display them. There are some accents that CodeMirror can't display correctly :/

And I'm not sure whether it would make sense to allow special glyphs to be displayed in a different font, because normally the app should already do this (sometimes when you write exotic glyphs, you may see the font is different for them, which is the app fetching the glyph from a fallback font)

@nathanlesage
Copy link
Member

I just remembered the magical keyword for CodeMirror: It's "bidi", and I directly found this:

image

So in case that works I can implement a non-persistent switch somewhere easily accessible to momentarily switch the base direction. I don't know where to put it, but what you could do in the meantime to test it, would be to do the following:

  1. Activate debug mode in the Advanced tab of the preferences dialog
  2. Restart the app
  3. Open one of the affected files
  4. Open the developer console (Develop -> Toggle developer tools)
  5. In the Console-tab, enter: renderer._editor._cm.setOption('direction', 'rtl') (or 'ltr' for the default mode again)
  6. See if that solves the problem

@jcuenod
Copy link
Author

jcuenod commented Mar 6, 2019

Hmm, I haven't tried it yet but this doesn't sound like it'll solve the problem. My base direction is actually still consistently ltr. I think this is a weakness in CodeMirror's handling of bidirectional text.

I'll give it a try (maybe this weekend) and let you know.

@nathanlesage
Copy link
Member

I fear this as well, but maybe we'll find something that works out for you!

@nathanlesage
Copy link
Member

Any updates on this one?

@jcuenod
Copy link
Author

jcuenod commented May 9, 2019

I just made sure I was still up to date. The sample above one אלהים" three still doesn't work for cursor movement (so this issue is still active). I don't remember whether the font has changed to be honest - it doesn't look too bad though.

@nathanlesage
Copy link
Member

The font mainly concerns the glyphs available, so there's not so much it can do concerning the cursor movement. But I am starting to think that this issue should be posed with CodeMirror, as it concerns the inner workings of the editor. Would you mind transferring it there? I think Marijn can help you more than I can :S

@nathanlesage
Copy link
Member

Mh, I'll close this issue --- if the BiDirectional issues still occur, I'd really suggest opening issues on the CodeMirror repository, as this issue more or less is out of my scope!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement to a feature of Zettlr.
Projects
None yet
Development

No branches or pull requests

2 participants