diff options
| author | Augusto Stoffel <arstoffel@gmail.com> | 2023-02-11 17:27:07 +0100 |
|---|---|---|
| committer | Vedang Manerikar <ved.manerikar@gmail.com> | 2023-06-11 00:59:58 +0530 |
| commit | 97cffdd1b214d0c6e904630468550802d20f4601 (patch) | |
| tree | c869bb328f8f2ae1769611275ee9c3fc536a4212 | |
| parent | 6a86b29140b4e84d9aff5093c444255c20eef463 (diff) | |
Allow creation of markup annotations without a text selection
This allows calling `pdf-info-addannot` from Lisp with a nil
`markup-edges` argument, which was previously disallowed.
In this case, the annotation covers exactly the selected region of the
page, without attempting to match it to a certain text region.
This means that you can now highlight an exact region! Just select the
region by holding down the Meta key and dragging the mouse. Then
invoke `pdf-annot-add-highlight-markup-annotation` (with `C-c C-a h`)
and voila!
Closes: #191
| -rw-r--r-- | lisp/pdf-annot.el | 7 | ||||
| -rw-r--r-- | server/epdfinfo.c | 15 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lisp/pdf-annot.el b/lisp/pdf-annot.el index e0f2ae9..078f132 100644 --- a/lisp/pdf-annot.el +++ b/lisp/pdf-annot.el @@ -1053,9 +1053,12 @@ Return the new annotation." (> (length edges) 1)) (error "Edges argument should be a single edge-list for text annotations")) (let* ((selection-style pdf-view-selection-style) + (non-markup (pcase type + ('text t) + ('highlight pdf-view--have-rectangle-region))) (a (apply #'pdf-info-addannot page - (if (eq type 'text) + (if non-markup (car edges) (apply #'pdf-util-edges-union (apply #'append @@ -1066,7 +1069,7 @@ Return the new annotation." type selection-style nil - (if (not (eq type 'text)) edges))) + (unless non-markup edges))) (id (pdf-annot-get-id a))) (when property-alist (condition-case err diff --git a/server/epdfinfo.c b/server/epdfinfo.c index 6d3e14e..b3925d0 100644 --- a/server/epdfinfo.c +++ b/server/epdfinfo.c @@ -1635,6 +1635,21 @@ annotation_new (const epdfinfo_t *ctx, document_t *doc, PopplerPage *page, #ifdef HAVE_POPPLER_ANNOT_MARKUP garray = g_array_new (FALSE, FALSE, sizeof (PopplerQuadrilateral)); poppler_page_get_size (page, &width, &height); + if (nargs == 0) + { + PopplerQuadrilateral q; + + q.p1.x = r->x1; + q.p1.y = r->y1; + q.p2.x = r->x2; + q.p2.y = r->y1; + q.p4.x = r->x2; + q.p4.y = r->y2; + q.p3.x = r->x1; + q.p3.y = r->y2; + + g_array_append_val (garray, q); + } for (i = 0; i < nargs; ++i) { PopplerRectangle *rr = &carg.value.rectangle; |
