Github messages for voidlinux
 help / color / mirror / Atom feed
From: dkwo <dkwo@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] new package: sioyek
Date: Fri, 08 Jul 2022 16:55:12 +0200	[thread overview]
Message-ID: <20220708145512.hlBmCErQBYLtjAJ63bZ0blHgKUnuR4Kkm4yHBGn-MVw@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-37912@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

There is an updated pull request by dkwo against master on the void-packages repository

https://github.com/dkwo/void-packages sioyek
https://github.com/void-linux/void-packages/pull/37912

new package: sioyek
Sioyek is a PDF viewer designed for reading research papers and technical books. https://sioyek.info/
I applied a patch from a PR to use system mupdf, otherwise it would build its own.
I translated their build_linux.sh into our qmake build helper.
Added new package mujs needed.

A patch file from https://github.com/void-linux/void-packages/pull/37912.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sioyek-37912.patch --]
[-- Type: text/x-diff, Size: 9561 bytes --]

From 5964b212743e497b8c0c049251f6aaa3eff24c28 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Thu, 7 Jul 2022 19:56:41 +0200
Subject: [PATCH 1/2] new package: mujs

---
 srcpkgs/mujs/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/mujs/template

diff --git a/srcpkgs/mujs/template b/srcpkgs/mujs/template
new file mode 100644
index 000000000000..7ee43a2f4c33
--- /dev/null
+++ b/srcpkgs/mujs/template
@@ -0,0 +1,17 @@
+# Template file for 'mujs'
+pkgname=mujs
+version=1.2.0
+revision=1
+build_style=gnu-makefile
+makedepends="readline-devel"
+short_desc="Embeddable JavaScript interpreter written in C"
+maintainer="dkwo <npiazza@disroot.org>"
+license="ISC"
+homepage="https://mujs.com/"
+distfiles="https://github.com/ccxvii/mujs/archive/refs/tags/${version}.tar.gz"
+checksum=bbb74b96c168e7120f1aa2ce0a42026eba01cff14a9234108c91795f3a4c8cd0
+make_install_args+=" prefix=/usr"
+
+post_install() {
+	vlicense COPYING
+}

From 7619ab7f021fe79a397e38a35eba838b5cb6a105 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Thu, 7 Jul 2022 10:39:04 +0200
Subject: [PATCH 2/2] new package: sioyek

---
 srcpkgs/sioyek/patches/294.patch | 152 +++++++++++++++++++++++++++++++
 srcpkgs/sioyek/template          |  36 ++++++++
 2 files changed, 188 insertions(+)
 create mode 100644 srcpkgs/sioyek/patches/294.patch
 create mode 100644 srcpkgs/sioyek/template

diff --git a/srcpkgs/sioyek/patches/294.patch b/srcpkgs/sioyek/patches/294.patch
new file mode 100644
index 000000000000..cc35d1e55879
--- /dev/null
+++ b/srcpkgs/sioyek/patches/294.patch
@@ -0,0 +1,152 @@
+From 35fa37f9485bf933e754b995902f69d53dac1670 Mon Sep 17 00:00:00 2001
+From: lennonhill <31923882+lennonhill@users.noreply.github.com>
+Date: Tue, 28 Jun 2022 18:01:36 +0200
+Subject: [PATCH 1/2] Parse mupdf 1.20 links
+
+---
+ pdf_viewer/document_view.cpp |  2 +-
+ pdf_viewer/main_widget.cpp   |  6 +++---
+ pdf_viewer/utils.cpp         | 20 +++++---------------
+ pdf_viewer/utils.h           |  2 +-
+ 4 files changed, 10 insertions(+), 20 deletions(-)
+
+diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp
+index 9a7d8ea2..d8305620 100644
+--- a/pdf_viewer/document_view.cpp
++++ b/pdf_viewer/document_view.cpp
+@@ -1013,7 +1013,7 @@ std::optional<DocumentPos> DocumentView::find_line_definition() {
+ 
+ 			std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
+ 			if (pdf_link.has_value()) {
+-				auto parsed_uri = parse_uri(pdf_link.value().uri);
++				auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
+ 				DocumentPos res;
+ 				res.page = parsed_uri.page-1;
+ 				res.x = parsed_uri.x;
+diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
+index 9e02e2c6..5bd7ed1f 100644
+--- a/pdf_viewer/main_widget.cpp
++++ b/pdf_viewer/main_widget.cpp
+@@ -135,7 +135,7 @@ void MainWidget::set_overview_position(int page, float offset) {
+ 
+ void MainWidget::set_overview_link(PdfLink link) {
+ 
+-    auto [page, offset_x, offset_y] = parse_uri(link.uri);
++    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
+     if (page >= 1) {
+         set_overview_position(page - 1, offset_y);
+     }
+@@ -2647,7 +2647,7 @@ void MainWidget::handle_pending_text_command(std::wstring text) {
+             }
+             if ((link_index >= 0) && (link_index < static_cast<int>(visible_page_links.size()))) {
+                 auto [selected_page, selected_link] = visible_page_links[link_index];
+-                auto [page, offset_x, offset_y] = parse_uri(selected_link->uri);
++                auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
+                 long_jump_to_destination(page-1, offset_y);
+             }
+         }
+@@ -3223,7 +3223,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
+ 		return;
+ 	}
+ 
+-	auto [page, offset_x, offset_y] = parse_uri(link.uri);
++	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
+ 
+ 	// convert one indexed page to zero indexed page
+ 	page--;
+diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp
+index be9d2e76..505b7d12 100644
+--- a/pdf_viewer/utils.cpp
++++ b/pdf_viewer/utils.cpp
+@@ -24,6 +24,8 @@
+ #include <qnetworkreply.h>
+ #include <qscreen.h>
+ 
++#include <mupdf/pdf.h>
++
+ extern std::wstring LIBGEN_ADDRESS;
+ extern std::wstring GOOGLE_SCHOLAR_ADDRESS;
+ extern std::ofstream LOG_FILE;
+@@ -106,21 +108,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
+ 	return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
+ }
+ 
+-ParsedUri parse_uri(std::string uri) {
+-	int comma_index = -1;
+-
+-	uri = uri.substr(1, uri.size() - 1);
+-	comma_index = static_cast<int>(uri.find(","));
+-	int page = atoi(uri.substr(0, comma_index ).c_str());
+-
+-	uri = uri.substr(comma_index+1, uri.size() - comma_index-1);
+-	comma_index = static_cast<int>(uri.find(","));
+-	float offset_x = atof(uri.substr(0, comma_index ).c_str());
+-
+-	uri = uri.substr(comma_index+1, uri.size() - comma_index-1);
+-	float offset_y = atof(uri.c_str());
+-
+-	return { page, offset_x, offset_y };
++ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
++        fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
++        return { dest.loc.page + 1, dest.x, dest.y };
+ }
+ 
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>& special_symbols) {
+diff --git a/pdf_viewer/utils.h b/pdf_viewer/utils.h
+index 919ff6eb..f7934b7f 100644
+--- a/pdf_viewer/utils.h
++++ b/pdf_viewer/utils.h
+@@ -33,7 +33,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
+ int mod(int a, int b);
+ bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
+ bool rects_intersect(fz_rect rect1, fz_rect rect2);
+-ParsedUri parse_uri(std::string uri);
++ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);
+ 
+ template<typename T>
+
+From 5b2488e7cd9a454faf0ff488ba97c11f22805e25 Mon Sep 17 00:00:00 2001
+From: lennonhill <31923882+lennonhill@users.noreply.github.com>
+Date: Tue, 28 Jun 2022 19:18:53 +0200
+Subject: [PATCH 2/2] Upgrade mupdf to 1.20
+
+---
+ pdf_viewer/document.cpp     | 4 ++--
+ pdf_viewer/pdf_renderer.cpp | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/pdf_viewer/document.cpp b/pdf_viewer/document.cpp
+index f1585ad3..e906594a 100644
+--- a/pdf_viewer/document.cpp
++++ b/pdf_viewer/document.cpp
+@@ -542,14 +542,14 @@ void Document::convert_toc_tree(fz_outline* root, std::vector<TocNode*>& output)
+ 		current_node->title = utf8_decode(root->title);
+ 		current_node->x = root->x;
+ 		current_node->y = root->y;
+-		if (root->page == -1) {
++		if (root->page.page == -1) {
+ 			float xp, yp;
+ 			fz_location loc = fz_resolve_link(context, doc, root->uri, &xp, &yp);
+ 			int chapter_page = accum_chapter_pages[loc.chapter];
+ 			current_node->page = chapter_page + loc.page;
+ 		}
+ 		else {
+-			current_node->page = root->page;
++			current_node->page = root->page.page;
+ 		}
+ 		convert_toc_tree(root->down, current_node->children);
+ 
+diff --git a/pdf_viewer/pdf_renderer.cpp b/pdf_viewer/pdf_renderer.cpp
+index de4c43fc..9adbc998 100644
+--- a/pdf_viewer/pdf_renderer.cpp
++++ b/pdf_viewer/pdf_renderer.cpp
+@@ -315,7 +315,7 @@ void PdfRenderer::run_search(int thread_index)
+ 
+ 				const int max_hits_per_page = 20;
+ 				fz_quad hitboxes[max_hits_per_page];
+-				int num_results = fz_search_page(mupdf_context, page, utf8_encode(req.search_term).c_str(), hitboxes, max_hits_per_page);
++				int num_results = fz_search_page(mupdf_context, page, utf8_encode(req.search_term).c_str(), nullptr, hitboxes, max_hits_per_page);
+ 
+ 				if (num_results > 0) {
+ 					req.search_results_mutex->lock();
diff --git a/srcpkgs/sioyek/template b/srcpkgs/sioyek/template
new file mode 100644
index 000000000000..ecdfa8a8c12b
--- /dev/null
+++ b/srcpkgs/sioyek/template
@@ -0,0 +1,36 @@
+# Template file for 'sioyek'
+pkgname=sioyek
+version=1.4.0
+revision=1
+build_style=qmake
+#make_build_args="pdf_viewer_build_config.pro"
+#make_install_args="sioyek pdf_viewer/prefs.config pdf_viewer/prefs_user.config
+# pdf_viewer/keys.config pdf_viewer/keys_user.config pdf_viewer/shaders
+# tutorial.pdf"
+hostmakedepends="zlib-devel qt5-qmake qt5-host-tools mupdf-devel
+ gumbo-parser-devel harfbuzz-devel mujs
+ qt5-3d-devel qt5-opengl qt5-gui qt5-widgets qt5-network qt5-gamepad-devel"
+makedepends="${makedepends} qt5-opengl"
+depends="mupdf"
+short_desc="PDF viewer designed for reading research papers and technical books"
+maintainer="dkwo <npiazza@disroot.org>"
+license="GPL-3.0-or-later"
+homepage="https://sioyek.info/"
+distfiles="https://github.com/ahrm/sioyek/archive/refs/tags/v${version}.tar.gz"
+checksum=44d49aec28e49bb79c2d0fb7cefd26aecc53b60136bf02dfec9863ac586aacd0
+# configure_args+=" linux_app_image"
+
+do_build() {
+	qmake pdf_viewer_build_config.pro
+	make ${makejobs} CC="$CC" CXX="$CXX" LINK="$CXX"
+}
+
+do_install() {
+	vbin sioyek
+	vmkdir etc/sioyek
+	vinstall pdf_viewer/prefs.config 644 etc/sioyek
+	vinstall pdf_viewer/keys.config 644 etc/sioyek
+	vmkdir usr/share/sioyek/shaders
+	vcopy pdf_viewer/shaders/* usr/share/sioyek/shaders
+	vinstall tutorial.pdf 644 usr/share/sioyek
+}

  parent reply	other threads:[~2022-07-08 14:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 12:32 [PR PATCH] new package: sioyek [wip] dkwo
2022-07-07 18:01 ` [PR PATCH] [Updated] new package: sioyek dkwo
2022-07-07 18:54 ` dkwo
2022-07-07 18:55 ` dkwo
2022-07-07 19:47 ` dkwo
2022-07-07 19:53 ` [PR PATCH] [Updated] " dkwo
2022-07-08 14:55 ` dkwo [this message]
2022-07-08 14:56 ` dkwo
2022-07-08 16:01 ` dkwo
2022-08-19 13:53 ` abenson
2022-08-19 13:55 ` [PR REVIEW] " abenson
2022-08-20 12:28 ` [PR PATCH] [Updated] " dkwo
2022-08-20 12:29 ` [PR REVIEW] " dkwo
2022-09-08  0:55 ` dexgs
2022-09-08 12:53 ` dkwo
2022-09-20 15:36 ` [PR PATCH] [Updated] " dkwo
2022-09-20 19:46 ` [PR REVIEW] " abenson
2022-09-20 19:58 ` [PR PATCH] [Updated] " dkwo
2022-09-20 19:59 ` dkwo
2022-09-20 22:45 ` leahneukirchen
2022-09-20 22:52 ` leahneukirchen
2022-09-21 13:27 ` [PR PATCH] [Updated] " dkwo
2022-09-22 14:03 ` leahneukirchen
2022-09-23 13:59 ` [PR PATCH] [Updated] " dkwo
2022-09-23 20:01 ` [PR PATCH] [Merged]: " leahneukirchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220708145512.hlBmCErQBYLtjAJ63bZ0blHgKUnuR4Kkm4yHBGn-MVw@z \
    --to=dkwo@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).