emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101530: Fix position calculation on


From: Kenichi Handa
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101530: Fix position calculation on mouse click within bidi-reordered composition.
Date: Wed, 22 Sep 2010 11:57:19 +0900
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101530 [merge]
committer: Kenichi Handa <address@hidden>
branch nick: trunk
timestamp: Wed 2010-09-22 11:57:19 +0900
message:
  Fix position calculation on mouse click within bidi-reordered composition.
modified:
  src/ChangeLog
  src/dispnew.c
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-09-21 19:33:59 +0000
+++ b/src/ChangeLog     2010-09-22 02:56:28 +0000
@@ -1,3 +1,15 @@
+2010-09-22  Kenichi Handa  <address@hidden>
+
+       * xdisp.c (compute_stop_pos): Call composition_compute_stop_pos
+       only if we are not at a composition.
+       (set_iterator_to_next): Give it->end_charpos to
+       composition_compute_stop_pos.
+       (set_iterator_to_next, next_element_from_buffer): Likewise.
+
+       * dispnew.c (buffer_posn_from_coords): Fix position when the
+       current display element is a grapheme cluster in bidi-reordered
+       region.
+
 2010-09-21  Ari Roponen  <address@hidden>  (tiny change)
 
        * doc.c (Fsnarf_documentation): Use memmove instead of memcpy as

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2010-08-21 09:35:31 +0000
+++ b/src/dispnew.c     2010-09-22 02:54:58 +0000
@@ -5420,6 +5420,22 @@
   if (STRINGP (it.string))
     string = it.string;
   *pos = it.current;
+  if (it.what == IT_COMPOSITION
+      && it.cmp_it.nchars > 1
+      && it.cmp_it.reversed_p)
+    {
+      /* The current display element is a grapheme cluster in a
+        composition.  In that case, we need the position of the first
+        character of the cluster.  But, as it.cmp_it.reversed_p is 1,
+        it.current points to the last character of the cluster, thus
+        we must move back to the first character of the same
+        cluster.  */
+      CHARPOS (pos->pos) -= it.cmp_it.nchars - 1;
+      if (STRINGP (it.string))
+       BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
+      else
+       BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos));
+    }
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (it.what == IT_IMAGE)

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2010-09-18 11:59:53 +0000
+++ b/src/xdisp.c       2010-09-22 02:54:58 +0000
@@ -3177,7 +3177,7 @@
 {
   register INTERVAL iv, next_iv;
   Lisp_Object object, limit, position;
-  EMACS_INT charpos, bytepos, stoppos;
+  EMACS_INT charpos, bytepos;
 
   /* If nowhere else, stop at the end.  */
   it->stop_charpos = it->end_charpos;
@@ -3267,12 +3267,15 @@
        }
     }
 
-  if (it->bidi_p && it->bidi_it.scan_dir < 0)
-    stoppos = -1;
-  else
-    stoppos = it->stop_charpos;
-  composition_compute_stop_pos (&it->cmp_it, charpos, bytepos,
-                               stoppos, it->string);
+  if (it->cmp_it.id < 0)
+    {
+      EMACS_INT stoppos = it->end_charpos;
+
+      if (it->bidi_p && it->bidi_it.scan_dir < 0)
+       stoppos = -1;
+      composition_compute_stop_pos (&it->cmp_it, charpos, bytepos,
+                                   stoppos, it->string);
+    }
 
   xassert (STRINGP (it->string)
           || (it->stop_charpos >= BEGV
@@ -6126,7 +6129,7 @@
                  it->cmp_it.id = -1;
                  composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),
                                                IT_BYTEPOS (*it),
-                                               it->stop_charpos, Qnil);
+                                               it->end_charpos, Qnil);
                }
            }
          else if (! it->cmp_it.reversed_p)
@@ -6149,7 +6152,7 @@
                {
                  /* No more grapheme clusters in this composition.
                     Find the next stop position.  */
-                 EMACS_INT stop = it->stop_charpos;
+                 EMACS_INT stop = it->end_charpos;
                  if (it->bidi_it.scan_dir < 0)
                    /* Now we are scanning backward and don't know
                       where to stop.  */
@@ -6177,7 +6180,7 @@
                {
                  /* No more grapheme clusters in this composition.
                     Find the next stop position.  */
-                 EMACS_INT stop = it->stop_charpos;
+                 EMACS_INT stop = it->end_charpos;
                  if (it->bidi_it.scan_dir < 0)
                    /* Now we are scanning backward and don't know
                       where to stop.  */
@@ -6210,7 +6213,7 @@
                {
                  /* As the scan direction was changed, we must
                     re-compute the stop position for composition.  */
-                 EMACS_INT stop = it->stop_charpos;
+                 EMACS_INT stop = it->end_charpos;
                  if (it->bidi_it.scan_dir < 0)
                    stop = -1;
                  composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),
@@ -6288,7 +6291,7 @@
              composition_compute_stop_pos (&it->cmp_it,
                                            IT_STRING_CHARPOS (*it),
                                            IT_STRING_BYTEPOS (*it),
-                                           it->stop_charpos, it->string);
+                                           it->end_charpos, it->string);
            }
        }
       else
@@ -6705,7 +6708,7 @@
       IT_BYTEPOS (*it) = it->bidi_it.bytepos;
       SET_TEXT_POS (it->position, IT_CHARPOS (*it), IT_BYTEPOS (*it));
       {
-       EMACS_INT stop = it->stop_charpos;
+       EMACS_INT stop = it->end_charpos;
        if (it->bidi_it.scan_dir < 0)
          stop = -1;
        composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),


reply via email to

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