unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Eli Zaretskii" <eliz@elta.co.il>
Cc: gerd.moellmann@t-online.de, alex@emacswiki.org,
	emacs-bidi@gnu.org, developer@arabeyes.org, emacs-devel@gnu.org
Subject: Re: merge emacs-bidi into the main tree
Date: Tue, 12 Aug 2003 08:59:52 +0200	[thread overview]
Message-ID: <9743-Tue12Aug2003085951+0300-eliz@elta.co.il> (raw)
In-Reply-To: <200308120149.KAA23819@etlken.m17n.org> (message from Kenichi Handa on Tue, 12 Aug 2003 10:49:26 +0900 (JST))

> Date: Tue, 12 Aug 2003 10:49:26 +0900 (JST)
> From: Kenichi Handa <handa@m17n.org>
> 
> In brief, what I did in emacs-bidi are:
> 
> (1) change xdisp.c to call get_next_display_element_visually
>   and set_iterator_to_next_visually instead of
>   get_next_display_element and set_iterator_to_next.
> 
> (2) make a new file bidi.c that implements
>   get_next_display_element_visually and
>   set_iterator_to_next_visually.
> 
> (3) make a new file bidi.el that implements simple
>   bidi-reordering function that is called from
>   get_next_display_element_visually to create a cache in
>   (struct it).
> 
> (4) change xterm.c to display glyphs flushing to right when
>   orientation-reversed is non-nil.
> 
> My current plan is to replace (2) and (3) with Eli's code.

It's not gonna be that simple ;-)

The code I wrote is designed to be plugged into the part of the
display engine that walks the buffer and, for each character it
encounters, generates a `struct glyph' element of the glyph matrix.
Currently, ignoring overlays, text properties, etc., this buffer scan
is linear, from left to right, and going to the next buffer position
is simple:

	IT_BYTEPOS (*it) += it->len;
	IT_CHARPOS (*it) += 1;

(this is from xdisp.c:set_iterator_to_next).  That is, we simply
increment the buffer's character position by one.  (If the next
display element comes from something other than the buffer, the code
in set_iterator_to_next does similar things with the object that is
the source of characters.)

The code I wrote replaces the buffer position increment with a call to
a function.  Thus, the above two lines should roughly be replaced with
this:

	bidi_get_next_char_visually (it->bidi_it);

[IT_BYTEPOS (*it) and IT_CHARPOS (*it) get set to the right values
inside that call.]

What bidi_get_next_char_visually does is to find the next character in
the buffer in the visual order; that could involve quickly scanning
across a run of characters until we find the one we want to display.
For example, i fthe buffer's contents are

	abcdABCDefg

then after processing `d', the code will scan until `D', then go back
to `C', `B', and `A', in that order, then jump to `e', and finally
proceed to `f' and `g'.

(To save future work, some crucial information about the characters
over which we scan is cached inside the bidi_it struct, to facilitate
processing later when we need to go back to those characters and
generate the glyph matrix elements from them.  So, in the above
example, going back from 'D' to 'A' boils down to delivering
information already cached during the forward scan.)

So a linear scan becomes non-linear, but the details of that are
completely concealed from set_iterator_to_next; as far as it is
concerned, it just magically jumped over a few characters and landed
on the next character to be displayed.  The glyph matrices are layed
in the visual order.

In other words, the structure and logic of the code in xdisp.c remains
largely unchanged, the only changes being where we find the position
of the next display element.  Or so I hope, anyway...

(There still needs to be more code in the terminal-specific parts of
Emacs, that displays the glyphs either starting at the left or the
right margin of the screen/window, depending on the current
paragraph's base direction; the latter gets decided by subroutines of
bidi_get_next_char_visually and is stored in the bidi_it structure.  I
believe this code, at least for the X terminals, already largely
exists in m17n.org's emacs-bidi.)

  reply	other threads:[~2003-08-12  6:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87lluax3ch.fsf@emacswiki.org>
     [not found] ` <7458-Sun03Aug2003224354+0300-eliz@elta.co.il>
     [not found]   ` <87smoi9p64.fsf@emacswiki.org>
     [not found]     ` <u1xw26isb.fsf@elta.co.il>
2003-08-04 14:54       ` merge emacs-bidi into the main tree Alex Schroeder
2003-08-07  6:05         ` Richard Stallman
2003-08-07 14:29           ` Eli Zaretskii
2003-08-08  9:05             ` Oliver Scholz
2003-08-08 11:47               ` Kenichi Handa
2003-08-08 15:57               ` Eli Zaretskii
2003-08-08 11:23             ` Gerd Moellmann
2003-08-08 16:02               ` Eli Zaretskii
2003-08-08 16:13                 ` Gerd Moellmann
2003-08-09 14:21                   ` Richard Stallman
2003-08-09 14:58                     ` Gerd Moellmann
2003-08-10  6:34                     ` Eli Zaretskii
2003-08-10 10:42                       ` Gerd Moellmann
2003-08-10 16:56                         ` Eli Zaretskii
2003-08-10 16:33                           ` Gerd Moellmann
2003-08-10 16:45                             ` Stefan Monnier
2003-08-11 12:53                       ` Richard Stallman
2003-08-12  1:49                         ` Kenichi Handa
2003-08-12  6:59                           ` Eli Zaretskii [this message]
2003-08-12  7:18                             ` Kenichi Handa
2003-08-12  8:48                               ` Eli Zaretskii
2003-08-13 17:13                           ` Richard Stallman
2003-08-09 14:21               ` Richard Stallman
2003-08-09 15:04                 ` Gerd Moellmann
2003-08-10  6:36                 ` Eli Zaretskii
2003-08-08 11:44             ` Kenichi Handa
2003-08-08 16:04               ` Eli Zaretskii
2003-08-08 17:48               ` Alex Schroeder
2003-08-08 18:58           ` Chahine M. HAMILA
2003-08-09 18:43           ` Nadim Shaikli
2003-08-11 12:54             ` Richard Stallman
2003-08-11 16:32               ` Nadim Shaikli
2003-08-12 23:22                 ` Richard Stallman
2003-08-13  0:33                   ` Kenichi Handa
2003-08-14  3:08                     ` Richard Stallman
2003-08-15  5:51                       ` Kenichi Handa
2003-08-15 11:51                         ` Alex Schroeder
2003-08-15 15:38                           ` Nadim Shaikli
2003-08-17  0:36                         ` Richard Stallman
2003-08-18  0:24                           ` Kenichi Handa
2003-08-13  3:44                   ` Nadim Shaikli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9743-Tue12Aug2003085951+0300-eliz@elta.co.il \
    --to=eliz@elta.co.il \
    --cc=alex@emacswiki.org \
    --cc=developer@arabeyes.org \
    --cc=emacs-bidi@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=gerd.moellmann@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).