aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2021-05-13 16:12:10 +0300
committerEli Zaretskii2021-05-13 16:12:10 +0300
commit1aaceec93173fd98c25dfe282b2fa2030ccf14f0 (patch)
tree30e40e01d9464f989ce132a6a5a9e6ea4f8399b0 /src
parent1b919004f65f6987c5815e7d65a00b78e19fc7ac (diff)
downloademacs-1aaceec93173fd98c25dfe282b2fa2030ccf14f0.tar.gz
emacs-1aaceec93173fd98c25dfe282b2fa2030ccf14f0.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 23b4ba5c39c..4841a0af6f3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10838,6 +10838,47 @@ include the height of both, if present, in the return value. */)
10838 10838
10839 return Fcons (make_fixnum (x - start_x), make_fixnum (y)); 10839 return Fcons (make_fixnum (x - start_x), make_fixnum (y));
10840} 10840}
10841
10842DEFUN ("display--line-is-continued-p", Fdisplay__line_is_continued_p,
10843 Sdisplay__line_is_continued_p, 0, 0, 0,
10844 doc: /* Return non-nil if the current screen line is continued on display. */)
10845 (void)
10846{
10847 struct buffer *oldb = current_buffer;
10848 struct window *w = XWINDOW (selected_window);
10849 enum move_it_result rc = MOVE_POS_MATCH_OR_ZV;
10850
10851 set_buffer_internal_1 (XBUFFER (w->contents));
10852
10853 if (PT < ZV)
10854 {
10855 struct text_pos startpos;
10856 struct it it;
10857 void *itdata;
10858 /* Use a marker, since vertical-motion enters redisplay, which can
10859 trigger fontifications, which in turn could modify buffer text. */
10860 Lisp_Object opoint = Fpoint_marker ();
10861
10862 /* Make sure to start from the beginning of the current screen
10863 line, so that move_it_in_display_line_to counts pixels correctly. */
10864 Fvertical_motion (make_fixnum (0), selected_window, Qnil);
10865 SET_TEXT_POS (startpos, PT, PT_BYTE);
10866 itdata = bidi_shelve_cache ();
10867 start_display (&it, w, startpos);
10868 /* If lines are truncated, no line is continued. */
10869 if (it.line_wrap != TRUNCATE)
10870 {
10871 it.glyph_row = NULL;
10872 rc = move_it_in_display_line_to (&it, ZV, -1, MOVE_TO_POS);
10873 }
10874 SET_PT_BOTH (marker_position (opoint), marker_byte_position (opoint));
10875 bidi_unshelve_cache (itdata, false);
10876 }
10877 set_buffer_internal_1 (oldb);
10878
10879 return rc == MOVE_LINE_CONTINUED ? Qt : Qnil;
10880}
10881
10841 10882
10842/*********************************************************************** 10883/***********************************************************************
10843 Messages 10884 Messages
@@ -34739,6 +34780,7 @@ be let-bound around code that needs to disable messages temporarily. */);
34739 defsubr (&Swindow_text_pixel_size); 34780 defsubr (&Swindow_text_pixel_size);
34740 defsubr (&Smove_point_visually); 34781 defsubr (&Smove_point_visually);
34741 defsubr (&Sbidi_find_overridden_directionality); 34782 defsubr (&Sbidi_find_overridden_directionality);
34783 defsubr (&Sdisplay__line_is_continued_p);
34742 34784
34743 DEFSYM (Qmenu_bar_update_hook, "menu-bar-update-hook"); 34785 DEFSYM (Qmenu_bar_update_hook, "menu-bar-update-hook");
34744 DEFSYM (Qoverriding_terminal_local_map, "overriding-terminal-local-map"); 34786 DEFSYM (Qoverriding_terminal_local_map, "overriding-terminal-local-map");