-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support Continous Scrolling in pdf-tools
#18
Comments
I've taken a stab at a to incorporate these in (defun my-image-next-line (n)
"Scroll image in current window upward by N lines.
Don't stop if the bottom edge of the image is reached."
(interactive "p")
;; Convert N to pixels.
(setq n (* n (frame-char-height)))
(cond ((= n 0) nil)
((< n 0)
(image-set-window-vscroll (max 0 (+ (window-vscroll nil t) n))))
(t
(image-set-window-vscroll (+ n (window-vscroll nil t))))))
(defun my-image-scroll-up (&optional n)
"Scroll image in current window upward by N lines.
Don't stop if the bottom edge of the image is reached.
If ARG is omitted or nil, scroll upward by a near full screen.
A near full screen is `next-screen-context-lines' less than a full screen.
Negative ARG means scroll downward.
If ARG is the atom `-', scroll downward by nearly full screen.
When calling from a program, supply as argument a number, nil, or `-'."
(interactive "P")
(cond ((null n)
(let* ((edges (window-inside-edges))
(win-height (- (nth 3 edges) (nth 1 edges))))
(my-image-next-line
(max 0 (- win-height next-screen-context-lines)))))
((eq n '-)
(let* ((edges (window-inside-edges))
(win-height (- (nth 3 edges) (nth 1 edges))))
(my-image-next-line
(min 0 (- next-screen-context-lines win-height)))))
(t (my-image-next-line (prefix-numeric-value n)))))
(defun my-pdf-view-scroll-up-or-next-page (&optional arg)
"Scroll page up ARG lines if possible, else go to the next page.
When `pdf-view-continuous' is non-nil, scrolling upward at the
bottom edge of the page moves to the next page. Otherwise, go to
next page only on typing SPC (ARG is nil)."
(interactive "P")
(if (or pdf-view-continuous (null arg))
(seq-let (_ top _ bot)
(window-edges nil nil nil
pdf-view-have-image-mode-pixel-vscroll)
(let* ((win-height (- bot top))
(image (image-get-display-property))
(img-height (ceiling (cdr (image-display-size image t))))
(cur-page (pdf-view-current-page)))
(if (< (+ win-height (window-vscroll nil pdf-view-have-image-mode-pixel-vscroll))
img-height)
(my-image-scroll-up arg)
(pdf-view-next-page)
(when (/= cur-page (pdf-view-current-page))
(image-bob)
(image-bol 1))
(image-set-window-hscroll (window-hscroll)))))
(my-image-scroll-up arg))) |
@odanoburu The example code you posted misses some |
@dalanicolai oops, it's fixed now! thanks for the heads-up :) (I actually had posted an extra function, and missed this one) |
I have just created a (not very, but still) simple sketch to obtain "real" continuous scrolling (i.e. in a single buffer). You can check it out here. It would be great if others would also like to hack on it. With |
I create a small package to indicate the remaining text: https://github.com/kimim/pdf-view-pagemark Demo: |
a very popular request for
pdf-tools
is the implementation of actual continuous scrolling, with multiple PDF pages per buffer (see politza/pdf-tools#27). but alas, this is hard to implement, although a hack is available. the formerpdf-tools
maintainer suggested that a compromise fix might be afixed-scroll-mode
, in which a call topdf-view-scroll-up-or-next-page
always performs the same amount of scrolling whenever it does not move to next page, so that we don't lose the location of the line we were reading when the scroll hits the bottom of the page. I'd be happy enough with this fix, and I think a lot of people would too (the person who first opened the issue made a good case: they put the unpredictability of the current line after scrolling as the problem, and suggested contiguous view as a mere possible fix, even if the most common and expected one).if I can get some pointers as to how to actually implement this I think I can manage a PR :)
The text was updated successfully, but these errors were encountered: