Quantcast

scroll-down with pixel transition

classic Classic list List threaded Threaded
55 messages Options
123
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

scroll-down with pixel transition

Tak Kunihiro
I see scroll-up a line with pixel transition can be implemented
by `set-window-vscroll' as shown below.

(progn
  (vertical-motion 1)
  (dolist (vs (number-sequence 1 (1- (frame-char-height))))
    (set-window-vscroll nil vs t) (sit-for 0.001))
  (scroll-up 1))

Do you have ideas to scroll-down with pixel transition?


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> From: Tak Kunihiro <[hidden email]>
> Date: Mon, 10 Apr 2017 08:49:59 +0900
> Cc: Kunihiro Tak <[hidden email]>
>
> I see scroll-up a line with pixel transition can be implemented
> by `set-window-vscroll' as shown below.
>
> (progn
>   (vertical-motion 1)
>   (dolist (vs (number-sequence 1 (1- (frame-char-height))))
>     (set-window-vscroll nil vs t) (sit-for 0.001))
>   (scroll-up 1))
>
> Do you have ideas to scroll-down with pixel transition?

Scroll down one line, then use set-window-vscroll to scroll up by
pixels?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
>> I see scroll-up a line with pixel transition can be implemented
>> by `set-window-vscroll' as shown below.
>>
>> (progn
>>  (vertical-motion 1)
>>  (dolist (vs (number-sequence 1 (1- (frame-char-height))))
>>    (set-window-vscroll nil vs t) (sit-for 0.001))
>>  (scroll-up 1))
>>
>> Do you have ideas to scroll-down with pixel transition?
>
> Scroll down one line, then use set-window-vscroll to scroll up by
> pixels?

It works.
Is there a way to visually hide the overshoot on (scroll-down 1)?

(progn
  (scroll-down 1)
  (set-window-vscroll nil (1- (frame-char-height)) t) (sit-for 0.001)
  (dolist (vs (reverse (number-sequence 0 (- (frame-char-height) 2))))
    (set-window-vscroll nil vs t) (sit-for 0.001)))


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> From: Tak Kunihiro <[hidden email]>
> Date: Mon, 10 Apr 2017 16:06:37 +0900
> Cc: Kunihiro Tak <[hidden email]>,
>  [hidden email]
>
> > Scroll down one line, then use set-window-vscroll to scroll up by
> > pixels?
>
> It works.
> Is there a way to visually hide the overshoot on (scroll-down 1)?

I don't understand the question.  The display is only refreshed when
you call sit-for, so you have complete control of that already, and
AFAICS the code does what you told it to do.  Am I missing something?

(Btw, I think (sit-for 0) should also work, you don't need the 1 msec
delay.)

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
>> It works.
>> Is there a way to visually hide the overshoot on (scroll-down 1)?
>
> I don't understand the question.  The display is only refreshed when
> you call sit-for, so you have complete control of that already, and
> AFAICS the code does what you told it to do.  Am I missing something?

In Emacs around me (25.1 on Mac, 25.1 on Windows), the following lines
give me overshoot for each scroll-down.  Is not the case for you?

(dotimes (ii 10)
  (scroll-down 1)
  (set-window-vscroll nil (1- (frame-char-height)) t) (sit-for 0.05)
  (dolist (vs (reverse (number-sequence 0 (- (frame-char-height) 2))))
    (set-window-vscroll nil vs t) (sit-for 0.05)))

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> Date: Tue, 11 Apr 2017 07:24:17 +0900 (JST)
> Cc: [hidden email], [hidden email]
> From: Tak Kunihiro <[hidden email]>
>
> >> It works.
> >> Is there a way to visually hide the overshoot on (scroll-down 1)?
> >
> > I don't understand the question.  The display is only refreshed when
> > you call sit-for, so you have complete control of that already, and
> > AFAICS the code does what you told it to do.  Am I missing something?
>
> In Emacs around me (25.1 on Mac, 25.1 on Windows), the following lines
> give me overshoot for each scroll-down.  Is not the case for you?
>
> (dotimes (ii 10)
>   (scroll-down 1)
>   (set-window-vscroll nil (1- (frame-char-height)) t) (sit-for 0.05)
>   (dolist (vs (reverse (number-sequence 0 (- (frame-char-height) 2))))
>     (set-window-vscroll nil vs t) (sit-for 0.05)))

I'm still not sure what you mean by "overshoot", but if that's the
extra full-line scroll for each of the 10 iterations, then you see the
same in the snippet you shown that scrolls in the other direction, if
you look carefully.

The current display code doesn't like starting a window with a
partially visible line, so it zeroes out the vscroll if that produces
a fully-visible line at the window start.  E.g., try this:

  (progn
    (vertical-motion 1)
    (dolist (vs (number-sequence 1 (- (frame-char-height) 6)))
      (set-window-vscroll nil vs t) (sit-for 0.001)))

This ends up with the first window line partially visible, but as soon
as you move the cursor (triggering a redisplay cycle, just like
sit-for does), Emacs zeroes the window's vscroll to make that line
fully visible.  Changing that (probably as some special optional mode)
will require changes in the display engine on the C level and in
probably also in the line-moving commands in simple.el.  Patches
welcome.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
GOAL: Pixel-level vertical scrolling up and down

> I'm still not sure what you mean by "overshoot", but if that's the
> extra full-line scroll for each of the 10 iterations

Yes, that's what I meant!

> then you see the same in the snippet you shown that scrolls in the
> other direction, if you look carefully.

This I do not see (even with careful look).  At least, following lines
give me pixel-level and smooth scrolling.  Not for you?

(dotimes (ii 10)
  (vertical-motion 1)
  (dolist (vs (number-sequence 1 (1- (frame-char-height))))
    (set-window-vscroll nil vs t) (sit-for 0.02))
  (scroll-up 1) (sit-for 0.02))

> Changing that (probably as some special optional mode) will require
> changes in the display engine on the C level and in probably also in
> the line-moving commands in simple.el.  Patches welcome.

Let's say the lines above give smooth scrolling.  If so, to make Emacs
scroll both up and down with pixel-to-pixel resolution, requirement is
that `set-window-vscroll' accepts negative number.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> Date: Wed, 12 Apr 2017 21:13:35 +0900 (JST)
> Cc: [hidden email], [hidden email]
> From: Tak Kunihiro <[hidden email]>
>
> GOAL: Pixel-level vertical scrolling up and down
>
> > I'm still not sure what you mean by "overshoot", but if that's the
> > extra full-line scroll for each of the 10 iterations
>
> Yes, that's what I meant!
>
> > then you see the same in the snippet you shown that scrolls in the
> > other direction, if you look carefully.
>
> This I do not see (even with careful look).  At least, following lines
> give me pixel-level and smooth scrolling.  Not for you?

That's because the last iteration of the inner loop comes within 1
pixel of the next screen line, so you don't see the jump, which is
visible when you scroll in the other direction.  I've provided a
snippet to demonstrate the basic issue which causes that; if something
is unclear in my explanation, I can try clarifying.

> Let's say the lines above give smooth scrolling.  If so, to make Emacs
> scroll both up and down with pixel-to-pixel resolution, requirement is
> that `set-window-vscroll' accepts negative number.

Like I explained, it won't help, because the moment you do something
that potentially requires a redisplay, the vscroll will be zeroed, and
the text will scroll back to the state where the first screen line
visible in the window is fully visible.  So this cannot be the
solution to your problem, I think.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
>> Let's say the lines above give smooth scrolling.  If so, to make Emacs
>> scroll both up and down with pixel-to-pixel resolution, requirement is
>> that `set-window-vscroll' accepts negative number.
>
> Like I explained, it won't help, because the moment you do something
> that potentially requires a redisplay, the vscroll will be zeroed, and
> the text will scroll back to the state where the first screen line
> visible in the window is fully visible.  So this cannot be the
> solution to your problem, I think.

I think before pixel-level vertical scrolling up or down,
scrolling single line up or down `with pixel transition' should be
implemented.  It ends up (window-vscroll nil t) to be zero.
This may be good enough to give modern feel.

I assign the snippet to mwheel-scroll-up-function and it works
OK so far.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> From: Tak Kunihiro <[hidden email]>
> Date: Thu, 13 Apr 2017 16:02:13 +0900
> Cc: Kunihiro Tak <[hidden email]>,
>  [hidden email]
>
> I think before pixel-level vertical scrolling up or down,
> scrolling single line up or down `with pixel transition' should be
> implemented.  It ends up (window-vscroll nil t) to be zero.
> This may be good enough to give modern feel.
>
> I assign the snippet to mwheel-scroll-up-function and it works
> OK so far.

Sorry, I don't understand your proposal.  Can you show some code?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
>> I think before pixel-level vertical scrolling up or down,
>> scrolling single line up or down `with pixel transition' should be
>> implemented.  It ends up (window-vscroll nil t) to be zero.
>> This may be good enough to give modern feel.
>>
>> I assign the snippet to mwheel-scroll-up-function and it works
>> OK so far.
>
> Sorry, I don't understand your proposal.  Can you show some code?

Yes.  I attach a package in a middle.  With this Emacs scrolls a line
with pixel transition but ONLY upward.


;;; pixel-scroll.el --- Scroll with pixel-to-pixel transition

;; Copyright (C) 2017 Tak Kunihiro
;; Author: Tak Kunihiro <[hidden email]>
;; Maintainer: Tak Kunihiro <[hidden email]>
;; URL: http://dream.misasa.okayama-u.ac.jp
;; Package-Requires: ((emacs "24.5"))
;; Version: 1.0.0
;; Package-Version: 20170413.1707
;; Keywords: convenience, usability

;;; This file is NOT part of GNU Emacs

;;; License

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.

;;; Commentary:

;; To interactively toggle the mode on / off:
;;
;;   M-x pixel-scroll-mode
;;
;; To make the mode permanent, put this in your init file:
;;
;;   (require 'pixel-scroll)
;;   (pixel-scroll-mode 1)
;;
;; If you want to scroll by pixel-level also include:
;;   (setq pixel-resolusion-fine-p t)
;;
;; This package offers a global minor mode which makes Emacs scroll
;; vertically with feel of modern applications.  This minor mode
;; offers pixel-by-pixel scroll upward by mouse wheel using
;; `set-window-vscroll', `window-vscroll', and `scroll-up'.  The minor
;; mode overwrites parameters defined in `mwheel.el' to refer
;; `pixel-scroll-up' and `pixel-scroll-down' instead of `scroll-up'
;; and `scroll-down'.

;;; Principle of vertical scroll:

;; Scrolling text upward a line by pixels using `set-window-vscroll'
;; and by a line using `scroll-up' gives similar visual feedback when
;; vscroll location is @0.  Note vscroll location is vertical shift
;; obtained by `window-vscroll'.  Line height by pixel is obtained by
;; `frame-char-height' (to be exact, this is true for buffer with
;; mono-sized font).  Following two lines scroll text in similar
;; fashion, visually.
;;
;;   (scroll-up 1)
;;   (set-window-vscroll nil (frame-char-height) t)
;;
;; Scrolling text upward by a pixel and a line yields similar result
;; when vscroll location is at the last pixel.  Following two lines
;; scroll text in similar fashion, visually.
;;
;;   (scroll-up 1)
;;   (set-window-vscroll nil (1- (frame-char-height) t)) (scroll-up 1)
;;
;; When vscroll gets larger and as soon as point is beyond beginning
;; of a window, vscroll is set to zero.  To user, scope is changed
;; suddenly without point moved.  This package tries to scroll text
;; upward by a line with pixel-by-pixel transition by following
;; sequences.
;;
;;   (progn
;;     (vertical-motion 1)
;;     (dolist (vs (number-sequence 1 (1- (frame-char-height))))
;;       (set-window-vscroll nil vs t) (sit-for 0.001))
;;     (scroll-up 1))

;;; Change Log:

;; 20170319.1153
;;  - Replace `frame-char-height' by `pixel-line-height'.

;;; TODO:
;; - Scroll pixel-by-pixel to upward direction.

;;; Code:

(require 'mwheel)

(defgroup pixel-scroll nil
  "Scroll pixel-by-pixel in Emacs."
  :group 'mouse
  :prefix "pixel-")

(defcustom pixel-wait 0
  "Idle time on pixel scroll specified in second."
  :group 'pixel-scroll
  :type 'float)

(defcustom pixel-amount '(1 ((shift) . 5) ((control)))
  "Amount to scroll by when spinning the mouse wheel."
  :group 'pixel-scroll)

(defcustom pixel-resolusion-fine-p nil
  "Enhance scrolling resolution to pixel-to-pixel instead of
line-to-line."
  :group 'pixel-scroll
  :type 'boolean)

(define-minor-mode pixel-scroll-mode
  "A minor mode to scroll text pixel-by-pixel.  With a prefix argument ARG,
enable Pixel Scroll mode if ARG is positive, and disable it
otherwise.  If called from Lisp, enable Pixel Scroll mode if ARG
is omitted or nil."
  :init-value nil
  :group 'pixel-scroll
  :global t

  (if pixel-scroll-mode
      (progn (setq mwheel-scroll-up-function 'pixel-scroll-up)
             ;; (setq mwheel-scroll-down-function 'pixel-scroll-down)
             (setq mouse-wheel-scroll-amount pixel-amount)
             (setq mouse-wheel-progressive-speed pixel-resolusion-fine-p))
    (setq mwheel-scroll-up-function 'scroll-up)
    ;; (setq mwheel-scroll-down-function 'scroll-down)
    (dolist (var '(mouse-wheel-scroll-amount
                   mouse-wheel-progressive-speed))
      (custom-reevaluate-setting var))))

(defun pixel-scroll-up (&optional arg)
  "Scroll text of selected window up ARG lines.  This is
alternative of `scroll-up'.  Scope moves downward."
  (interactive)
  (or arg (setq arg 1))
  (dotimes (ii arg) ; move scope downward
    ;; (equal (window-end) (point-max)) ; when end-of-buffer is seen, use `scroll-up' to be conservative
    (if (<= (count-lines (window-start) (window-end)) 2)
        (scroll-up 1) ; when end of scroll is close, relay on more robust guy
      (when (or (equal (point-at-bol) (window-start)) ; prevent too late
                (and scroll-preserve-screen-position
                     (not (equal (point-at-bol) (window-end))))) ; prevent too fast
        (vertical-motion 1)) ; move point downward
      (pixel-scroll-pixel-up (if pixel-resolusion-fine-p
                                 1
                               (pixel-line-height)))))) ; move scope downward

(defun pixel-scroll-pixel-up (amt)
  "Scroll text of selected windows up AMT pixels.  Scope moves
downward."
  (while (>= (+ (window-vscroll nil t) amt)
            (pixel-line-height))
    (setq amt (- amt (pixel--flush-line-up)))) ; major scroll
  (pixel--sweep-pixel-up amt)) ; minor scroll

(defun pixel--flush-line-up ()
  "Flush text upward a line with pixel transition.  When `vscroll' is non-zero,
complete scrolling a line.  When `vscroll' is larger than height
of multiple lines, this flushes the lines.  At the end, `vscroll'
will be set to zero.  This assumes that lines to be caught up are
with the same height.  Scope moves downward.  This function
returns number of pixels that were scroled."
  (let* ((src (window-vscroll nil t))  ; EXAMPLE (initial)      @0   @8  @88
         (height (pixel-line-height))  ;                        25   25   23
         (line (1+ (/ src height)))    ; catch up + one line    Δ1   Δ1   Δ4
         (dst (* line height))         ; goal                  @25  @25  @92
         (delta (- dst src)))          ; pixels to be scrolled  25   17    4
    (pixel--sweep-pixel-up (1- delta)) ; sweep until one less  @24  @24  @91
    (scroll-up line) (sit-for pixel-wait) ; scroll 1 pixel      @0   @0   @0
    delta))

(defun pixel--sweep-pixel-up (n)
  "Sweep text upward to N pixels.  Scope moves downward."
  (when (> n 0)
    (let ((vs0 (window-vscroll nil t)))
      (dolist (vs (number-sequence (1+ vs0) (+ vs0 n)))
        (set-window-vscroll nil vs t) (sit-for pixel-wait)))))

(defun pixel-line-height (&optional pos)
  "Measure line height of POS in pixel.  When height of all lines
are equal, you don't need this function but `frame-char-height'.
See Info node `(elisp) Line Height'."
  (or pos (setq pos (window-start)))
  (save-excursion
    (goto-char pos)
    (line-pixel-height)))

(provide 'pixel-scroll)
;;; pixel-scroll.el ends here
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> Date: Thu, 13 Apr 2017 17:12:34 +0900 (JST)
> Cc: [hidden email], [hidden email]
> From: Tak Kunihiro <[hidden email]>
>
> > Sorry, I don't understand your proposal.  Can you show some code?
>
> Yes.  I attach a package in a middle.  With this Emacs scrolls a line
> with pixel transition but ONLY upward.

Thanks.  AFAICT, this exhibits the same problem I was talking about:
after pixel-level scrolling, if the first screen line of the window is
not completely visible, typing C-n or C-p will scroll the window to
make it fully visible, thus undoing the effect of the pixel-level
scroll.  Isn't that what you see?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Yuri Khan-2
In reply to this post by Eli Zaretskii
On Thu, Apr 13, 2017 at 2:21 PM, Eli Zaretskii <[hidden email]> wrote:

>> From: Tak Kunihiro <[hidden email]>
>> I think before pixel-level vertical scrolling up or down,
>> scrolling single line up or down `with pixel transition' should be
>> implemented.  It ends up (window-vscroll nil t) to be zero.
>> This may be good enough to give modern feel.
>>
>> I assign the snippet to mwheel-scroll-up-function and it works
>> OK so far.
>
> Sorry, I don't understand your proposal.  Can you show some code?

I think I do, and can translate.

To reproduce: Scroll a window up or down by one line, e.g. by
(scroll-up 1) or (scroll-down 1).

Current behavior: The display is updated once, with the window
scrolled a whole line.

Desired behavior: The display is updated n times, with the window
scrolled 1 pixel, then 2 pixels, …, then n-1 pixels, then n pixels,
where n is the height of a line in pixels.

Attempted implementation:

(defun my-scroll-down-line ()
  (interactive)
  (scroll-down 1) ;; Undesired redraw happens here
  (set-window-vscroll nil (1- (frame-char-height)) t)
  (sit-for 0.001)
  (dolist (vs (reverse (number-sequence 0 (- (frame-char-height) 2))))
    (set-window-vscroll nil vs t)
    (sit-for 0.001)))

Observed behavior: The display is updated n+1 times, first with the
window scrolled a whole line, then 1 pixel, 2 pixels, …, n-1 pixels,
finally a whole line again.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
In reply to this post by Eli Zaretskii
>> Yes.  I attach a package in a middle.  With this Emacs scrolls a line
>> with pixel transition but ONLY upward.
>
> Thanks.  AFAICT, this exhibits the same problem I was talking about:
> after pixel-level scrolling, if the first screen line of the window is
> not completely visible, typing C-n or C-p will scroll the window to
> make it fully visible, thus undoing the effect of the pixel-level
> scroll.  Isn't that what you see?

Not really, because it checks (line-pixel-height) before scrolling and
scrolls up until fully visible.  There is no chance to move point into
partially visible line.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
In reply to this post by Yuri Khan-2
> From: Yuri Khan <[hidden email]>
> Date: Thu, 13 Apr 2017 15:35:51 +0700
> Cc: Tak Kunihiro <[hidden email]>, Emacs developers <[hidden email]>
>
> Desired behavior: The display is updated n times, with the window
> scrolled 1 pixel, then 2 pixels, …, then n-1 pixels, then n pixels,
> where n is the height of a line in pixels.
>
> Attempted implementation:
>
> (defun my-scroll-down-line ()
>   (interactive)
>   (scroll-down 1) ;; Undesired redraw happens here
>   (set-window-vscroll nil (1- (frame-char-height)) t)
>   (sit-for 0.001)
>   (dolist (vs (reverse (number-sequence 0 (- (frame-char-height) 2))))
>     (set-window-vscroll nil vs t)
>     (sit-for 0.001)))
>
> Observed behavior: The display is updated n+1 times, first with the
> window scrolled a whole line, then 1 pixel, 2 pixels, …, n-1 pixels,
> finally a whole line again.

See my response to the code posted by Tak-san.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
In reply to this post by Tak Kunihiro
> From: Tak Kunihiro <[hidden email]>
> Date: Thu, 13 Apr 2017 17:40:48 +0900
> Cc: Kunihiro Tak <[hidden email]>,
>  [hidden email]
>
> >> Yes.  I attach a package in a middle.  With this Emacs scrolls a line
> >> with pixel transition but ONLY upward.
> >
> > Thanks.  AFAICT, this exhibits the same problem I was talking about:
> > after pixel-level scrolling, if the first screen line of the window is
> > not completely visible, typing C-n or C-p will scroll the window to
> > make it fully visible, thus undoing the effect of the pixel-level
> > scroll.  Isn't that what you see?
>
> Not really, because it checks (line-pixel-height) before scrolling and
> scrolls up until fully visible.  There is no chance to move point into
> partially visible line.

I think there's a misunderstanding.  Here's a recipe:

  emacs -Q
  M-x load-file RET pixel-scroll.el RET
  M-x pixel-scroll-mode RET
  M-x set-variable RET pixel-resolution-fine-p RET
  C-x C-f some-file RET
  C-u C-u C-n
  Scroll slowly with the mouse-wheel, one click at a time, until the
    first screen line is partially visible
  C-n

The last C-n causes a scroll which undoes the pixel-level scroll.  The
first screen line is now fully visible, and window's vscroll is now
zero.

Am I missing something?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
>>> Thanks.  AFAICT, this exhibits the same problem I was talking about:
>>> after pixel-level scrolling, if the first screen line of the window is
>>> not completely visible, typing C-n or C-p will scroll the window to
>>> make it fully visible, thus undoing the effect of the pixel-level
>>> scroll.  Isn't that what you see?
>>
>> Not really, because it checks (line-pixel-height) before scrolling and
>> scrolls up until fully visible.  There is no chance to move point into
>> partially visible line.
>
> I think there's a misunderstanding.  Here's a recipe:
>
>  emacs -Q
>  M-x load-file RET pixel-scroll.el RET
>  M-x pixel-scroll-mode RET
>  M-x set-variable RET pixel-resolution-fine-p RET
>  C-x C-f some-file RET
>  C-u C-u C-n
>  Scroll slowly with the mouse-wheel, one click at a time, until the
>    first screen line is partially visible
>  C-n
>
> The last C-n causes a scroll which undoes the pixel-level scroll.  The
> first screen line is now fully visible, and window's vscroll is now
> zero.
>
> Am I missing something?

You are correct.  Sorry for confusion.
I should have eliminated codes in regard to `pixel-resolution-fine-p’.

My intension was, to show an example of scrolling single line up with
(setq pixel-resolution-fine-p nil).

Thank you Yuri, for translation.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> From: Tak Kunihiro <[hidden email]>
> Date: Thu, 13 Apr 2017 18:22:37 +0900
> Cc: [hidden email], Kunihiro Tak <[hidden email]>,
> [hidden email]
>
> I should have eliminated codes in regard to `pixel-resolution-fine-p’.
>
> My intension was, to show an example of scrolling single line up with
> (setq pixel-resolution-fine-p nil).

For scrolling in the other direction, the following snippet should I
hope show how to avoid the unwanted extra scroll:

  (defun pscroll-down (arg)
    (interactive "p")
    (let ((pos
           (save-excursion
             (goto-char (window-start))
             (beginning-of-visual-line 0))))
      (set-window-start nil pos t)
      (set-window-vscroll nil arg t)))
  (define-key global-map [f9] 'pscroll-up)

With this, you can say "C-u 6 F9" and have the window text scrolled
down so that the first 6 pixels of the first screen line are not
shown.  Since this is just a demo, there are no protection against
hitting the beginning of buffer, against point being in the last
screen line, etc.; but adding that should be trivial.

The important part here is that you must call set-window-start as
shown, to force the display engine use that particular position as the
window-start point.  Otherwise, redisplay will reset the window's
vscroll.

HTH

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Tak Kunihiro
> For scrolling in the other direction, the following snippet should I
> hope show how to avoid the unwanted extra scroll:
>
>  (defun pscroll-down (arg)
>    (interactive "p")
>    (let ((pos
>   (save-excursion
>     (goto-char (window-start))
>     (beginning-of-visual-line 0))))
>      (set-window-start nil pos t)
>      (set-window-vscroll nil arg t)))
>  (define-key global-map [f9] 'pscroll-up)

This helps a lot.  Thank you!

Now (1) I can scroll single line up or down with `pixel transition'.
Also (2) I can scroll a pixel up or down.

For (2), concern remains.  After a pixel scroll by (2), typing C-n or
C-p scrolls the window to make it fully visible, and undos the effect
of the pixel-level scroll.  

CONCLUSION: Emacs almost gets modern scroll


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scroll-down with pixel transition

Eli Zaretskii
> From: Tak Kunihiro <[hidden email]>
> Date: Fri, 14 Apr 2017 11:40:28 +0900
> Cc: Kunihiro Tak <[hidden email]>,
>  [hidden email],
>  [hidden email]
>
> This helps a lot.  Thank you!

You are welcome.

I think we should have a minor mode that scrolls "smoothly" as in your
code.  Would you like to code that for inclusion in Emacs?

> Now (1) I can scroll single line up or down with `pixel transition'.
> Also (2) I can scroll a pixel up or down.
>
> For (2), concern remains.  After a pixel scroll by (2), typing C-n or
> C-p scrolls the window to make it fully visible, and undos the effect
> of the pixel-level scroll.  

This particular issue probably comes from line-move and its
subroutines, and could be fixed there, given some user option.  But my
point is more general: allowing pixel-level scrolling in Emacs
requires a thorough review of the related functionalities, to make
sure none of them zeroes out vscroll where users won't want that.

123
Loading...