Stefan Schimanski wrote:
Hi!

Can anybody please explain me Text::bidi? It keeps a cache of RTL<->LTR levels for a row. But this variable is in the Text class, in the public section. It does not store for which paragraph or row it has values. It is accessed from all over the LyX code. At some few places it is updated to another row (e.g. in the RowPainter). There is zero documentation for it in the Text class declaration. Its computation function is 3 screens long with a lot of position magic going on, but without any (zero, niente, none) line of documentation. If you want to learn what bad code is, you will have a lot learning material here.

What I want to say with this example: the bidi code is in a very bad state. We are lucky that it is more or less working.

Stefan

This is not totally fair. The fact is, it's implementing a well-known, standard, function. To understand it, you probably have to read up on the Bidi algorithm (I've never done it thoroughly, I don't know this code, either, and have been trying to avoid it as much as possible, partly for the reasons you've stated ;) ). But, the fact is that it works, I've yet to see a problem which is due to the heart of the bidi algorithm. (Do you think you have found one, now?) If you find yourself wanting to change things inside it, then chances are that's not the right way to go about it; unless you purposely want to change things from the standard bidi behavior (which I actually think I may want to do, in order to fix the "GUI-backend bidi mismatch" --- I'm not sure it's such a great idea, though). But then that should be done very carefully...

I assume a lot of the deficiencies you describe are due to the fact that the code is really old, I once started trying to trace something in there back, and reached the days when a lot of different parts of LyX were still all in text.C, or whatever it was called then, and finally gave up. And I suspect that people were hesitant about playing around with it later, given that they didn't understand it... And when changes were made, I'm not sure they were always for the better...

All that said, I must reiterate again: I don't know this code, either...

Dov

Reply via email to