summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Politz <politza@hochschule-trier.de>2014-11-24 16:51:17 +0100
committerAndreas Politz <politza@hochschule-trier.de>2014-11-24 16:51:17 +0100
commitcb71e424766faf7de8a2ad6bb20b95fe6efb66ae (patch)
treeff8417a699264e08aa9b55a1554ef94d16949807
parent9e50630ecc7212bc354808878400818d33f25cd6 (diff)
*** empty log message ***
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac2
-rw-r--r--lisp/pdf-annot.el154
-rw-r--r--lisp/pdf-cache.el53
-rw-r--r--lisp/pdf-info.el18
-rw-r--r--lisp/pdf-isearch.el6
-rw-r--r--lisp/pdf-links.el7
-rw-r--r--lisp/pdf-util.el14
-rw-r--r--lisp/pdf-view.el44
-rw-r--r--src/epdfinfo.c10
10 files changed, 162 insertions, 149 deletions
diff --git a/Makefile.am b/Makefile.am
index aaa96ed..5281119 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,9 +9,10 @@ LISP_FILES = $(top_srcdir)/lisp/pdf-history.el \
$(top_srcdir)/lisp/pdf-outline.el \
$(top_srcdir)/lisp/pdf-tools.el \
$(top_srcdir)/lisp/pdf-util.el \
- $(top_srcdir)/lisp/pdf-render.el \
$(top_srcdir)/lisp/pdf-annot.el \
$(top_srcdir)/lisp/pdf-sync.el \
+ $(top_srcdir)/lisp/pdf-view.el \
+ $(top_srcdir)/lisp/pdf-cache.el \
$(top_srcdir)/lisp/tablist.el \
$(top_srcdir)/lisp/tablist-filter.el
diff --git a/configure.ac b/configure.ac
index 97d4818..02de4df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.67])
-AC_INIT([pdf-tools], [0.30], [politza@fh-trier.de])
+AC_INIT([pdf-tools], [0.40], [politza@fh-trier.de])
AM_INIT_AUTOMAKE([-Wall -Wno-override foreign])
AC_CONFIG_SRCDIR([src/epdfinfo.h])
AC_CONFIG_HEADERS([src/config.h])
diff --git a/lisp/pdf-annot.el b/lisp/pdf-annot.el
index 4d50d3b..baf85ef 100644
--- a/lisp/pdf-annot.el
+++ b/lisp/pdf-annot.el
@@ -22,6 +22,16 @@
;;
+(require 'pdf-view)
+(require 'pdf-info)
+(require 'pdf-cache)
+(require 'pdf-misc)
+(require 'facemenu) ;; list-colors-duplicates
+(require 'faces) ;; color-values
+(require 'org) ;; org-create-formula-image
+(require 'tablist)
+(require 'cl-lib)
+
;; * ================================================================== *
@@ -155,7 +165,7 @@ Any other argument signals an error."
;; * Variables and Macros
;; * ================================================================== *
-(defconst pdf-annot-rendered-annotation-size '(24 . 24)
+(defconst pdf-annot-text-annotation-size '(24 . 24)
"The Size of text and file annotations in PDF points.
These values are hard-coded in poppler. And while the size of
@@ -193,6 +203,21 @@ having a list of annotations as value.")
(defvar-local pdf-annot--attachment-file-alist nil
"Alist mapping attachment ids to unique relative filenames.")
+(defmacro pdf-annot-with-atomic-modifications (&rest body)
+ "Execute BODY joining multiple modifications.
+
+The effect is, that `pdf-annot-modified-functions' will be called
+only once at the end of BODY.
+
+BODY should not modify annotations in a different then the
+current buffer, because that won't run the hooks properly."
+ (declare (indent 0) (debug t))
+ `(unwind-protect
+ (save-current-buffer
+ (let ((pdf-annot-inhibit-modification-hooks t))
+ (progn ,@body)))
+ (pdf-annot-run-modified-hooks)))
+
;; * ================================================================== *
;; * Minor mode
@@ -252,20 +277,20 @@ Setting this after the package was loaded has no effect."
`(menu-item "Delete annotation"
,(lambda ()
(interactive)
- (when (pdf-annot-y-or-n-p 'delete)
- (pdf-annot-set-deleted-p a t)
+ (when (y-or-n-p "Delete annotation ? ")
+ (pdf-annot-delete a)
(message "Annotation deleted")))
:help
,(substitute-command-keys
"Delete this annotation"))))
- (cl-case (pdf-annot-type a)
+ (cl-case (pdf-annot-get a 'type)
(file
(define-key menu [open-attachment]
`(menu-item "Open attachment"
,(lambda ()
(interactive)
- (pdf-annot-attach-find-file-other-window a))
+ (pdf-annot-pop-to-attachment a))
:help "Find this attachment in another window")))
(t
(define-key menu [goto-annotation]
@@ -339,7 +364,8 @@ Returns the modified annotation."
(declare (indent 2))
(unless (equal value (pdf-annot-get a property))
(unless (pdf-annot-property-modifiable-p a property)
- (error "Property `%s' is read-only for this annotation"))
+ (error "Property `%s' is read-only for this annotation"
+ property))
(with-current-buffer (pdf-annot-get-buffer a)
(setq a (pdf-annot-create
(pdf-info-editannot
@@ -350,38 +376,6 @@ Returns the modified annotation."
(pdf-view-redisplay-pages (pdf-annot-get a 'page))))
a)
-(defun pdf-annot-equal (a1 a2)
- "Return non-nil, if annotations A1 and A2 are equal.
-
-Two annotations are equal, if they belong to the same buffer and
-have identical id properties."
- (and (eq (pdf-annot-get-buffer a1)
- (pdf-annot-get-buffer a2))
- (eq (pdf-annot-get a1 'id)
- (pdf-annot-get a2 'id))))
-
-(defun pdf-annot-get-buffer (a)
- "Return annotation A's buffer."
- (pdf-annot-get a 'pdf-annot-buffer))
-
-(defun pdf-annot-get-id (a)
- "Return id property of A."
- (pdf-annot-get a 'id))
-
-(defun pdf-annot-delete (a)
- "Delete annotation A.
-
-Sets A's buffer's modified flag and runs the hook
-`pdf-annot-modified-functions'.
-
-This function alwasy returns nil."
- (with-current-buffer (pdf-annot-get-buffer a)
- (pdf-info-delannot
- (pdf-annot-get a 'id))
- (set-buffer-modified-p t)
- (pdf-annot-run-modified-hooks :delete a))
- nil)
-
(defun pdf-annot-run-modified-hooks (&optional operation &rest annotations)
"Run `pdf-annot-modified-functions' using OPERATION on ANNOTATIONS.
@@ -427,20 +421,37 @@ the variable is nil and this function is called again."
'pdf-annot-modified-functions closure)
(setq pdf-annot-delayed-modified-annotations nil))))))
-(defmacro pdf-annot-with-atomic-modifications (&rest body)
- "Execute BODY joining multiple modifications.
+(defun pdf-annot-equal (a1 a2)
+ "Return non-nil, if annotations A1 and A2 are equal.
-The effect is, that `pdf-annot-modified-functions' will be called
-only once at the end of BODY.
+Two annotations are equal, if they belong to the same buffer and
+have identical id properties."
+ (and (eq (pdf-annot-get-buffer a1)
+ (pdf-annot-get-buffer a2))
+ (eq (pdf-annot-get a1 'id)
+ (pdf-annot-get a2 'id))))
+
+(defun pdf-annot-get-buffer (a)
+ "Return annotation A's buffer."
+ (pdf-annot-get a 'pdf-annot-buffer))
-BODY should not modify annotations in a different then the
-current buffer, because that won't run the hooks properly."
- (declare (indent 0) (debug t))
- (unwind-protect
- (save-current-buffer
- (let ((pdf-annot-inhibit-modification-hooks t))
- (progn ,@body)))
- (pdf-annot-run-pages-modified-hooks)))
+(defun pdf-annot-get-id (a)
+ "Return id property of A."
+ (pdf-annot-get a 'id))
+
+(defun pdf-annot-delete (a)
+ "Delete annotation A.
+
+Sets A's buffer's modified flag and runs the hook
+`pdf-annot-modified-functions'.
+
+This function alwasy returns nil."
+ (with-current-buffer (pdf-annot-get-buffer a)
+ (pdf-info-delannot
+ (pdf-annot-get a 'id))
+ (set-buffer-modified-p t)
+ (pdf-annot-run-modified-hooks :delete a))
+ nil)
(defun pdf-annot-text-annotation-p (a)
(eq 'text (pdf-annot-get a 'type)))
@@ -664,7 +675,7 @@ See `pdf-annot-image-position' for IMAGE-SIZE."
(unless image-size
(pdf-util-assert-pdf-window)
(setq image-size (pdf-view-image-size)))
- (let ((edges (pdf-util-scale-edges
+ (let ((edges (pdf-util-scale
(pdf-annot-get a 'edges) image-size)))
(pdf-util-with-edges (edges)
(cons edges-width edges-height))))
@@ -756,7 +767,6 @@ i.e. a non mouse-movement event is read."
resize-diagonally)))
(vresize (memq operation '(resize-vertically
resize-diagonally)))
- (button (event-basic-type event))
(window (selected-window))
make-pointer-invisible)
(when (pdf-util-track-mouse-dragging (ev 0.1)
@@ -817,8 +827,8 @@ i.e. a non mouse-movement event is read."
;; Activating
(local-set-key
(vector id 'mouse-1)
- (lambda (ev)
- (interactive "@e")
+ (lambda ()
+ (interactive)
(pdf-annot-activate-annotation annotation)))
;; Move/Resize
(when operation
@@ -850,9 +860,7 @@ other annotations."
(save-selected-window
(when window (select-window window))
(pdf-util-assert-pdf-window)
- (let ((color "black")
- (alpha 0.5)
- (page (pdf-annot-get a 'page))
+ (let ((page (pdf-annot-get a 'page))
(size (pdf-view-image-size)))
(unless (= page (pdf-view-current-page))
(pdf-view-goto-page page))
@@ -971,7 +979,7 @@ Return the new annotation."
(cdr (posn-object-x-y posn))
(if (equal icon "") nil icon))))
(pdf-util-assert-pdf-window)
- (let ((isize (pdf-view-image-size window)))
+ (let ((isize (pdf-view-image-size)))
(unless (and (>= x 0)
(< x (car isize)))
(signal 'args-out-of-range (list x)))
@@ -979,7 +987,7 @@ Return the new annotation."
(< y (cdr isize)))
(signal 'args-out-of-range (list y)))
(let ((size (pdf-util-scale-points-to-pixel
- pdf-annot-default-text-annotation-size 'round)))
+ pdf-annot-text-annotation-size 'round)))
(setcar size (min (car size) (car isize)))
(setcdr size (min (cdr size) (cdr isize)))
(cl-decf x (max 0 (- (+ x (car size)) (car isize))))
@@ -1050,7 +1058,7 @@ Offer `pdf-annot-preferred-annotation-colors' as default values."
(current-completing-read-function completing-read-function)
(completing-read-function
(lambda (prompt collection &optional predicate require-match
- initial-input hist def inherit-input-method)
+ initial-input hist _def inherit-input-method)
(funcall current-completing-read-function
prompt collection predicate require-match
initial-input hist
@@ -1083,7 +1091,7 @@ occurence in any list in ALISTS."
(color
(propertize (or value "")
'face (and value
- `(:background ,color))))
+ `(:background ,value))))
((created modified)
(let ((date value))
(if (null date)
@@ -1202,23 +1210,6 @@ by a header."
(file-exists-p tempfile))
(delete-file tempfile)))))
-
-
-
-
-;; * ================================================================== *
-;; * O L D C O D E
-;; * ================================================================== *
-
-(require 'pdf-info)
-(require 'pdf-render)
-(require 'pdf-misc)
-(require 'facemenu) ;;for list-colors-duplicates
-(require 'faces) ;;for color-values
-(require 'org) ;;org-with-gensyms, org-create-formula-image
-(require 'tablist)
-(require 'cl-lib)
-
;; * ================================================================== *
;; * Editing annotation contents
@@ -1370,11 +1361,11 @@ A2."
(p2 (pdf-annot-get a2 'page)))
(or (< p1 p2)
(and (= p1 p2)
- (let ((e1 (pdf-util-scale-edges
+ (let ((e1 (pdf-util-scale
(or (car (pdf-annot-get a1 'markup-edges))
(pdf-annot-get a1 'edges))
'(1000 . 1000)))
- (e2 (pdf-util-scale-edges
+ (e2 (pdf-util-scale
(or (car (pdf-annot-get a2 'markup-edges))
(pdf-annot-get a2 'edges))
'(1000 . 1000))))
@@ -1518,7 +1509,8 @@ A2."
(define-minor-mode pdf-annot-list-follow-minor-mode
"" nil nil nil
- (pdf-util-assert-derived-mode 'pdf-annot-list-mode)
+ (unless (derived-mode-p 'pdf-annot-list-mode)
+ (error "No in pdf-annot-list-mode."))
(cond
(pdf-annot-list-follow-minor-mode
(add-hook 'tablist-selection-changed-functions
diff --git a/lisp/pdf-cache.el b/lisp/pdf-cache.el
index 075ea3f..0a17b08 100644
--- a/lisp/pdf-cache.el
+++ b/lisp/pdf-cache.el
@@ -25,8 +25,8 @@
(require 'pdf-info)
(require 'pdf-util)
-(require 'pdf-annot)
-(require 'pdf-view)
+
+(defvar pdf-annot-modified-functions)
;; * ================================================================== *
@@ -129,7 +129,10 @@ Make shure, not to modify it's return value.\n" fn)
(dolist (page (cons t pages))
(remhash page pdf-cache--cache)))
+(declare-function pdf-annot-get "pdf-annot")
+
(defun pdf-cache--clear-annotations-pages (fn)
+ "Hook function for `pdf-annot-modified-functions'."
(pdf-cache-clear-pages
(delq nil (mapcar (lambda (a)
(pdf-annot-get a 'page))
@@ -152,7 +155,7 @@ Make shure, not to modify it's return value.\n" fn)
(defvar-local pdf-cache--image-cache nil)
(defmacro pdf-cache--make-image (page width data hash)
- `(list page width data hash))
+ `(list ,page ,width ,data ,hash))
(defmacro pdf-cache--image/page (img) `(nth 0 ,img))
(defmacro pdf-cache--image/width (img) `(nth 1 ,img))
(defmacro pdf-cache--image/data (img) `(nth 2 ,img))
@@ -329,6 +332,22 @@ See also `pdf-info-renderpage-text-regions' and
(defvar-local pdf-cache--prefetch-timer nil
"Timer used when prefetching images.")
+(define-minor-mode pdf-cache-prefetch-minor-mode
+ "Try to load images which will probably be needed in a while."
+ nil nil t
+ (pdf-util-assert-pdf-buffer)
+ (pdf-cache--prefetch-cancel)
+ (add-hook 'after-change-major-mode-hook
+ 'pdf-cache--prefetch-cancel nil t)
+ (cond
+ (pdf-cache-prefetch-minor-mode
+ (add-hook 'pre-command-hook 'pdf-cache--prefetch-stop nil t)
+ (setq pdf-cache--prefetch-timer
+ (run-with-idle-timer (or pdf-cache-prefetch-delay 1)
+ t 'pdf-cache--prefetch-start (current-buffer))))
+ (t
+ (remove-hook 'pre-command-hook 'pdf-cache--prefetch-stop t))))
+
(defun pdf-cache-prefetch-pages-function-default ()
(let ((page (pdf-view-current-page)))
(cl-remove-duplicates
@@ -340,7 +359,7 @@ See also `pdf-info-renderpage-text-regions' and
;; +1, -1, +2, -2, ...
(let ((sign 1)
(incr 1))
- (mapcar (lambda (i)
+ (mapcar (lambda (_)
(setq page (+ page (* sign incr))
sign (- sign)
incr (1+ incr))
@@ -368,7 +387,8 @@ See also `pdf-info-renderpage-text-regions' and
(* 2 image-width))))
(setq page (pop pdf-cache--prefetch-pages)))
(when (null page)
- (pdf-tools-debug "Prefetching done."))
+ ;; (pdf-tools-debug "Prefetching done.")
+ )
(when page
(let ((pdf-info-asynchronous
(lambda (status data)
@@ -379,7 +399,7 @@ See also `pdf-info-renderpage-text-regions' and
(pdf-cache-put-image
page image-width data)
(image-size (pdf-view-create-page page))
- (pdf-tools-debug "Prefetched Page %s." page)
+ ;; (pdf-tools-debug "Prefetched Page %s." page)
;; Avoid max-lisp-eval-depth
(run-with-timer
0.001 nil 'pdf-cache--prefetch-pages window image-width))))))
@@ -411,26 +431,5 @@ See also `pdf-info-renderpage-text-regions' and
(cancel-timer pdf-cache--prefetch-timer))
(setq pdf-cache--prefetch-timer nil))
-(define-minor-mode pdf-cache-prefetch-minor-mode
- "Try to load images which will probably be needed in a while."
- nil nil t
-
- (pdf-util-assert-pdf-buffer)
- (pdf-cache--prefetch-cancel)
- (add-hook 'after-change-major-mode-hook
- 'pdf-cache--prefetch-cancel nil t)
- (cond
- (pdf-cache-prefetch-minor-mode
- (add-hook 'pre-command-hook 'pdf-cache--prefetch-stop nil t)
- (setq pdf-cache--prefetch-timer
- (run-with-idle-timer (or pdf-cache-prefetch-delay 1)
- t 'pdf-cache--prefetch-start (current-buffer))))
- (t
- (remove-hook 'pre-command-hook 'pdf-cache--prefetch-stop t))))
-
-(provide 'pdf-view)
-;;; pdf-view.el ends here
-
(provide 'pdf-cache)
-
;;; pdf-cache.el ends here
diff --git a/lisp/pdf-info.el b/lisp/pdf-info.el
index 032b61d..019d5c5 100644
--- a/lisp/pdf-info.el
+++ b/lisp/pdf-info.el
@@ -543,6 +543,9 @@ This is a no-op, if `pdf-info-log' is nil."
;; * Utility functions
;; * ================================================================== *
+(defvar doc-view-buffer-file-name)
+(defvar doc-view--buffer-file-name)
+
(defun pdf-info--normalize-file-or-buffer (file-or-buffer)
"Return the PDF file corresponding to FILE-OR-BUFFER.
@@ -551,7 +554,11 @@ or a PDF file."
(unless file-or-buffer
(setq file-or-buffer
(cl-case major-mode
- (doc-view-mode doc-view-buffer-file-name)
+ (doc-view-mode
+ (cond ((boundp 'doc-view-buffer-file-name)
+ doc-view-buffer-file-name)
+ ((boundp 'doc-view--buffer-file-name)
+ doc-view--buffer-file-name)))
(pdf-view-mode (pdf-view-buffer-file-name))
(t (current-buffer)))))
(when (bufferp file-or-buffer)
@@ -823,19 +830,14 @@ aforementioned function, when called with the same arguments."
(pdf-info-getselection
page '(0 0 1 1) 'glyph file-or-buffer))
-(defun pdf-info-pagesize (&optional page file-or-buffer)
+(defun pdf-info-pagesize (page &optional file-or-buffer)
"Return the size of PAGE as a cons \(WIDTH . HEIGHT\)
The size is in pixel."
(pdf-info-query
'pagesize
(pdf-info--normalize-file-or-buffer file-or-buffer)
- (or page
- (and (eq (window-buffer)
- (current-buffer))
- (derived-mode-p 'doc-view-mode)
- (doc-view-current-page))
- 1)))
+ page))
(defun pdf-info-quit ()
"Quit the epdfinfo server."
diff --git a/lisp/pdf-isearch.el b/lisp/pdf-isearch.el
index 6afa8e0..0ceea8c 100644
--- a/lisp/pdf-isearch.el
+++ b/lisp/pdf-isearch.el
@@ -29,7 +29,7 @@
(require 'pdf-info)
(require 'pdf-misc)
(require 'pdf-view)
-
+(require 'pdf-cache)
;;; Code:
@@ -470,7 +470,7 @@ match."
(cond
((null last-match)
;; Goto first match from top or bottom of the window.
- (let* ((iedges (pdf-util-image-edges-in-window))
+ (let* ((iedges (pdf-util-image-displayed-edges))
(pos (pdf-util-with-edges (iedges)
(if forward
(cons iedges-left iedges-top)
@@ -503,7 +503,7 @@ match."
(not (eq last-page this-page)))
(pdf-isearch-next-match-isearch
last-page this-page last-match matches same-search-p forward-p)
- (let ((iedges (pdf-util-image-edges-in-window)))
+ (let ((iedges (pdf-util-image-displayed-edges)))
(pdf-util-with-edges (match iedges)
(car (cl-remove-if
;; Filter matches visible on screen.
diff --git a/lisp/pdf-links.el b/lisp/pdf-links.el
index c38e49a..5f18c9a 100644
--- a/lisp/pdf-links.el
+++ b/lisp/pdf-links.el
@@ -231,8 +231,7 @@ scroll the current page."
(when (derived-mode-p 'pdf-view-mode)
(when (> page 0)
(pdf-view-goto-page page))
- (when (and top
- (pdf-util-page-displayed-p))
+ (when top
;; Showing the tooltip is somewhat slow.
(sit-for 0)
(pdf-util-tooltip-arrow top)))))
@@ -346,7 +345,7 @@ See `pdf-links-action-perform' for the interface."
(lambda (e)
(= 0 (pdf-util-edges-intersection-area (car e) match)))
(mapcar (lambda (l)
- (cons (pdf-util-scale-edges
+ (cons (pdf-util-scale
(car l) size)
(cdr l)))
(pdf-cache-pagelinks page)))
@@ -358,7 +357,7 @@ See `pdf-links-action-perform' for the interface."
(pdf-links-action-perform (cdar links))))))
(defun pdf-links-isearch-link-filter-matches (matches)
- (let ((links (pdf-util-scale-edges
+ (let ((links (pdf-util-scale
(mapcar 'car (pdf-cache-pagelinks
(pdf-view-current-page)))
(pdf-view-image-size))))
diff --git a/lisp/pdf-util.el b/lisp/pdf-util.el
index 217a3b1..96b28ef 100644
--- a/lisp/pdf-util.el
+++ b/lisp/pdf-util.el
@@ -22,14 +22,19 @@
;;
;;; Todo:
;;
-;; * Handle remote and locally cached documents.
;;; Code:
(require 'cl-lib)
(require 'format-spec)
(require 'faces)
-(require 'pdf-view)
+
+;; These functions are only used after a PdfView window was asserted,
+;; which won't succeed, if pdf-view.el isn't loaded.
+(declare-function pdf-view-image-size "pdf-view")
+(declare-function pdf-view-image-offset "pdf-view")
+(declare-function pdf-view-current-image "pdf-view")
+(declare-function pdf-view-current-overlay "pdf-view")
;; * ================================================================== *
@@ -253,6 +258,7 @@ values."
"Return the visible region of the image in WINDOW.
Returns a list of pixel edges."
+ (pdf-util-assert-pdf-window)
(let* ((edges (window-inside-pixel-edges window))
(isize (pdf-view-image-size window))
(offset (pdf-view-image-offset window))
@@ -279,6 +285,7 @@ top of the window. CONTEXT-PIXEL defaults to 0.
Return the require hscroll in columns or nil, if scrolling is not
needed."
+ (pdf-util-assert-pdf-window)
(unless context-pixel
(setq context-pixel 0))
(let* ((win (window-inside-pixel-edges))
@@ -318,6 +325,7 @@ value of `next-screen-context-lines'.
Return the require vscroll in lines or nil, if scrolling is not
needed."
+ (pdf-util-assert-pdf-window)
(let* ((win (window-inside-pixel-edges))
(image-height (cdr (pdf-view-image-size t)))
(image-top (window-vscroll nil t))
@@ -471,7 +479,7 @@ is non-nil."
"Return COLOR in hex-format.
Singal an error, if color is invalid."
- (let ((values (color-values (string-trim color))))
+ (let ((values (color-values color)))
(unless values
(signal 'wrong-type-argument (list 'color-defined-p color)))
(apply 'format "#%02x%02x%02x"
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el
index 316258c..bd398f4 100644
--- a/lisp/pdf-view.el
+++ b/lisp/pdf-view.el
@@ -23,10 +23,10 @@
;;; Code:
;;
+(require 'image-mode)
(require 'pdf-util)
(require 'pdf-info)
-
;; * ================================================================== *
;; * Customizations
@@ -71,7 +71,7 @@ of the page moves to the previous page."
"Whether imagemagick should be used for rendering.
This variable has no effect, if imagemagick was not compiled into
-Emacs. FIXME: Explain dis-/advantages of imagemagick and png."
+Emacs. FIXME: Explain dis-/advantages of imagemagick and png."
:group 'pdf-view
:type 'boolean)
@@ -243,18 +243,18 @@ PNG images in Emacs buffers.
;; Setup other local variables.
(setq-local mode-line-position
'(" P" (:eval (number-to-string (pdf-view-current-page)))
- "/" (:eval (number-to-string (pdf-cache-number-of-pages))))
- auto-hscroll-mode nil
- ;; High values of scroll-conservatively seem to trigger
- ;; some display bug in xdisp.c:try_scrolling .
- scroll-conservatively 0
- cursor-type nil
- mode-name "PDFView"
- major-mode 'pdf-view-mode
- buffer-read-only t
- view-read-only nil
- ;; No auto-save at the moment.
- buffer-auto-save-file-name nil)
+ "/" (:eval (number-to-string (pdf-cache-number-of-pages)))))
+ (setq-local auto-hscroll-mode nil)
+ ;; High values of scroll-conservatively seem to trigger
+ ;; some display bug in xdisp.c:try_scrolling .
+ (setq-local scroll-conservatively 0)
+ (setq-local cursor-type nil)
+ (setq-local mode-name "PDFView")
+ (setq-local major-mode 'pdf-view-mode)
+ (setq-local buffer-read-only t)
+ (setq-local view-read-only nil)
+ ;; No auto-save at the moment.
+ (setq-local buffer-auto-save-file-name nil)
(use-local-map pdf-view-mode-map)
(add-hook 'window-configuration-change-hook
'pdf-view-maybe-redisplay-resized-windows nil t)
@@ -535,7 +535,7 @@ dragging it to its bottom-right corner. See also
(setq h (- (cdr (posn-object-x-y (event-end e))) y))
(setq done t))))
(apply 'pdf-view-set-slice
- (pdf-util-scale-edges
+ (pdf-util-scale
(list x y w h)
(cons (/ 1.0 (float (car size)))
(/ 1.0 (float (cdr size))))))))
@@ -675,7 +675,7 @@ It is equal to \(LEFT . TOP\) of the current slice in pixel."
(overlay-put ol 'display
(if slice
(list (cons 'slice
- (pdf-util-scale-edges slice size))
+ (pdf-util-scale slice size))
image)
image))
(let* ((win (overlay-get ol 'window))
@@ -905,7 +905,7 @@ supercede hotspots in lower ones."
(list (list 0 0 (car size) (cdr size)))))
(let ((transient-mark-mode t))
(push-mark))
- (pdf-view-display-active-region))
+ (pdf-view-display-region))
(defun pdf-view-active-region-text ()
"Return the text of the active region as a list of strings."
@@ -922,7 +922,7 @@ supercede hotspots in lower ones."
;; * Display a text cursor
;; * ================================================================== *
-(defvar pdf-view-text-regions-keymap
+(defvar pdf-view-text-regions-minor-mode-map
(let ((km (make-sparse-keymap)))
(define-key km [t] 'pdf-util-image-map-mouse-event-proxy)
km)
@@ -931,7 +931,7 @@ supercede hotspots in lower ones."
(defun pdf-view-text-regions-hotspots-function (page size)
"Return a list of hotspots for text regions on PAGE using SIZE."
(mapcar (lambda (region)
- (let ((e (pdf-util-scale-edges region size)))
+ (let ((e (pdf-util-scale region size)))
`((rect . ((,(nth 0 e) . ,(nth 1 e))
. (,(nth 2 e) . ,(nth 3 e))))
pdf-view-text-region
@@ -947,8 +947,12 @@ supercede hotspots in lower ones."
(cond
(pdf-view-text-regions-minor-mode
(pdf-view-add-hotspot-function 'pdf-view-text-regions-hotspots-function -9)
- (local-set-key [pdf-view-text-region] pdf-view-text-region-keymap))
+ (local-set-key [pdf-view-text-region] pdf-view-text-regions-minor-mode-map))
(t
(pdf-view-remove-hotspot-function 'pdf-view-text-regions-hotspots-function)
(local-set-key [pdf-view-text-region] nil)))
(pdf-view-redisplay t))
+
+(provide 'pdf-view)
+
+;;; pdf-view.el ends here
diff --git a/src/epdfinfo.c b/src/epdfinfo.c
index 7ddcd00..8ac1ea4 100644
--- a/src/epdfinfo.c
+++ b/src/epdfinfo.c
@@ -1070,6 +1070,7 @@ annotation_get_by_key (document_t *doc, const gchar *key)
return g_hash_table_lookup (doc->annotations.keys, key);
}
+#ifdef HAVE_POPPLER_ANNOT_MARKUP
static cairo_region_t*
annotation_markup_get_text_regions (PopplerPage *page, PopplerAnnotTextMarkup *a)
{
@@ -1144,6 +1145,7 @@ annotation_markup_append_text_region (PopplerPage *page, PopplerRectangle *regio
g_list_free (regions);
}
+#endif
/**
* Create a new annotation.
*
@@ -1204,7 +1206,9 @@ annotation_new (const epdfinfo_t *ctx, document_t *doc, PopplerPage *page,
else
cerror_if_not (0, error_msg, "Unknown annotation type: %s", type);
+#endif
error:
+#ifdef HAVE_POPPLER_ANNOT_MARKUP
if (garray) g_array_unref (garray);
if (region) cairo_region_destroy (region);
#endif
@@ -1318,12 +1322,14 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page)
r.y1 = height - m->area.y2;
r.y2 = height - m->area.y1;
+#ifdef HAVE_POPPLER_ANNOT_MARKUP
if (POPPLER_IS_ANNOT_TEXT_MARKUP (a))
{
region = annotation_markup_get_text_regions (page, POPPLER_ANNOT_TEXT_MARKUP (a));
perror_if_not (region, "%s", "Unable to extract annotation's text regions");
}
-
+#endif
+
/* >>> Any Annotation >>> */
/* Page */
printf ("%d:", poppler_page_get_index (page) + 1);
@@ -1426,6 +1432,7 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page)
xpoppler_annot_text_state_string (poppler_annot_text_get_state (ta)),
poppler_annot_text_get_is_open (ta));
}
+#ifdef HAVE_POPPLER_ANNOT_MARKUP
/* <<< Text Annotation <<< */
else if (POPPLER_IS_ANNOT_TEXT_MARKUP (a))
{
@@ -1448,6 +1455,7 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page)
}
/* <<< Markup Text Annotation <<< */
}
+#endif
putchar ('\n');
error:
if (region) cairo_region_destroy (region);