emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 a8e6741: Fix conversion of pixel coordinates to b


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 a8e6741: Fix conversion of pixel coordinates to buffer position
Date: Sat, 28 Oct 2017 09:52:54 -0400 (EDT)

branch: emacs-26
commit a8e67410662e653e60e8dcc7aaf27042492afee8
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix conversion of pixel coordinates to buffer position
    
    * src/dispnew.c (buffer_posn_from_coords): Adapt to
    auto-hscroll-mode == current-line.
---
 src/dispnew.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/dispnew.c b/src/dispnew.c
index cb32f09..065d068 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5149,6 +5149,29 @@ buffer_posn_from_coords (struct window *w, int *x, int 
*y, struct display_pos *p
      include the hscroll. */
   to_x += it.first_visible_x;
 
+  /* If we are hscrolling only the current line, and Y is at the line
+     containing point, augment TO_X with the hscroll amount of the
+     current line.  */
+  if (it.line_wrap == TRUNCATE
+      && EQ (automatic_hscrolling, Qcurrent_line) && IT_CHARPOS (it) < PT)
+    {
+      struct it it2 = it;
+      void *it2data = bidi_shelve_cache ();
+      it2.last_visible_x = 1000000;
+      /* If the line at Y shows point, the call below to
+        move_it_in_display_line will succeed in reaching point.  */
+      move_it_in_display_line (&it2, PT, -1, MOVE_TO_POS);
+      if (IT_CHARPOS (it2) >= PT)
+       {
+         to_x += (w->hscroll - w->min_hscroll) * FRAME_COLUMN_WIDTH (it.f);
+         /* We need to pretend the window is hscrolled, so that
+            move_it_in_display_line below will DTRT with TO_X.  */
+         it.first_visible_x += w->hscroll * FRAME_COLUMN_WIDTH (it.f);
+         it.last_visible_x += w->hscroll * FRAME_COLUMN_WIDTH (it.f);
+       }
+      bidi_unshelve_cache (it2data, 0);
+    }
+
   /* Now move horizontally in the row to the glyph under *X.  Second
      argument is ZV to prevent move_it_in_display_line from matching
      based on buffer positions.  */



reply via email to

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