For the cursor things are as I thought: check out Paragraph::getParLanguage in Paragraph.cpp.
Lior On Wed, Jul 8, 2015 at 8:52 PM, Lior Silberman <lior3.1...@gmail.com> wrote: > On Mon, 06 Jul 2015 02:43:25 -0700 Scott Kostyshak wrote: >> Thank you Lior and Guy for the explanations. I think I'm starting to >> understand a bit more. However, when you say "document is LtR", I assume you >> mean that the language in document settings is a language that is RtL? If >> that is the case, then why when I go to the document settings and change the >> language from Arabic to English, nothing changes (note I still have >> "logical" cursor movement set). From what I understand from your above >> explanation, after the change, in Arabic "right arrow" means "move forward". >> But if I put the cursor at the beginning of the document (e.g. with ctrl + >> home), which is in Arabic, Left arrow moves forward and Right arrow does >> nothing. >> >>I attach the document in 2.1.x format now. >> >>Scott > > LaTeX assigns directionality at the paragraph level. Testing with > 2.1.3 (but not reading the code yet), I deduce that LyX also assigns > an LtR/RtL value at the paragraph level -- by examining the language > of the first character (!) (because of my naive test I assumed this > was done at the document level). > > So if the first character in a paragraph is from a LtR language, then > _for that paragraph_ right-arrow is forward and left-arrow is back. > If the first character is from a RtL language then you get the > opposite behaviour. By the way, this matters beyond arrow keys. For > example, if the paragraph is a section heading, then LyX prints the > section number on the left if it thinks it's in LtR mode (first > character marked English) but on the right if it thinks it's in RtL > mode (first character marked Arabic). That's certainly wrong: the > user should be allowed to set the "paragraph language" independently > of the language for individual text. > > Conclusion 1: We may want 3 cursor modes, splitting the "logical" mode > into one relying on the document language and one changing the cursor > behaviour paragraph-by-paragraph. I wonder home many people on > lyx-users write bidirectional documents and have to deal with this. > > [As far as I can tell, LibreOffice decided to always have a "logical" > cursor with LtR default (so right-arrow moves towards the end of text > even in a Hebrew-only document)]. > > Conclusion 2: assuming my understanding is correct, each paragraph > needs a "Language" field which is independent of the "Language" > setting of the text inside it. At creation this should be copied from > the document language (ensuring that section headings, say, behave > consistently even if they are written in the "wrong language"). The > "Edit -> Paragraph Settings" dialogue should allow changing the > language of a paragraph. Of course, having a paragraph-level language > different from the language of the text in the paragraph would also be > confusing to users, but that's the way LaTeX works. > > If I have time I'll examine the detailed documentation (I mean the > code) and see what's really going on. > > Lior