emacs-diffs
[Top][All Lists]
Advanced

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

master 1aaceec: Fix vertical cursor motion across tall text or small ima


From: Eli Zaretskii
Subject: master 1aaceec: Fix vertical cursor motion across tall text or small images
Date: Thu, 13 May 2021 09:13:20 -0400 (EDT)

branch: master
commit 1aaceec93173fd98c25dfe282b2fa2030ccf14f0
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix vertical cursor motion across tall text or small images
    
    'line-move-partial' should in general leave it to the display
    engine to scroll or recenter the window due to vertical motion of
    the cursor.  The only purpose of this function is to produce
    vscroll suitable for scrolling across large (relatively to the
    window's height) images, where moving by display lines is not
    appropriate.
    
    * src/xdisp.c (Fdisplay__line_is_continued_p): New primitive.
    
    * lisp/simple.el (line-move-partial): Call
    'display--line-is-continued-p' to decide whether to leave it to
    redisplay to scroll the window as appropriate.  (Bug#48170)
---
 lisp/simple.el |  6 ++++--
 src/xdisp.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 35bb472..0255f69 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6935,11 +6935,13 @@ The value is a floating-point number."
               (or (null rbot) (= rbot 0)))
          nil)
         ;; If cursor is not in the bottom scroll margin, and the
-        ;; current line is not too tall, move forward.
+        ;; current line is not too tall, or if there's a continuation
+        ;; line below this one, move forward.
         ((and (or (null this-height) (<= this-height winh))
               vpos
               (> vpos 0)
-              (< py last-line))
+              (or (< py last-line)
+                   (display--line-is-continued-p)))
          nil)
         ;; When already vscrolled, we vscroll some more if we can,
         ;; or clear vscroll and move forward at end of tall image.
diff --git a/src/xdisp.c b/src/xdisp.c
index 23b4ba5..4841a0a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10838,6 +10838,47 @@ include the height of both, if present, in the return 
value.  */)
 
   return Fcons (make_fixnum (x - start_x), make_fixnum (y));
 }
+
+DEFUN ("display--line-is-continued-p", Fdisplay__line_is_continued_p,
+       Sdisplay__line_is_continued_p, 0, 0, 0,
+       doc: /* Return non-nil if the current screen line is continued on 
display.  */)
+  (void)
+{
+  struct buffer *oldb = current_buffer;
+  struct window *w = XWINDOW (selected_window);
+  enum move_it_result rc = MOVE_POS_MATCH_OR_ZV;
+
+  set_buffer_internal_1 (XBUFFER (w->contents));
+
+  if (PT < ZV)
+    {
+      struct text_pos startpos;
+      struct it it;
+      void *itdata;
+      /* Use a marker, since vertical-motion enters redisplay, which can
+        trigger fontifications, which in turn could modify buffer text.  */
+      Lisp_Object opoint = Fpoint_marker ();
+
+      /* Make sure to start from the beginning of the current screen
+        line, so that move_it_in_display_line_to counts pixels correctly.  */
+      Fvertical_motion (make_fixnum (0), selected_window, Qnil);
+      SET_TEXT_POS (startpos, PT, PT_BYTE);
+      itdata = bidi_shelve_cache ();
+      start_display (&it, w, startpos);
+      /* If lines are truncated, no line is continued.  */
+      if (it.line_wrap != TRUNCATE)
+       {
+         it.glyph_row = NULL;
+         rc = move_it_in_display_line_to (&it, ZV, -1, MOVE_TO_POS);
+       }
+      SET_PT_BOTH (marker_position (opoint), marker_byte_position (opoint));
+      bidi_unshelve_cache (itdata, false);
+    }
+  set_buffer_internal_1 (oldb);
+
+  return rc == MOVE_LINE_CONTINUED ? Qt : Qnil;
+}
+
 
 /***********************************************************************
                               Messages
@@ -34739,6 +34780,7 @@ be let-bound around code that needs to disable messages 
temporarily. */);
   defsubr (&Swindow_text_pixel_size);
   defsubr (&Smove_point_visually);
   defsubr (&Sbidi_find_overridden_directionality);
+  defsubr (&Sdisplay__line_is_continued_p);
 
   DEFSYM (Qmenu_bar_update_hook, "menu-bar-update-hook");
   DEFSYM (Qoverriding_terminal_local_map, "overriding-terminal-local-map");



reply via email to

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