Ken Bloom wrote:

> On Thu, 02 Jul 2009 20:03:02 +0200, Bram Moolenaar wrote:
> 
> > Adriaan Pater wrote:
> > 
> >> When I open a UTF-text file with right-to-left-text (hebrew in this
> >> case) and left-to-right-text (english in this case) in gedit it is
> >> rendered OK (rtl is displayed as rtl, ltr is displayed as ltr).
> >> 
> >> But when I open the same file in gvim the right-to-left text (hebrew)
> >> is showed as left-to-right text (just as the rest of the file, cq.
> >> english).
> >> 
> >> Is there a way to get the same behaviour as in gedit?
> >> 
> >> I searched for :help already and found things like mlterm, termbidi,
> >> set bomb etc. but I just can't gvim to show the text like gedit.
> > 
> > No, the whole text is either LTR or RTL.
> > 
> > I have never understood why people put the text in the wrong order in
> > the file and then change the order when displaying it.  The characters
> > should be in the file in the order they are displayed.
> > 
> > Perhaps there is a filter that change the order for this kind of file.
> 
> They're stored in the file in "logical order", which is the order that 
> the reader processes them when reading. That means, if he has an English 
> document with some embedded Hebrew, then when he encounters the first 
> Hebrew letter, his eyes will skip to the end of the Hebrew phrase (or the 
> end of the same line if it's a multi-line hebrew phrase), and start 
> working backwords until he hits the English, at which point his eyes will 
> skip again across the Hebrew to the English text that follows the Hebrew. 
> This is "logical order", and it's the order he reads in.
> 
> It's also the order that a computer would use if it were:
> * lexicographically comparing mixed-language strings
> * performing text-to-speech conversion
> * rewrapping paragraphs
> * it is the order in which text is typed at the keyboard.
> 
> See pages 19-20 of the Unicode Standard 5.0 (available online at http://
> unicode.org/versions/Unicode5.0.0/ch02.pdf)
> 
> Since display is the only part of the system that doesn't operate in 
> logical order, it's logical to put the conversion into the display 
> routines, rather than putting it into the file itself where it screws up 
> every other operation the computer has to perform on it.

The display is not the only part.  Suppose you move your cursor to the
start of a word and type "dw".  You expect the word to be deleted.
Since "start of the word" depends on what direction the word is to be
read, the editor needs to understand the meaning of the word to be able
to decide what to do.  And it gets worse: What if some of the characters
in the word are LTR and some are RTL?  This quickly gets very
complicated.

So Vim uses a simple and reliable method: Display the text either as LTR
or RTL and do the editing assuming all text is to be read that way.

You can open two windows on the same text, one in LTR and one in RTL if
you want to edit mixed text.

It would be really messy to display the text with mixed directions and
then have all edits work one way or perhaps fail with an error.  Or
worse: delete the wrong text.

There are actually many more places where it matters: When
concatanating two files with text, "echo -n" in the shell, etc.
That's why i18n is so difficult.

I'm glad Australians don't write upside-down!


-- 
hundred-and-one symptoms of being an internet addict:
55. You ask your doctor to implant a gig in your brain.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to