unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Set-window-vscroll sometimes doesn't work
Date: Thu, 22 Oct 2020 12:50:23 -0400	[thread overview]
Message-ID: <AF7C9321-8D13-4307-9081-024C3795B53E@gmail.com> (raw)
In-Reply-To: <83imb2kzu0.fsf@gnu.org>

> What do you mean by "smooth scrolling" here?  If I invoke C-2 C-n" on
> a large image, the image gets scrolled by the amount of pixels that is
> equivalent to 2 screen lines.  Isn't that what you see?

With emacs -Q? On my machine emacs -Q doesn’t to that. Instead of moving two line’s height, it just jumps to the next logical line.

> When vscroll is so large that the window-start point is entirely not
> visible, you should move window-start so it becomes visible.  But that
> shouldn't be a problem, because it means you've scrolled the entire
> image off-screen.

> On Oct 22, 2020, at 12:08 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Thu, 22 Oct 2020 00:16:04 -0400
>> Cc: help-gnu-emacs@gnu.org
>> 
>> Ok, I looked at redisplay_window, and it zeros out vscroll if force_start is true, that explains my initial
>> question. After reading the function, it seems that setting window-start is the primary way to scroll and to
>> produce the glyph matrix to display. IIUC this is how window-start and vscroll works together in window
>> redisplay: we have a window-start -> try window -> start_display on window-start -> it_initialize on
>> window-start -> it->current-y adjusted according to vscroll -> back to try window -> while (it.current_y <
>> it.last_visible_y): produce glyph rows. This doesn’t seem to be too contradictory, and scrolling by setting
>> window-start and add sub-line adjustment with vscroll seems to be complaint with the redisplay logic. What
>> am I missing?
> 
> You are missing the use cases where the display element that is taller
> than the normal text is not an image, but something else.  For
> example, text displayed with a very large font.  In this other use
> case, starting display with a non-zero vscroll when the Lisp program
> forced window-start will produce text part of which cannot be read,
> because too much of the characters is off-screen.
> 
> This is why setting window-start zeroes out vscroll: Emacs wants to
> make sure that in this case the entire screen line that starts at
> window-start will be fully visible.
> 

That’s a fair point. But what about scrolling down into an image? I’ll need to set window-start on the image then set vscroll to image height - line height so it only displays the bottom strip. That’s what line-move does, too:

(prog1 (line-move-visual arg noerror)
	    ;; If we moved into a tall line, set vscroll to make
	    ;; scrolling through tall images more smooth.
	    (let ((lh (line-pixel-height))
		  (edges (window-inside-pixel-edges))
		  (dlh (default-line-height))
		  winh)
	      (setq winh (- (nth 3 edges) (nth 1 edges) 1))
	      (if (and (< arg 0)
		       (< (point) (window-start))
		       (> lh winh))
		  (set-window-vscroll
		   nil
		   (- lh dlh) t))))

Yuan

  reply	other threads:[~2020-10-22 16:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-18  0:35 Set-window-vscroll sometimes doesn't work Yuan Fu
2020-10-18 14:34 ` Eli Zaretskii
2020-10-18 17:24   ` Yuan Fu
2020-10-18 17:31     ` Eli Zaretskii
2020-10-18 17:51       ` Yuan Fu
2020-10-18 17:55         ` Eli Zaretskii
2020-10-18 18:02           ` Yuan Fu
2020-10-18 19:12           ` Yuan Fu
2020-10-18 19:19             ` Eli Zaretskii
2020-10-18 20:06               ` Yuan Fu
2020-10-19  2:23                 ` Eli Zaretskii
     [not found]                   ` <B1D235FE-49B8-4F0A-9C02-78B7E3244C47@gmail.com>
2020-10-19  6:00                     ` Yuan Fu
2020-10-19 16:24                     ` Eli Zaretskii
2020-10-19 16:56                       ` Yuan Fu
2020-10-19 17:23                         ` Eli Zaretskii
2020-10-19 20:39                           ` Yuan Fu
2020-10-20 16:04                             ` Eli Zaretskii
2020-10-20 18:00                               ` Yuan Fu
2020-10-20 18:19                               ` Yuan Fu
2020-10-21 16:25                                 ` Eli Zaretskii
2020-10-21 19:05                                   ` Yuan Fu
2020-10-22  4:16                                     ` Yuan Fu
2020-10-22 16:08                                       ` Eli Zaretskii
2020-10-22 16:50                                         ` Yuan Fu [this message]
2020-10-22 17:09                                           ` Eli Zaretskii
2020-10-22 19:33                                             ` Yuan Fu
2020-10-23  6:05                                               ` Eli Zaretskii
2020-10-23 16:48                                                 ` Yuan Fu
2020-10-23 18:11                                                   ` Eli Zaretskii
2020-10-23 20:30                                                     ` Yuan Fu
2020-10-24  7:17                                                       ` Eli Zaretskii
2020-10-26  8:38                                                         ` Jens C. Jensen
2020-10-26 15:18                                                           ` Eli Zaretskii
2020-10-27 18:10                                                         ` Yuan Fu
2020-10-27 18:32                                                           ` Eli Zaretskii
2020-10-22 16:05                                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AF7C9321-8D13-4307-9081-024C3795B53E@gmail.com \
    --to=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).