emacs-devel
[Top][All Lists]
Advanced

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

Scrolling over images/tall lines


From: Yuan Fu
Subject: Scrolling over images/tall lines
Date: Mon, 2 Nov 2020 16:48:59 -0500

Currently scrolling over images in Emacs is pretty bad: you jumps all over the 
place:

Attachment: bad-scrolling.mp4
Description: video/mp4


 A better behavior is to gradually scroll over an image as if it is made of 
multiple lines:

Attachment: good-scrolling.mp4
Description: video/mp4


Basically, like what you get by insert-sliced-image but with normal images.

However, I have some problem implementing this: to achieve this scrolling 
effect, I need to set window-start and window-vscroll at the same time. Because 
if you are scrolling in an image, you scroll not by changing window-start but 
by changing window-vscroll, and if you want to scroll up 3 lines in such a 
window:

+------window top--------------+
|==========line==========      |
|==========line==========      |
|(1)--------------------+      |
|(2)                    |      |
||       image          |      |
||                      |      |
||                      |      |
||                      |      |
|+----------------------+      |
|                              |


You want to see this: scroll up two display lines and one line’s height worth 
of pixels in the image, which means setting window start to (1) and vscroll to 
(* 1 (default-line-height)).

+------window top--------------+
|(2)                    |      |
||       image          |      |
||                      |      |
||                      |      |
||                      |      |
|+----------------------+      |
|                              |

Eli pointed out that setting window-start and vscroll in the same time is 
against the logic of the redisplay and advised me to set either window-start or 
window-vscroll, but not both in the same time. But 1) it doesn’t seem to be 
completely contradictory in the redisplay code for me and 2) there are some 
cases that I have to set window-start and window-vscroll in the same time, so I 
can’t go around this. Eli suggested moving the discussion to emacs-devel so 
here we are. Any suggestions? Maybe someone can assure me that setting both in 
the same time is fine or suggest a way to not set both in the same time but 
still get the desired behavior.


P.S. The case where I have to set window-start and window-vscroll in the same 
time is this: consider this window:

 (1)--------------------+
 |                      |
 |        image         |
 |                      |
 |                      |
 |                      |
 +----------------------+
+------window top--------------+
|==========line==========      |
|==========line==========      |
|==========line==========      |

If I now scroll up one line, I want to see this:

 (1)--------------------+
 |                      |
 |        image         |
 |                      |
 |                      |
+------window top--------------+
||                      |      |
|+----------------------+      |
|==========line==========      |
|==========line==========      |
|==========line==========      |

Which requires setting window-start to (1) and setting vscroll to image-height 
- default-line-height.

Code that works but sets both window-start and vscroll in the same time:

Attachment: iscroll.el
Description: Binary data


Yuan

reply via email to

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