emacs-bidi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-bidi] Re: Display of continuation lines


From: Eli Zaretskii
Subject: Re: [emacs-bidi] Re: Display of continuation lines
Date: Sat, 13 Oct 2001 23:06:10 +0200

> From: Behdad Esfahbod <address@hidden>
> Date: Sun, 14 Oct 2001 00:06:31 +0330 (IRT)
> 
> On Thu, 11 Oct 2001, Yair Friedman (Jerusalem) wrote:
> 
> > "Eli Zaretskii" <address@hidden> writes:
> > 
> > > As I slowly work on coding the sequential bidi algorithm suited for
> > > Emacs, one issue presented itself that I thought would be useful to
> > > discuss: how do we want to display continuation lines.
> > [...]
> > > The question is, given a bidirectional text:
> > >
> > >       abcdeABCDEFGH
> > >
> > > do we want it to be displayed like this:
> > >
> > >       abcdeHGF\
> > >       EDCBA
> > >
> > > or like this:
> > >
> > >       abcdeCBA\
> > >       HGFED
> > 
> > Whatever you do, there will be cases where it won't look good.  You can
> > see this in the newspapers where narrow columns are common... Go for the
> > simple solution instead.
> 
> The Unicode BiDi Alg. UAX#9, outputs the second one, that is the
> correct one too, you naturally read each line completely and then go
> to the next line...

I think the Unicode algorithm is not very releveant to this because it
describes something different from the Emacs continuation lines.  What
UTR#9 describes is a typical word processor which automatically wraps
long lines.  Emacs has 2 features for similar functionality:
auto-filling and continuation lines.

Auto-filling works by inserting newline characters where the line
should be broken.  Since this modifies the buffer contents, the bidi
display will always DTRT in that case, i.e. produce the second variant
above (but without the backslash).

By contrast, continuation lines is something done by the display
engine after it computes the glyphs required to display the line.
This is way after the bidi algorithm does its job, so it's almost
impossible to do without rewriting the Emacs display code.

UTR#9 says that reordering of resolved levels should be done after
glyphs are layed out and their widths used for line breaking, but that
is only possible for some specific architectures of the display
engine.  The structure of the Emacs display engine is incompatible
with this requirement, and therefore the UTR#9 implementation I wrote
doesn't reorder the characters per se, it simply delivers them to the
display engine in the visual order: the display engine asks for the
next character, and the bidi algorithm returns the next character in
the visual order.  That is, instead of walking the buffer in a linear
fashion, the bidi display will walk it non-linearly.

In general, anyone who tried to implement UTR#9 knows all too well
that it is too specific to a certain class of applications.  That's
hardly surprising, since we know exactly from what application was
that algorithm lifted ;-)

Anyway, since the main Emacs feature that is equivalent to line-wrap
is auto-fill, I don't think that displaying continuation lines as the
first variant above shows will do any real harm.  It does have a
_huge_ advantage of avoiding a complete rewrite of the Emacs display
code, which is something unthinkable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]