Saturday, February 26, 2011

Re: bidi in vim

* Ben Schmidt <mail_ben_schmidt@yahoo.com.au> [25/02/11 17:12]:
> Hi, Moshe,
>
> I've rearranged things a bit to suit my reply.
>
> > Of course I also would prefer to have full bidi support, but I can also
> > see that this would require some serious changes and complications in
> > the code,
>
> I think basing it on syntax regions/matches/whatever also would require
> serious changes. I don't think there is any 'easy' way to do this, and
> if we have to pick between 'hard' ways, I think it would be smartest to
> pick the way that is actually most standard/correct.

That, in my opinion, is the main question. I know nothing about the Vim
code, and if implementing it would be as difficult as integrating the
bidi algorithm, then there is obviously no point in doing it. The way I
imagined things work is more or less:

1. The user performs some operation, such as adding text or moving the
cursor. The operation is logical, so no bidi considerations are
involved, and no change to the code is needed. At the end of this
stage, Vim has a logical representation of the new text, and the
location of the cursor in terms of the logical text
2. Vim prepares to display the new text (and the new cursor position).
Part of this process would be to determine the syntax regions, and
there would be a new bit here where the direction of the text is
stored
3. Vim actually displays the text. At this point, Vim would need to take
into account the direction, but the information is already available,
and no extra algorithm is required.

So, if things are as I imagine, there would only be a small change to
the syntax highlighting, and the rest in the gui part.
>
> > I also don't see that what I'm suggesting is a hack or a workaround.
>
> I think it is a hack because which direction text should be displayed
> really has nothing to do with syntax regions conceptually. It is about
> what language the text is in, what script the characters in the text
> come from, etc..
>

Well, this is becoming a bit theoretical, but I don't see why the
direction of the text should be inherently determined by the character
set. Imagine that people in Australia decide to start writing from right
to left (but maintain the same alphabet). Then you would have to insert
direction marking in a logical text to determine the text direction (and
consequently could use these markings to define syntax regions). It is
just a (fortunate) coincidence that the direction of the text is
determined by the alphabet.

> >>> If this can be done, I think it will solve most practical
> >>> problems,
> >>> since when editing latex, for example, text in different direction will
> >>> appear in particular commands or environments.
>
> My perspective is a bit different. When I want bidi text, it's not
> because I have text of one language embedded in particular regions of a
> program or script or markup. It's because I'm writing in multiple
> languages. I would have thought this, too, was quite common, i.e. simply
> editing text.
>

Again, I agree that full bidi support would be better, and indeed there
are cases (as in writing emails) when there is no particular markup is
already available. But I would happily pay the price of explicitly
adding Right-Left marks to make use of an existing partial
implementation, rather than have nothing at all.

Thanks,
Moshe

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: