From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dalanicolai Newsgroups: gmane.emacs.devel Subject: {PATCH] continuous scroll for doc-view (FOR REVIEW)) Date: Thu, 13 Jan 2022 11:53:45 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c91f3105d5748092" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16763"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 13 11:59:30 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7xpK-0004CS-Bn for ged-emacs-devel@m.gmane-mx.org; Thu, 13 Jan 2022 11:59:30 +0100 Original-Received: from localhost ([::1]:37430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7xpI-0001Qj-V1 for ged-emacs-devel@m.gmane-mx.org; Thu, 13 Jan 2022 05:59:28 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7xk1-0002KY-3P for emacs-devel@gnu.org; Thu, 13 Jan 2022 05:54:01 -0500 Original-Received: from [2607:f8b0:4864:20::934] (port=36724 helo=mail-ua1-x934.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7xjz-0003gf-59 for emacs-devel@gnu.org; Thu, 13 Jan 2022 05:54:00 -0500 Original-Received: by mail-ua1-x934.google.com with SMTP id r15so10267495uao.3 for ; Thu, 13 Jan 2022 02:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=/u+Cdr1i+1MYC2Av1ChVgHabpu5vQpLJWbQRHvhdYcg=; b=n+cchL41D8iJIUoHGvqAaD53AIhU/tinsMTBPZCaOjKPcuwDQoHFVEYZ+xSr0ShiiW /sb/Ys6MF/MqXMiS2SnCddQH188960Xa9dXYxUdjuVYNW2zkaEa2de6N07XA0mXmoJc7 1/CjuA865LxIBWmj+na2Uyuqn/pQMj9DUP8yQxLOiNOdogFGbbEYljQ/DEXHq678wK9U 8E8mT6FAaSZRti4xUYjPUJiSj7OBZ2znKVW0d9MlcJeghDZ3+Xs1ZiLRM7IpUK9mc2sb EbTqXuq4ycCDimygnTxtPiyGpxaNmy4KFPuhKgpBFBIGp7cRI0bVDgLENJQdXTLXVpPt RM0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/u+Cdr1i+1MYC2Av1ChVgHabpu5vQpLJWbQRHvhdYcg=; b=OPsKI/5ZbuR2+PQ3IkxzoU0qeTb6+gotqyKJUSxcrHBEZr2n939u9HEKv+ttaKXHan GhpgsrGzitANVfLHhn2cPNV7m+hXgeW+XPo2pugnFHJP8cA5ZeJu+kx8WicQ7bsF2iMs +XUA13/XR9TWGZB+lrSpPuuyGUCbe3uXGKFuQ0faFJgJzvgZTGyvJEJR4Y8/bPDeElsr EfIrEre9yGI96LBO+qu2lWAd+s/nSgHQ1euLNFOxtAqmS/uROSD03t3Y/JHUrthbWN4r h9k3l83Sl6f7CHNg2Cry0eYH5XlUWvjysVLwqyclvROlruWj6Fv+eqY8KJr/Nv3/X++R f3Pw== X-Gm-Message-State: AOAM5314yYvyu8P2r1P7feMDDMQ8jZzpR6JtabZicLHtjttrxDyE8DM+ 8JkfAFP1m7P0G7X7oaGeVjDeoyMO9tniyhCt6xpb7DDvsUQ= X-Google-Smtp-Source: ABdhPJxaqvQNqN3up7M39bSYb/td0k+Rmrdroh8Hbt0xWmOYB6qSvZYicRauouT4/iCVdDWi8/ur7YkhCUx5o23p4HE= X-Received: by 2002:ab0:7804:: with SMTP id x4mr1904493uaq.74.1642071237138; Thu, 13 Jan 2022 02:53:57 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::934 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::934; envelope-from=dalanicolai@gmail.com; helo=mail-ua1-x934.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284700 Archived-At: --000000000000c91f3105d5748092 Content-Type: text/plain; charset="UTF-8" I am not sure how to best handle this, but I figured I'll better keep you involved (get feedback better sooner than later). So I have got the code for a first 'working' example for the continuous scroll. Let me comment a little first: So I've started from the Proof of Concept here , on which I commented on more already in the thread here (original thread is here ). A very short, but 'noteworthy' digression ... I'd really like to mention that I get no hits when searching for that thread (actually searching for 'the original thread') when searching on `multi image PDF` in the Emacs devel archive. (This time) it is not due to too many results. Would be great if you could inform me why that does not work. Back to the main subject... So I will attach two files here, the first is an 'adapted' bookroll.el file, and the second is a a modified doc-view file that implements the first 'rudimentary' continuous scroll for PDF documents(despite the subject title of this message, I am simply attaching the file, as you can then more simply load and try it, while I guess you must be capable of diffing it with the latest doc-view.el file yourself ;). For, now it only works on PDF documents (I hope all of them), because I have to find good 'splitting points' for the various overlays (this was the original approach that I'd used in pdf-view, I prefer to keep the document it's contents in the buffer and drawing the overlays over it). For other types of documents I've tried to 'determine' split points using `forward-line`, but that did not give satisfactory results. I am not sure if the bookroll-mode should be a separate package (like image-mode), or that it could just get merged into doc-view. But it is as it is for the development process. So now some comments on the files/approach: To understand the approach of bookmark.el, it is probably most useful to look at the Proof of Concept file to which I have linked already above. It simply draws a triplet of images (pages) for each page (and a doublet for the first and last pages), and then it uses a 'currently-displayed-images' list, and refreshes pages when necessary by comparing with that list. The current page is the page that takes more than half of the window height. In the single page doc-view there is a single overlay, that informs via its properties many doc-view functions about which step to take next (it controls the doc-view 'process'). In the bookroll doc-view version, This overlay is kept as a 'control' overlay, which is not used for containing images. The overlays for 'holding' the images are in the `overlay-list`. (Although this solution for the control overlay looks simple, it took me quite some investigation and error and trial to come up with it, which is also to say that I think it is a nice solution). For now, the scrolling is too continuous (i.e. now separation indicator between the pages), but I am planning to embed the files in svg images (as I have done in djvu3.el ), so that it will be easy to draw a line between the pages So, anyone who is interested can have a look at the code, and of course any feedback and suggestions are welcome I am no experienced programmer, and I am also fairly new to Emacs (actually Spacemacs which I think is (also) a really great project). I am only able to do this because of your great (documentation) work :) If you find things that looks like 'bad developing process practice', then I am very happy with good/better suggestions. As I have to take care of 'fixing' the 'resizing/scaling/zoom' functionality now, any comments ideas on that part would be welcome in particular... Quite obviously, to test it, load the bookmark.el file, then load the doc-view.el file, open some PDF document and start scrolling using `j`/`k`. --000000000000c91f3105d5748092 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I am not sure how to best handle this, but I figured = I'll better keep you
involved (get feedback better sooner tha= n later).

So I have got the code for a first '= working' example for the continuous scroll.

Le= t me comment a little first:
So I've started from the Proof o= f Concept here, = on which I commented
on more already in the thread here= (original thread is here).


=
A very short, but 'noteworthy' digression ...
=
I'd really like to mention that I get no hits when searching for that thread (actually search= ing
for 'the original thread') when searching on `multi = image PDF` in the Emacs devel archive.
(This time) it is not due = to too many results. Would be great if you could inform me why that
does not work.


Back to the main= subject...

So I will attach two files here, the f= irst is an 'adapted' bookroll.el file, and the second is a
a modified doc-view file that implements the first 'rudimentary' = continuous scroll for PDF
documents(despite the subject title of = this message, I am simply attaching the file,
as you can then more simp= ly load and try it, while I guess you must be capable of diffing it with
the latest doc-view.el file yourself ;).
For, now it= only works on PDF documents (I hope all of them), because I
have to find good 'splitting points' for the various overlays (th= is was the original approach
that I'd used in pdf-view, I pre= fer to keep the document it's contents in the buffer and drawing
<= div>the overlays over it). For other types of documents I've tried to &= #39;determine' split points using `forward-line`, but that did not give= satisfactory results.

I am not sure if the bookro= ll-mode should be a separate package (like image-mode),
or that i= t could just get merged into doc-view. But it is as it is for the developme= nt process.

So now some comments on the files/appr= oach:

To understand the approach of bookmark.el, i= t is probably most useful to look at the Proof
of Concept file to= which I have linked already above. It simply draws a triplet of images (pa= ges)
for each page (and a doublet for the first and last pages), = and then it uses a 'currently-displayed-images' list, and refreshes= pages when necessary by comparing with that list. The current page is the = page that takes more than half of the window height.

In the single page doc-view there is a single overlay, that informs via = its properties many doc-view functions about which step to take next (it co= ntrols the doc-view 'process'). In the bookroll
doc-view = version, This overlay is kept as a 'control' overlay, which is not = used for containing images. The overlays for 'holding' the images a= re in the `overlay-list`. (Although this solution
for the control= overlay looks simple, it took me quite some investigation and error and tr= ial to
come up with it, which is also to say that I think it is a= nice solution).

For now, the scrolling is too con= tinuous (i.e. now separation indicator between the pages), but I
= am planning to embed the files in svg images (as I have done in djvu3.el), so that it will be eas= y
to draw a line between the pages

= So, anyone who is interested can have a look at the code, and of course any= feedback and suggestions are welcome I am no experienced programmer, and I= am also fairly new to Emacs
(actually Spacemacs which I think is= (also) a really great project). I am only able to do this because of your = great (documentation) work :) If you find things that looks like 'bad d= eveloping
process practice', then I am very happy with good/= better suggestions.

As I have to take care of = 'fixing' the 'resizing/scaling/zoom' functionality now, any= comments
ideas on that part would be welcome in particular...

Quite obviously, to test it, load the bookmark.el fi= le, then load the doc-view.el file, open some PDF document and start scroll= ing using `j`/`k`.
--000000000000c91f3105d5748092--