Abdelrazak Younes wrote:
Dov Feldstern wrote:
and I don't have any idea why we need the \rtl flag in lyxrc. Why is
RTL display not derived from the language?
Good question. I guess it should...
I think that the reason for having the flag is just for efficiency: in
the end, the direction *is* determined by the language. However, this
means that you have to check every single letter to determine whether
it belongs to an RTL or LTR language. This is the Bidi algorithm,
which was implemented in LyX by Dekel Tsur, and the implementation is
LyX is very good. However, it is costly. So if we know that we won't
be using RTL languages, it's more efficient to just turn off this
flag, and then the whole Bidi algorithm is skipped.
Yes, looks you're right... thanks for the analysis! But I am pretty sure
that we can optimize that. So I stand on my point, RTL support should be
automatically detected. It is really wrong (and confusing to the user)
to put a check box to avoid some part of the code.
is really bad for this kind of settings.
It's not so bad, really, when you think about it. If I'm a user who uses
a Bidi language, then I know when I first install LyX, to set RTL to
true, and I'm done --- never have to think about it again.
OTOH, I guess it's really not so bad to just do the calculation all the
time. I mean, I have this switch on, and I don't feel that it slows me
down or anything. Maybe the option could be reversed --- by default,
have RTL support on, and allow users who happen to be working on really
slow machines and who do not use RTL languages to turn it off. For
everyone else, it probably doesn't really make a difference. (I guess
that profiling could be used to see how costly it really is.)
Also --- not that this is necessarily any proof that it's good ---
OpenOffice has the same kind of setting, somewhere.
So yes, the direction is ultimately determined by the language, but
there's still a point in having the flag.
Just in case you're wondering where all this is in the code: I only
just started mapping it out, but basically the Bidi algorithm is
implemented in Bidi.C (surprising, no? ;) ). The actual computation
takes place in Bidi::computeTables. And the first thing there is to
check if the flag is set, and if not, just set an inner flag (don't
ask me what the meaning of the name "start_" is), and immediately
return, rather than performing the costly calculation.
I am sure that we can intelligently avoid the calculation in an
automated way by looking at the unicode code-point. That's actually the
big point of unicode.
I don't understand what you mean. In order to determine if there's any
RTL letter, I have to look at every letter in the paragraph. Which I
don't have to do if I know ahead of time that there's no RTL language
there. I think that that's the time saved. Unicode only helps me once
I'm looking at the letter. Am I missing something?
Abdel.