Compare commits

...
12 Commits
Author SHA1 Message Date
haraldandClaude Opus 5.5 4ca21483e5 fix(sync): compare small files by content to detect quick rewrites
Build & Publish Release / Build Packages & Publish to Gitea (push) In progress
File times are only as fine as the kernel clock tick. A manifest rewritten
right after a check with the same length (one page replaced by another)
looked unchanged, so the change was never picked up. Files up to 64 KiB
(manifest, open marker, small pages) now also carry a content hash.

Showed up as a flaky test_page_still_being_synced_is_tried_again in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:23:20 +01:00
haraldandClaude Opus 5.5 c95cde8ec8 chore(release): bump version to 0.39.3
Build & Publish Release / Build Packages & Publish to Gitea (push) Failing after 3m32s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:16:49 +01:00
haraldandClaude Opus 5.5 6b80cd672a fix: stop redrawing endlessly while idle (battery drain)
egui-winit reports `repaint: true` for every RedrawRequested, and the app
followed that with another request_redraw – so it redrew at full frame
rate all the time, keeping the app and the compositor (gnome-shell) busy.
Follow-up frames egui needs already come via `repaint_delay`.

The toast no longer redraws every frame either: one wake-up when its
fade-out starts is enough. While the updater checks or downloads, the
loop looks for its results every 100 ms instead.

Idle CPU under Xvfb/lavapipe: 187 % before, 0 % after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:14:46 +01:00
haraldandClaude Opus 5.5 7faf78ddeb feat(android): follow the activity lifecycle and build an APK (Issue #42)
- The drawing surface is created once the native window exists (Resumed)
  and released when the app goes to the background (Suspended); before
  that everything is saved, as Android may stop the app at any time
- Android's back button acts like Escape instead of closing the app
- Panics are written to logcat; no update check on Android yet
- scripts/package-android.sh builds target/ink-notes_<version>_arm64.apk
  without Gradle (NDK, aapt2, zipalign, apksigner); signing key from
  ANDROID_KEYSTORE/ANDROID_KEYSTORE_PASS/ANDROID_KEY_ALIAS, otherwise
  the debug key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:23:28 +01:00
haraldandClaude Opus 5.5 ce3a1f697b chore(release): bump version to 0.39.2
Build & Publish Release / Build Packages & Publish to Gitea (push) Successful in 19m8s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:57:30 +01:00
haraldandClaude Opus 5.5 e47c2b6f28 build: replace printpdf 0.7 with own PDF writer on lopdf 0.46
printpdf 0.7 pinned lopdf 0.31; newer printpdf versions are a complete
rewrite. The export now uses src/pdf_writer.rs, a small writer on top of
lopdf 0.46 with the subset of the printpdf API the export used: pages with
layers (optional content groups), paths, embedded TrueType fonts (Type0,
Identity-H, ToUnicode), images and bookmarks. Bookmark titles are written
as UTF-16BE directly, so the post-processing step for them is gone.
pdf_merge uses lopdf 0.46 as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:54:13 +01:00
haraldandClaude Opus 5.5 d610ca019a chore(release): bump version to 0.39.1
Build & Publish Release / Build Packages & Publish to Gitea (push) Successful in 12m19s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:46:13 +01:00
haraldandClaude Opus 5.5 8034c88f8b fix(windows): don't let Windows Ink report the mouse as a pen (Issue #48)
octotablet's default emulates a pen tool from the mouse on Windows Ink, so
every mouse move counted as pen hover and every click as pen down, while the
regular mouse events were ignored as duplicates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:44:42 +01:00
haraldandClaude Opus 5.5 1492f8affb chore(release): bump version to 0.39.0
Build & Publish Release / Build Packages & Publish to Gitea (push) Successful in 18m6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:16:45 +01:00
haraldandClaude Opus 5.5 e5a8601f87 feat: Windows build and Android groundwork (Issues #48, #42)
Shared groundwork:
- paths.rs: folders for data, settings and downloads per system (Linux XDG
  unchanged, Windows %APPDATA%/%LOCALAPPDATA%, Android app folder)
- Linux-only parts behind cfg: Wayland on-screen keyboard (osk/wayland.rs),
  display backend and app id, the vendored winit touch extensions
- run_with(event_loop) so that other entry points can start the app

Windows (#48):
- cross-compiled with MinGW into a portable ink-notes_<version>_x86_64.exe
  (system DLLs only), no console window in release builds
- file picker: user folders and drives; held notebook locks are detected
  (ERROR_LOCK_VIOLATION)
- updater: replaces the running .exe via rename, active at the next start
- octotablet panicking without the Tablet PC components no longer crashes
  the app
- release: .exe built in CI and part of the signed checksums
- all library tests pass under wine

Android (#42):
- android_main entry point, winit with android-native-activity,
  android_logger; octotablet and arboard left out there
- cargo check and the cdylib build for aarch64-linux-android pass; the window
  surface does not follow the activity lifecycle yet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:13:37 +01:00
haraldandClaude Opus 5.5 beb780b420 chore(release): bump version to 0.38.0
Build & Publish Release / Build Packages & Publish to Gitea (push) Successful in 7m31s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:51:37 +01:00
haraldandClaude Opus 5.5 9b34e30475 feat: sync notebooks between devices via a synced folder (Issue #49, stage 1)
- Storage location setting: the notebooks can be moved into a folder kept in
  sync by Nextcloud, Google Drive, Syncthing etc. (subfolder `ink-notes`);
  existing notebooks are copied there if it is still empty, the originals stay.
- Changes from other devices are taken over while everything local is saved:
  changed pages are reloaded, new/removed/reordered pages and titles come in
  through the manifest. A page file still being synced is retried later
  instead of being set aside as damaged.
- Conflict copies made by sync clients become pages of their own.
- `.opened_by.json` marks the device that has a notebook open; opening a
  notebook open elsewhere shows a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:09:39 +01:00
38 changed files with 4997 additions and 835 deletions

No files matched your search

+2 -1
View File
@@ -35,6 +35,7 @@ jobs:
libxrandr-dev \ libxrandr-dev \
libxi-dev \ libxi-dev \
libxkbcommon-dev \ libxkbcommon-dev \
gcc-mingw-w64-x86-64 \
squashfs-tools \ squashfs-tools \
dpkg-dev \ dpkg-dev \
curl \ curl \
@@ -62,7 +63,7 @@ jobs:
cargo clippy --all-targets -- -D warnings cargo clippy --all-targets -- -D warnings
cargo test cargo test
- name: Build Release Artifacts (.deb, .AppImage, SHA256SUMS.txt + .minisig) - name: Build Release Artifacts (.deb, .AppImage, .exe, SHA256SUMS.txt + .minisig)
run: | run: |
chmod +x scripts/*.sh chmod +x scripts/*.sh
./scripts/build-release.sh ./scripts/build-release.sh
Generated
+277 -125
View File
@@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2"
dependencies = [ dependencies = [
"ab_glyph_rasterizer", "ab_glyph_rasterizer",
"owned_ttf_parser 0.25.1", "owned_ttf_parser",
] ]
[[package]] [[package]]
@@ -24,6 +24,17 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aes"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"
dependencies = [
"cipher",
"cpubits",
"cpufeatures 0.3.1",
]
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.12" version = "0.8.12"
@@ -85,6 +96,24 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android_log-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d"
[[package]]
name = "android_logger"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f"
dependencies = [
"android_log-sys",
"env_logger",
"log",
"once_cell",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.6" version = "0.1.6"
@@ -201,6 +230,24 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "block-buffer"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
dependencies = [
"hybrid-array",
]
[[package]]
name = "block-padding"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b"
dependencies = [
"hybrid-array",
]
[[package]] [[package]]
name = "block-sys" name = "block-sys"
version = "0.2.1" version = "0.2.1"
@@ -241,17 +288,6 @@ dependencies = [
"alloc-stdlib", "alloc-stdlib",
] ]
[[package]]
name = "bstr"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f"
dependencies = [
"memchr",
"regex-automata",
"serde_core",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.20.3" version = "3.20.3"
@@ -316,6 +352,15 @@ dependencies = [
"wayland-client", "wayland-client",
] ]
[[package]]
name = "cbc"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896"
dependencies = [
"cipher",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.6.0" version = "1.6.0"
@@ -352,6 +397,27 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "chacha20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
dependencies = [
"cfg-if",
"cpufeatures 0.3.1",
"rand_core",
]
[[package]]
name = "cipher"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
dependencies = [
"crypto-common 0.2.2",
"inout",
]
[[package]] [[package]]
name = "clipboard-win" name = "clipboard-win"
version = "5.4.1" version = "5.4.1"
@@ -436,6 +502,12 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "const-oid"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
@@ -482,6 +554,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
[[package]]
name = "cpubits"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.17" version = "0.2.17"
@@ -491,6 +569,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "cpufeatures"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.5.2" version = "1.5.2"
@@ -522,6 +609,15 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "crypto-common"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
]
[[package]] [[package]]
name = "cursor-icon" name = "cursor-icon"
version = "1.2.0" version = "1.2.0"
@@ -545,20 +641,25 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
[[package]]
name = "deranged"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.10.7" version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [ dependencies = [
"block-buffer", "block-buffer 0.10.4",
"crypto-common", "crypto-common 0.1.7",
]
[[package]]
name = "digest"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
dependencies = [
"block-buffer 0.12.1",
"const-oid",
"crypto-common 0.2.2",
] ]
[[package]] [[package]]
@@ -612,6 +713,15 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
[[package]]
name = "ecb"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26f2a8b3e564eba0877223dc343703ad0385794e882e6d13f3a4dd5c6b1f41ac"
dependencies = [
"cipher",
]
[[package]] [[package]]
name = "ecolor" name = "ecolor"
version = "0.27.2" version = "0.27.2"
@@ -699,6 +809,15 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"log",
]
[[package]] [[package]]
name = "epaint" name = "epaint"
version = "0.27.2" version = "0.27.2"
@@ -939,6 +1058,7 @@ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"r-efi 6.0.0", "r-efi 6.0.0",
"rand_core",
] ]
[[package]] [[package]]
@@ -948,7 +1068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159"
dependencies = [ dependencies = [
"color_quant", "color_quant",
"weezl", "weezl 0.1.12",
] ]
[[package]] [[package]]
@@ -1249,6 +1369,15 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "hybrid-array"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "icrate" name = "icrate"
version = "0.0.4" version = "0.0.4"
@@ -1411,9 +1540,10 @@ dependencies = [
[[package]] [[package]]
name = "ink-notes" name = "ink-notes"
version = "0.37.0" version = "0.39.3"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"android_logger",
"arboard", "arboard",
"base64", "base64",
"bytemuck", "bytemuck",
@@ -1426,17 +1556,18 @@ dependencies = [
"hayro", "hayro",
"hayro-svg", "hayro-svg",
"image", "image",
"log",
"lopdf",
"minisign-verify", "minisign-verify",
"naga", "naga",
"octotablet", "octotablet",
"pollster", "pollster",
"printpdf",
"quick-xml", "quick-xml",
"resvg", "resvg",
"semver", "semver",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2 0.10.9",
"tempfile", "tempfile",
"ureq", "ureq",
"url", "url",
@@ -1448,6 +1579,16 @@ dependencies = [
"winit", "winit",
] ]
[[package]]
name = "inout"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f"
dependencies = [
"block-padding",
"hybrid-array",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.18" version = "1.0.18"
@@ -1592,12 +1733,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.15" version = "0.4.15"
@@ -1639,19 +1774,29 @@ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
[[package]] [[package]]
name = "lopdf" name = "lopdf"
version = "0.31.0" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07c8e1b6184b1b32ea5f72f572ebdc40e5da1d2921fa469947ff7c480ad1f85a" checksum = "d43f64cb8c0d673ff84245a6de9e0172c0cc05dc5dd9d263660b5b4a02b6c4ae"
dependencies = [ dependencies = [
"aes",
"bitflags 2.13.2",
"brotli-decompressor",
"cbc",
"ecb",
"encoding_rs", "encoding_rs",
"flate2", "flate2",
"getrandom 0.4.3",
"indexmap",
"itoa", "itoa",
"linked-hash-map",
"log", "log",
"md5", "md-5",
"pom", "nom",
"time", "rand",
"weezl", "rangemap",
"sha2 0.11.1",
"stringprep",
"thiserror 2.0.21",
"weezl 0.2.1",
] ]
[[package]] [[package]]
@@ -1664,10 +1809,14 @@ dependencies = [
] ]
[[package]] [[package]]
name = "md5" name = "md-5"
version = "0.7.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98"
dependencies = [
"cfg-if",
"digest 0.11.3",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
@@ -1798,10 +1947,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]] [[package]]
name = "num-conv" name = "nom"
version = "0.2.2" version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
@@ -1983,22 +2135,13 @@ dependencies = [
"libredox", "libredox",
] ]
[[package]]
name = "owned_ttf_parser"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "706de7e2214113d63a8238d1910463cfce781129a6f263d13fdb09ff64355ba4"
dependencies = [
"ttf-parser 0.19.2",
]
[[package]] [[package]]
name = "owned_ttf_parser" name = "owned_ttf_parser"
version = "0.25.1" version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b"
dependencies = [ dependencies = [
"ttf-parser 0.25.1", "ttf-parser",
] ]
[[package]] [[package]]
@@ -2167,15 +2310,6 @@ dependencies = [
"arrayvec", "arrayvec",
] ]
[[package]]
name = "pom"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c972d8f86e943ad532d0b04e8965a749ad1d18bb981a9c7b3ae72fe7fd7744b"
dependencies = [
"bstr",
]
[[package]] [[package]]
name = "potential_utf" name = "potential_utf"
version = "0.1.6" version = "0.1.6"
@@ -2185,30 +2319,12 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "powerfmt"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
[[package]] [[package]]
name = "presser" name = "presser"
version = "0.3.1" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]]
name = "printpdf"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c30a4cc87c3ca9a98f4970db158a7153f8d1ec8076e005751173c57836380b1d"
dependencies = [
"js-sys",
"lopdf",
"owned_ttf_parser 0.19.0",
"time",
]
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "3.5.0" version = "3.5.0"
@@ -2275,12 +2391,35 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "rand"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
dependencies = [
"chacha20",
"getrandom 0.4.3",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]] [[package]]
name = "range-alloc" name = "range-alloc"
version = "0.1.5" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08"
[[package]]
name = "rangemap"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d"
[[package]] [[package]]
name = "raw-window-handle" name = "raw-window-handle"
version = "0.5.2" version = "0.5.2"
@@ -2342,12 +2481,6 @@ dependencies = [
"bitflags 2.13.2", "bitflags 2.13.2",
] ]
[[package]]
name = "regex-automata"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
[[package]] [[package]]
name = "renderdoc-sys" name = "renderdoc-sys"
version = "1.1.0" version = "1.1.0"
@@ -2573,8 +2706,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures", "cpufeatures 0.2.17",
"digest", "digest 0.10.7",
]
[[package]]
name = "sha2"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
dependencies = [
"cfg-if",
"cpufeatures 0.3.1",
"digest 0.11.3",
] ]
[[package]] [[package]]
@@ -2715,6 +2859,17 @@ dependencies = [
"float-cmp", "float-cmp",
] ]
[[package]]
name = "stringprep"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
dependencies = [
"unicode-bidi",
"unicode-normalization",
"unicode-properties",
]
[[package]] [[package]]
name = "strum" name = "strum"
version = "0.26.3" version = "0.26.3"
@@ -2869,40 +3024,10 @@ dependencies = [
"flate2", "flate2",
"half", "half",
"quick-error", "quick-error",
"weezl", "weezl 0.1.12",
"zune-jpeg", "zune-jpeg",
] ]
[[package]]
name = "time"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
dependencies = [
"deranged",
"num-conv",
"powerfmt",
"serde_core",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
[[package]]
name = "time-macros"
version = "0.2.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
dependencies = [
"num-conv",
"time-core",
]
[[package]] [[package]]
name = "tiny-skia" name = "tiny-skia"
version = "0.11.4" version = "0.11.4"
@@ -2964,6 +3089,12 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "tinyvec"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.53.2" version = "1.53.2"
@@ -3003,12 +3134,6 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "ttf-parser"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1"
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.25.1" version = "0.25.1"
@@ -3030,12 +3155,33 @@ version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "unicode-bidi"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.26" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
[[package]]
name = "unicode-normalization"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-properties"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.13.3" version = "1.13.3"
@@ -3401,6 +3547,12 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "weezl"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4ca08e5ef825b65b056d9efbd95c8750683f0a6d0466d02e96dc2e4e360f3d2"
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.19.4" version = "0.19.4"
+25 -5
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "ink-notes" name = "ink-notes"
version = "0.37.0" version = "0.39.3"
edition = "2021" edition = "2021"
description = "Notizbuch-App für Stift, Touch und Maus unter Linux" description = "Notizbuch-App für Stift, Touch und Maus unter Linux"
repository = "https://gitea.pansi.eu/harald/ink-notes" repository = "https://gitea.pansi.eu/harald/ink-notes"
@@ -24,8 +24,8 @@ glam = { version = "0.27", features = ["serde"] }
# Asynchroner Starter für wgpu-Device-Setup # Asynchroner Starter für wgpu-Device-Setup
pollster = "0.3" pollster = "0.3"
# PDF-Vektorexport # PDF: writing the export (own writer in src/pdf_writer.rs) and merging imported PDFs
printpdf = "0.7" lopdf = { version = "0.46", default-features = false }
serde = { version = "1.0.229", features = ["derive"] } serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.151" serde_json = "1.0.151"
@@ -38,11 +38,9 @@ semver = "1.0"
sha2 = "0.10" sha2 = "0.10"
ureq = { version = "2.10", default-features = false, features = ["tls", "gzip", "json"] } ureq = { version = "2.10", default-features = false, features = ["tls", "gzip", "json"] }
url = "2.5" url = "2.5"
octotablet = "0.1.0"
# Bilder einfügen: Dekodieren (PNG/JPEG/GIF/WebP/BMP) und Systemzwischenablage # Bilder einfügen: Dekodieren (PNG/JPEG/GIF/WebP/BMP) und Systemzwischenablage
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp"] } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp"] }
arboard = { version = "3", default-features = false, features = ["image-data"] }
minisign-verify = "0.3.0" minisign-verify = "0.3.0"
fs2 = "0.4" fs2 = "0.4"
hayro = "0.8" hayro = "0.8"
@@ -58,11 +56,33 @@ resvg = { version = "0.49", default-features = false, features = ["raster-images
# Text-Werkzeug: Schriftmetriken und Rasterung (Schriften aus egui) # Text-Werkzeug: Schriftmetriken und Rasterung (Schriften aus egui)
ab_glyph = "0.2" ab_glyph = "0.2"
# Pen input with pressure on Linux (Wayland/X11) and Windows (Windows Ink)
[target.'cfg(not(target_os = "android"))'.dependencies]
octotablet = "0.1.0"
# Systemzwischenablage (Bilder und Text)
arboard = { version = "3", default-features = false, features = ["image-data"] }
# Bildschirmtastatur unter Wayland anfordern (eigenes text-input-Objekt, siehe src/osk.rs) # Bildschirmtastatur unter Wayland anfordern (eigenes text-input-Objekt, siehe src/osk.rs)
[target.'cfg(target_os = "linux")'.dependencies]
wayland-client = "0.31" wayland-client = "0.31"
wayland-backend = { version = "0.3", features = ["client_system"] } wayland-backend = { version = "0.3", features = ["client_system"] }
wayland-protocols = { version = "0.31", features = ["client", "unstable"] } wayland-protocols = { version = "0.31", features = ["client", "unstable"] }
# Android (Issue #42): winit bound to the native activity. The library is built as
# cdylib and packed into an APK by scripts/package-android.sh
[target.'cfg(target_os = "android")'.dependencies]
winit = { version = "0.29", features = ["rwh_06", "android-native-activity"] }
android_logger = { version = "0.13", default-features = false }
log = "0.4"
[package.metadata.android]
package = "eu.pansi.inknotes"
apk_name = "ink-notes"
[package.metadata.android.sdk]
min_sdk_version = 26
target_sdk_version = 34
[profile.dev] [profile.dev]
opt-level = 1 # Erhöht Rendering-Performance auch im Debug-Modus opt-level = 1 # Erhöht Rendering-Performance auch im Debug-Modus
+15 -5
View File
@@ -13,7 +13,7 @@
ink-notes speichert Handschrift als Vektoren, erkennt auf Wunsch Formen, kann PDFs zum Beschriften sowie Notizbücher aus Xournal++, Rnote und Saber importieren, Bilder und Textfelder einfügen und alles wieder als PDF, PNG oder SVG exportieren. Gespeichert wird automatisch im Hintergrund. ink-notes speichert Handschrift als Vektoren, erkennt auf Wunsch Formen, kann PDFs zum Beschriften sowie Notizbücher aus Xournal++, Rnote und Saber importieren, Bilder und Textfelder einfügen und alles wieder als PDF, PNG oder SVG exportieren. Gespeichert wird automatisch im Hintergrund.
Getestet wird vor allem unter Zorin OS 18 / Ubuntu 24.04 (Wayland und X11). Getestet wird vor allem unter Zorin OS 18 / Ubuntu 24.04 (Wayland und X11). Eine Windows-Version gibt es als experimentelles portables Programm.
Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemsprache, umstellen lässt sie sich im ☰-Menü unter „Sprache / Language“. Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemsprache, umstellen lässt sie sich im ☰-Menü unter „Sprache / Language“.
@@ -68,6 +68,7 @@ Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemspra
- Jede Datei wird erst vollständig in eine temporäre Datei geschrieben und dann ersetzt – ein Absturz beim Speichern hinterlässt keine halbe Datei. - Jede Datei wird erst vollständig in eine temporäre Datei geschrieben und dann ersetzt – ein Absturz beim Speichern hinterlässt keine halbe Datei.
- **Beim Schließen** (Fenster oder `Strg + Q`) und beim Wechsel des Notizbuchs wird alles Ausstehende geschrieben, bevor es weitergeht. Schlägt das fehl, bleibt die App offen und bietet Wiederholen oder eine Notfall-Sicherung an. - **Beim Schließen** (Fenster oder `Strg + Q`) und beim Wechsel des Notizbuchs wird alles Ausstehende geschrieben, bevor es weitergeht. Schlägt das fehl, bleibt die App offen und bietet Wiederholen oder eine Notfall-Sicherung an.
- `Strg + S` speichert sofort. Der Punkt am ☰-Knopf zeigt den Stand: grün = gespeichert, orange = Änderungen warten, gelb = speichert gerade, rot = Fehler. - `Strg + S` speichert sofort. Der Punkt am ☰-Knopf zeigt den Stand: grün = gespeichert, orange = Änderungen warten, gelb = speichert gerade, rot = Fehler.
- **Speicherort** (☰-Menü, „Speicherort“): Liegen die Notizbücher in einem Ordner, den **Nextcloud, Google Drive, Syncthing oder Dropbox** abgleichen, sind sie auf allen Geräten verfügbar. Die Notizbücher liegen im Unterordner `ink-notes`; ist er noch leer, werden die vorhandenen Notizbücher dorthin kopiert (die alten bleiben erhalten). Änderungen von einem anderen Gerät erscheinen nach wenigen Sekunden ohne neu zu öffnen – aber nur, solange lokal alles gespeichert ist, damit nichts überschrieben wird. Legt der Sync-Client eine Konfliktkopie einer Seite an, wird sie als eigene Seite („Konfliktkopie: …“) übernommen statt verloren zu gehen. Ist ein Notizbuch gerade auf einem anderen Gerät geöffnet, warnt die App beim Öffnen.
### Export ### Export
- **PDF** (`Strg + E`) nach `~/Documents/<Titel>.pdf`: Striche und Formen als Vektoren, Textfelder als echter, durchsuchbarer Text, importierte PDF-Seiten als Vektor-Unterlage, Seitentitel als Lesezeichen. - **PDF** (`Strg + E`) nach `~/Documents/<Titel>.pdf`: Striche und Formen als Vektoren, Textfelder als echter, durchsuchbarer Text, importierte PDF-Seiten als Vektor-Unterlage, Seitentitel als Lesezeichen.
@@ -86,7 +87,7 @@ Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemspra
## Installation ## Installation
Pakete gibt es unter [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) als `.deb` und `.AppImage` (x86_64). `<version>` steht für die Versionsnummer, z. B. `0.11.0`. Pakete gibt es unter [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) als `.deb`, `.AppImage` und für Windows als `.exe` (x86_64). `<version>` steht für die Versionsnummer, z. B. `0.11.0`.
```bash ```bash
# Debian-Paket (Zorin OS 18 / Ubuntu 24.04) # Debian-Paket (Zorin OS 18 / Ubuntu 24.04)
@@ -101,6 +102,8 @@ Hinweise:
- Benötigt `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) und einen Grafiktreiber mit Vulkan oder OpenGL. - Benötigt `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) und einen Grafiktreiber mit Vulkan oder OpenGL.
- Meldet das AppImage einen Fehler zu `libfuse.so.2`, entweder `sudo apt install libfuse2t64` installieren oder mit `--appimage-extract-and-run` starten. - Meldet das AppImage einen Fehler zu `libfuse.so.2`, entweder `sudo apt install libfuse2t64` installieren oder mit `--appimage-extract-and-run` starten.
**Windows (experimentell):** `ink-notes_<version>_x86_64.exe` ist ein portables Programm für Windows 10/11 – ohne Installation einfach starten (Windows SmartScreen fragt evtl. einmal nach, da das Programm nicht signiert ist). Stifteingabe mit Druck läuft über Windows Ink (noch nicht auf echter Hardware getestet). Notizbücher und Einstellungen liegen in `%APPDATA%\ink-notes`. Updates ersetzen die `.exe` an Ort und Stelle und gelten ab dem nächsten Start.
--- ---
## Tastenkürzel ## Tastenkürzel
@@ -151,6 +154,10 @@ cargo test # Unit- und Integrationstests
Die CI prüft zusätzlich `cargo fmt --check` und `cargo clippy --all-targets -- -D warnings`. Die CI prüft zusätzlich `cargo fmt --check` und `cargo clippy --all-targets -- -D warnings`.
Andere Systeme:
- **Windows** wird unter Linux übersetzt: `scripts/package-windows.sh` (braucht `gcc-mingw-w64-x86-64`); die Tests laufen mit `wine` als Runner (`CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine cargo test --target x86_64-pc-windows-gnu`).
- **Android** (experimentell, Issue #42): `scripts/package-android.sh` baut `target/ink-notes_<version>_arm64.apk` ohne Gradle. Nötig sind das Android-SDK (build-tools, Plattform 34; `ANDROID_HOME`, Standard `~/android-sdk`) und das NDK; der Signierschlüssel kommt aus `ANDROID_KEYSTORE`, `ANDROID_KEYSTORE_PASS` und `ANDROID_KEY_ALIAS`, sonst wird der Debug-Schlüssel verwendet. Installieren mit `adb install -r target/ink-notes_<version>_arm64.apk`, Log-Ausgaben mit `adb logcat -s ink-notes`. Notizbücher bleiben vorerst in der App; Stifterkennung, Bildschirmtastatur und Dateidialoge fehlen noch.
### Projektstruktur ### Projektstruktur
```text ```text
@@ -172,20 +179,23 @@ src/
├── assets.rs # Bilder und PDFs im Notizbuchordner ├── assets.rs # Bilder und PDFs im Notizbuchordner
├── pdf_doc.rs # PDF lesen und rendern (hayro) ├── pdf_doc.rs # PDF lesen und rendern (hayro)
├── pdf_merge.rs # Importierte PDF-Seiten beim Export unterlegen ├── pdf_merge.rs # Importierte PDF-Seiten beim Export unterlegen
├── pdf_writer.rs # Kleiner PDF-Schreiber für den Export (lopdf)
├── import.rs # Import als neues Notizbuch (Gemeinsames) ├── import.rs # Import als neues Notizbuch (Gemeinsames)
├── xopp.rs # Import von Xournal++-/Xournal-Notizbüchern ├── xopp.rs # Import von Xournal++-/Xournal-Notizbüchern
├── rnote.rs # Import von Rnote-Notizbüchern ├── rnote.rs # Import von Rnote-Notizbüchern
├── saber.rs # Import von Saber-Notizbüchern ├── saber.rs # Import von Saber-Notizbüchern
├── document.rs # Datenmodell: Notizbuch, Seiten, Striche, Seitengrößen ├── document.rs # Datenmodell: Notizbuch, Seiten, Striche, Seitengrößen
├── history.rs # Rückgängig/Wiederholen ├── history.rs # Rückgängig/Wiederholen
├── storage.rs # Laden/Speichern (atomar), Notizbücher, Papierkorb ├── storage.rs # Laden/Speichern (atomar), Notizbücher, Papierkorb, Speicherort
├── disk_watch.rs # Änderungen anderer Geräte übernehmen (Sync-Clients)
├── library.rs # Ordner der Notizbücher (library.json) ├── library.rs # Ordner der Notizbücher (library.json)
├── autosave.rs # Speichern im Hintergrund ├── autosave.rs # Speichern im Hintergrund
├── export.rs # PDF-Export (printpdf) ├── export.rs # PDF-Export
├── page_export.rs # Seite als PNG/SVG, Auswahl als Bild ├── page_export.rs # Seite als PNG/SVG, Auswahl als Bild
├── file_picker.rs # Eingebaute Dateiauswahl ├── file_picker.rs # Eingebaute Dateiauswahl
├── settings.rs # Einstellungen (~/.config/ink-notes/ui.json) ├── settings.rs # Einstellungen (~/.config/ink-notes/ui.json)
├── platform.rs # Wayland/X11-Erkennung ├── platform.rs # Wayland/X11-Erkennung, Unterschiede zwischen Linux, Windows und Android
├── paths.rs # Ordner für Daten, Einstellungen und Downloads je System
├── updater.rs # Updates von Gitea (Signatur- und Prüfsummenprüfung) ├── updater.rs # Updates von Gitea (Signatur- und Prüfsummenprüfung)
└── ui.rs # Oberfläche (egui): Werkzeugleiste, Menüs, Dialoge └── ui.rs # Oberfläche (egui): Werkzeugleiste, Menüs, Dialoge
``` ```
+15 -5
View File
@@ -13,7 +13,7 @@
ink-notes stores handwriting as vectors, can recognize shapes, imports PDFs for annotation as well as Xournal++, Rnote and Saber notebooks, inserts images and text boxes, and exports everything again as PDF, PNG or SVG. Saving happens automatically in the background. ink-notes stores handwriting as vectors, can recognize shapes, imports PDFs for annotation as well as Xournal++, Rnote and Saber notebooks, inserts images and text boxes, and exports everything again as PDF, PNG or SVG. Saving happens automatically in the background.
It is mainly tested on Zorin OS 18 / Ubuntu 24.04 (Wayland and X11). It is mainly tested on Zorin OS 18 / Ubuntu 24.04 (Wayland and X11). A Windows version is available as an experimental portable program.
The interface is available in English and German; ink-notes follows the system language, and you can switch it in the ☰ menu under "Sprache / Language". The interface is available in English and German; ink-notes follows the system language, and you can switch it in the ☰ menu under "Sprache / Language".
@@ -68,6 +68,7 @@ The interface is available in English and German; ink-notes follows the system l
- Every file is first written completely to a temporary file and then replaced – a crash while saving never leaves a half-written file. - Every file is first written completely to a temporary file and then replaced – a crash while saving never leaves a half-written file.
- **When closing** (window or `Ctrl + Q`) and when switching notebooks, everything pending is written before continuing. If that fails, the app stays open and offers to retry or to make an emergency backup. - **When closing** (window or `Ctrl + Q`) and when switching notebooks, everything pending is written before continuing. If that fails, the app stays open and offers to retry or to make an emergency backup.
- `Ctrl + S` saves immediately. The dot on the ☰ button shows the state: green = saved, orange = changes pending, yellow = saving, red = error. - `Ctrl + S` saves immediately. The dot on the ☰ button shows the state: green = saved, orange = changes pending, yellow = saving, red = error.
- **Storage location** (☰ menu, "Storage location"): put the notebooks into a folder that **Nextcloud, Google Drive, Syncthing or Dropbox** keep in sync, and they are available on all your devices. The notebooks are kept in the subfolder `ink-notes`; if it is still empty, the existing notebooks are copied there (the old ones stay). Changes arriving from another device show up within a few seconds without reopening – but only while everything local is saved, so nothing gets overwritten. If the sync client makes a conflict copy of a page, it is added as a page of its own („Conflict copy: …“) instead of getting lost. Opening a notebook that is open on another device shows a warning.
### Export ### Export
- **PDF** (`Ctrl + E`) to `~/Documents/<title>.pdf`: strokes and shapes as vectors, text boxes as real, searchable text, imported PDF pages as vector background, page titles as bookmarks. - **PDF** (`Ctrl + E`) to `~/Documents/<title>.pdf`: strokes and shapes as vectors, text boxes as real, searchable text, imported PDF pages as vector background, page titles as bookmarks.
@@ -86,7 +87,7 @@ The interface is available in English and German; ink-notes follows the system l
## Installation ## Installation
Packages are available under [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) as `.deb` and `.AppImage` (x86_64). `<version>` stands for the version number, e.g. `0.30.2`. Packages are available under [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) as `.deb`, `.AppImage` and for Windows as `.exe` (x86_64). `<version>` stands for the version number, e.g. `0.30.2`.
```bash ```bash
# Debian package (Zorin OS 18 / Ubuntu 24.04) # Debian package (Zorin OS 18 / Ubuntu 24.04)
@@ -101,6 +102,8 @@ Notes:
- Requires `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) and a graphics driver with Vulkan or OpenGL. - Requires `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) and a graphics driver with Vulkan or OpenGL.
- If the AppImage reports an error about `libfuse.so.2`, either install `sudo apt install libfuse2t64` or start it with `--appimage-extract-and-run`. - If the AppImage reports an error about `libfuse.so.2`, either install `sudo apt install libfuse2t64` or start it with `--appimage-extract-and-run`.
**Windows (experimental):** `ink-notes_<version>_x86_64.exe` is a portable program for Windows 10/11 – no installation, just start it (Windows SmartScreen may ask once, as the program is not signed). Pen input with pressure uses Windows Ink (not yet tested on real hardware). Notebooks and settings are stored in `%APPDATA%\ink-notes`. Updates replace the `.exe` in place and take effect at the next start.
--- ---
## Keyboard shortcuts ## Keyboard shortcuts
@@ -151,6 +154,10 @@ cargo test # unit and integration tests
CI additionally checks `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings`. CI additionally checks `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings`.
Other systems:
- **Windows** is cross-compiled on Linux: `scripts/package-windows.sh` (needs `gcc-mingw-w64-x86-64`); the tests run with `wine` as runner (`CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine cargo test --target x86_64-pc-windows-gnu`).
- **Android** (experimental, Issue #42): `scripts/package-android.sh` builds `target/ink-notes_<version>_arm64.apk` without Gradle. It needs the Android SDK (build-tools, platform 34; `ANDROID_HOME`, default `~/android-sdk`) and the NDK; the signing key comes from `ANDROID_KEYSTORE`, `ANDROID_KEYSTORE_PASS` and `ANDROID_KEY_ALIAS`, otherwise the debug key is used. Install with `adb install -r target/ink-notes_<version>_arm64.apk`, log output with `adb logcat -s ink-notes`. Notebooks stay inside the app for now; pen detection, on-screen keyboard and file dialogs are still missing.
New code comments and commit messages are written in English; older code and history still contain German. New code comments and commit messages are written in English; older code and history still contain German.
### Project structure ### Project structure
@@ -174,20 +181,23 @@ src/
├── assets.rs # Images and PDFs in the notebook folder ├── assets.rs # Images and PDFs in the notebook folder
├── pdf_doc.rs # Reading and rendering PDFs (hayro) ├── pdf_doc.rs # Reading and rendering PDFs (hayro)
├── pdf_merge.rs # Underlaying imported PDF pages on export ├── pdf_merge.rs # Underlaying imported PDF pages on export
├── pdf_writer.rs # Small PDF writer for the export (lopdf)
├── import.rs # Import as a new notebook (shared parts) ├── import.rs # Import as a new notebook (shared parts)
├── xopp.rs # Import of Xournal++/Xournal notebooks ├── xopp.rs # Import of Xournal++/Xournal notebooks
├── rnote.rs # Import of Rnote notebooks ├── rnote.rs # Import of Rnote notebooks
├── saber.rs # Import of Saber notebooks ├── saber.rs # Import of Saber notebooks
├── document.rs # Data model: notebook, pages, strokes, page sizes ├── document.rs # Data model: notebook, pages, strokes, page sizes
├── history.rs # Undo/redo ├── history.rs # Undo/redo
├── storage.rs # Loading/saving (atomic), notebooks, trash ├── storage.rs # Loading/saving (atomic), notebooks, trash, storage location
├── disk_watch.rs # Taking over changes from other devices (sync clients)
├── library.rs # Notebook folders (library.json) ├── library.rs # Notebook folders (library.json)
├── autosave.rs # Saving in the background ├── autosave.rs # Saving in the background
├── export.rs # PDF export (printpdf) ├── export.rs # PDF export
├── page_export.rs # Page as PNG/SVG, selection as image ├── page_export.rs # Page as PNG/SVG, selection as image
├── file_picker.rs # Built-in file picker ├── file_picker.rs # Built-in file picker
├── settings.rs # Settings (~/.config/ink-notes/ui.json) ├── settings.rs # Settings (~/.config/ink-notes/ui.json)
├── platform.rs # Wayland/X11 detection ├── platform.rs # Wayland/X11 detection, differences between Linux, Windows and Android
├── paths.rs # Folders for data, settings and downloads per system
├── updater.rs # Updates from Gitea (signature and checksum verification) ├── updater.rs # Updates from Gitea (signature and checksum verification)
└── ui.rs # Interface (egui): toolbar, menus, dialogs └── ui.rs # Interface (egui): toolbar, menus, dialogs
``` ```
+2 -2
View File
@@ -189,13 +189,13 @@ Jede Seite hat einen eigenen Verlauf (`history.rs`): Hinzufügen, Entfernen, Ers
## 8. Export ## 8. Export
`export.rs` erzeugt das PDF mit `printpdf`. Jede Seite bekommt ihre eigene Größe und diese Ebenen: `export.rs` erzeugt das PDF mit `pdf_writer.rs`, einem kleinen Schreiber auf Basis von `lopdf` (Ebenen als optionale Inhaltsgruppen, eingebettete Schriften mit ToUnicode-Tabelle, Bilder, Lesezeichen). Jede Seite bekommt ihre eigene Größe und diese Ebenen:
1. **Background:** Karo, Linien oder Punkte in der gewählten Musterfarbe (immer auf weißem Papier). 1. **Background:** Karo, Linien oder Punkte in der gewählten Musterfarbe (immer auf weißem Papier).
2. **PDF** (nur im Notfall): importierte PDF-Seite als Bild, falls sie sich nicht als Vektor übernehmen lässt. 2. **PDF** (nur im Notfall): importierte PDF-Seite als Bild, falls sie sich nicht als Vektor übernehmen lässt.
3. **Images:** eingefügte Bilder (höchstens 300 dpi). 3. **Images:** eingefügte Bilder (höchstens 300 dpi).
4. **Text:** Textfelder als echter Text mit eingebetteter Schrift (durchsuchbar, kopierbar). Jedes Feld liegt in einem eigenen Koordinatensystem, das eine Transformationsmatrix auf seine Ecken abbildet. 4. **Text:** Textfelder als echter Text mit eingebetteter Schrift (durchsuchbar, kopierbar). Jedes Feld liegt in einem eigenen Koordinatensystem, das eine Transformationsmatrix auf seine Ecken abbildet.
5. **Ink:** Striche als gefüllte Polygone, Formen als Pfade. Halbtransparente Striche (Textmarker) bekommen einen Grafikzustand mit Deckkraft (`ca`/`CA`); printpdf kann solche Zustände nicht anlegen, deshalb trägt `add_alpha_states` sie nach dem Speichern mit `lopdf` in die Seitenressourcen ein. Jeder Strich ist ein einziger Pfad und deckt sich daher nicht selbst doppelt. Der Umriss eines Strichs wird vor dem Export vereinfacht (`geometry::simplify_closed_outline`, höchstens 0,01 mm vom gezeichneten entfernt): Das Netz hat etwa 16 Punkte je Stiftpunkt, und mit allen dauerte der Export einer vollen Seite Sekunden. `INK_NOTES_EXACT_OUTLINES=1` exportiert wie bisher jeden Punkt. 5. **Ink:** Striche als gefüllte Polygone, Formen als Pfade. Halbtransparente Striche (Textmarker) bekommen einen Grafikzustand mit Deckkraft (`ca`/`CA`); `add_alpha_states` trägt sie nach dem Speichern mit `lopdf` in die Seitenressourcen ein. Jeder Strich ist ein einziger Pfad und deckt sich daher nicht selbst doppelt. Der Umriss eines Strichs wird vor dem Export vereinfacht (`geometry::simplify_closed_outline`, höchstens 0,01 mm vom gezeichneten entfernt): Das Netz hat etwa 16 Punkte je Stiftpunkt, und mit allen dauerte der Export einer vollen Seite Sekunden. `INK_NOTES_EXACT_OUTLINES=1` exportiert wie bisher jeden Punkt.
Importierte PDF-Seiten werden anschließend als Form-XObject unter die Seite gelegt (`pdf_merge.rs`), bleiben also Vektorgrafik. Seitentitel werden zu Lesezeichen. Importierte PDF-Seiten werden anschließend als Form-XObject unter die Seite gelegt (`pdf_merge.rs`), bleiben also Vektorgrafik. Seitentitel werden zu Lesezeichen.
+2 -2
View File
@@ -189,13 +189,13 @@ Each page has its own history (`history.rs`): adding, removing, replacing and mo
## 8. Export ## 8. Export
`export.rs` creates the PDF with `printpdf`. Each page gets its own size and these layers: `export.rs` creates the PDF with `pdf_writer.rs`, a small writer on top of `lopdf` (layers as optional content groups, embedded fonts with a ToUnicode map, images, bookmarks). Each page gets its own size and these layers:
1. **Background:** squares, lines or dots in the chosen pattern color (always on white paper). 1. **Background:** squares, lines or dots in the chosen pattern color (always on white paper).
2. **PDF** (fallback only): imported PDF page as an image, if it cannot be taken over as vectors. 2. **PDF** (fallback only): imported PDF page as an image, if it cannot be taken over as vectors.
3. **Images:** inserted images (at most 300 dpi). 3. **Images:** inserted images (at most 300 dpi).
4. **Text:** text boxes as real text with embedded font (searchable, copyable). Each box lives in its own coordinate system that a transformation matrix maps onto its corners. 4. **Text:** text boxes as real text with embedded font (searchable, copyable). Each box lives in its own coordinate system that a transformation matrix maps onto its corners.
5. **Ink:** strokes as filled polygons, shapes as paths. Semi-transparent strokes (highlighter) get a graphics state with opacity (`ca`/`CA`); printpdf cannot create such states, so `add_alpha_states` adds them to the page resources with `lopdf` after saving. Each stroke is a single path and therefore does not cover itself twice. The outline of a stroke is simplified before export (`geometry::simplify_closed_outline`, at most 0.01 mm away from the drawn one): the mesh has about 16 points per pen sample, and with all of them a full page took seconds to export. `INK_NOTES_EXACT_OUTLINES=1` exports every point as before. 5. **Ink:** strokes as filled polygons, shapes as paths. Semi-transparent strokes (highlighter) get a graphics state with opacity (`ca`/`CA`); `add_alpha_states` adds them to the page resources with `lopdf` after saving. Each stroke is a single path and therefore does not cover itself twice. The outline of a stroke is simplified before export (`geometry::simplify_closed_outline`, at most 0.01 mm away from the drawn one): the mesh has about 16 points per pen sample, and with all of them a full page took seconds to export. `INK_NOTES_EXACT_OUTLINES=1` exports every point as before.
Imported PDF pages are then placed under the page as a form XObject (`pdf_merge.rs`), so they stay vector graphics. Page titles become bookmarks. Imported PDF pages are then placed under the page as a form XObject (`pdf_merge.rs`), so they stay vector graphics. Page titles become bookmarks.
+11
View File
@@ -21,6 +21,7 @@ Dieses Dokument beschreibt, wo und wie ink-notes Notizbücher speichert, und die
│ │ ├── assets/ eingefügte Bilder und importierte PDFs │ │ ├── assets/ eingefügte Bilder und importierte PDFs
│ │ │ ├── <sha256>.png │ │ │ ├── <sha256>.png
│ │ │ └── <sha256>.pdf │ │ │ └── <sha256>.pdf
│ │ ├── .opened_by.json Gerät, auf dem das Notizbuch geöffnet ist (siehe unten)
│ │ └── .lock Sperrdatei, solange das Notizbuch geöffnet ist │ │ └── .lock Sperrdatei, solange das Notizbuch geöffnet ist
│ └── .trash/ gelöschte Notizbücher (<id>_<zeitstempel>) │ └── .trash/ gelöschte Notizbücher (<id>_<zeitstempel>)
└── recovery/ Notfall-Sicherungen ungespeicherter Seiten └── recovery/ Notfall-Sicherungen ungespeicherter Seiten
@@ -28,6 +29,10 @@ Dieses Dokument beschreibt, wo und wie ink-notes Notizbücher speichert, und die
~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) Einstellungen der Oberfläche ~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) Einstellungen der Oberfläche
``` ```
Unter Windows liegt dieselbe Struktur in `%APPDATA%\ink-notes` (Notizbücher, `recovery`, `ui.json`); heruntergeladene Updates landen in `%LOCALAPPDATA%\ink-notes`.
Der Ordner `notebooks/` lässt sich in den Einstellungen verlegen (`storage_dir` in `ui.json`), z. B. nach `~/Nextcloud/ink-notes`; `recovery/` bleibt, wo es ist.
- **Notizbuch-IDs** werden aus dem Titel und dem Zeitpunkt gebildet (z. B. `mathematik_1775460000`); das erste Notizbuch heißt `default`. - **Notizbuch-IDs** werden aus dem Titel und dem Zeitpunkt gebildet (z. B. `mathematik_1775460000`); das erste Notizbuch heißt `default`.
- **Assets** sind nach dem SHA-256-Hash ihres Inhalts benannt; dasselbe Bild wird nur einmal gespeichert. Bilder werden als PNG oder (unverändert) JPEG abgelegt, PDFs unverändert. - **Assets** sind nach dem SHA-256-Hash ihres Inhalts benannt; dasselbe Bild wird nur einmal gespeichert. Bilder werden als PNG oder (unverändert) JPEG abgelegt, PDFs unverändert.
- Alle Dateien werden mit Rechten `0600`, Ordner mit `0700` angelegt. - Alle Dateien werden mit Rechten `0600`, Ordner mit `0700` angelegt.
@@ -167,6 +172,12 @@ Ein Absturz während des Speicherns hinterlässt deshalb entweder die alte oder
### Gelöschte Seiten ### Gelöschte Seiten
Eine gelöschte Seite verschwindet aus `manifest.json`; ihre Datei `page_<id>.json` bleibt im Ordner liegen. Seitenkennungen werden nie wiederverwendet (`next_page_id`), die Datei kann also mit keiner neuen Seite kollidieren. Wird die Seite in derselben Sitzung wiederhergestellt, schreibt die App sie neu. Eine gelöschte Seite verschwindet aus `manifest.json`; ihre Datei `page_<id>.json` bleibt im Ordner liegen. Seitenkennungen werden nie wiederverwendet (`next_page_id`), die Datei kann also mit keiner neuen Seite kollidieren. Wird die Seite in derselben Sitzung wiederhergestellt, schreibt die App sie neu.
### Abgleich zwischen Geräten
Liegen die Notizbücher in einem Ordner, den Nextcloud, Google Drive, Syncthing o. Ä. abgleichen:
- `.opened_by.json` (`{"device": "<Rechnername>", "since": <Unix-Zeit>}`) wird beim Öffnen eines Notizbuchs geschrieben und beim Schließen entfernt. Eine Markierung eines anderen Geräts führt zu einer Warnung; die Sperrdatei `.lock` schützt nur vor einer zweiten Instanz auf demselben Rechner.
- Solange alle lokalen Änderungen gespeichert sind, prüft die App den Ordner alle 3 Sekunden (und wenn das Fenster den Fokus bekommt). Geänderte Seitendateien werden neu geladen, ein geändertes `manifest.json` bringt neue, entfernte oder umsortierte Seiten und Titel mit.
- Konfliktkopien der Sync-Clients (`page_<id> (….json`, `page_<id>_….json`, `page_<id>.sync-conflict-….json`) werden als neue Seiten hinter dem Original eingefügt und in `<name>.imported` umbenannt.
### Neuere Versionen ### Neuere Versionen
Dateien mit einer höheren `format_version` als der unterstützten werden nicht geöffnet – so kann eine ältere App-Version keine Inhalte verlieren, die sie nicht kennt. Dateien mit einer höheren `format_version` als der unterstützten werden nicht geöffnet – so kann eine ältere App-Version keine Inhalte verlieren, die sie nicht kennt.
+11
View File
@@ -21,6 +21,7 @@ This document describes where and how ink-notes stores notebooks, and the versio
│ │ ├── assets/ inserted images and imported PDFs │ │ ├── assets/ inserted images and imported PDFs
│ │ │ ├── <sha256>.png │ │ │ ├── <sha256>.png
│ │ │ └── <sha256>.pdf │ │ │ └── <sha256>.pdf
│ │ ├── .opened_by.json device that has the notebook open (see below)
│ │ └── .lock lock file while the notebook is open │ │ └── .lock lock file while the notebook is open
│ └── .trash/ deleted notebooks (<id>_<timestamp>) │ └── .trash/ deleted notebooks (<id>_<timestamp>)
└── recovery/ emergency backups of unsaved pages └── recovery/ emergency backups of unsaved pages
@@ -28,6 +29,10 @@ This document describes where and how ink-notes stores notebooks, and the versio
~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) interface settings ~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) interface settings
``` ```
On Windows the same structure lies in `%APPDATA%\ink-notes` (notebooks, `recovery`, `ui.json`); downloaded updates go to `%LOCALAPPDATA%\ink-notes`.
The folder `notebooks/` can be moved elsewhere in the settings (`storage_dir` in `ui.json`), e.g. to `~/Nextcloud/ink-notes`; `recovery/` stays where it is.
- **Notebook IDs** are built from the title and the time (e.g. `mathematik_1775460000`); the first notebook is called `default`. - **Notebook IDs** are built from the title and the time (e.g. `mathematik_1775460000`); the first notebook is called `default`.
- **Assets** are named after the SHA-256 hash of their content; the same image is stored only once. Images are stored as PNG or (unchanged) JPEG, PDFs unchanged. - **Assets** are named after the SHA-256 hash of their content; the same image is stored only once. Images are stored as PNG or (unchanged) JPEG, PDFs unchanged.
- All files are created with permissions `0600`, folders with `0700`. - All files are created with permissions `0600`, folders with `0700`.
@@ -167,6 +172,12 @@ A crash while saving therefore leaves either the old or the new file, never a ha
### Deleted pages ### Deleted pages
A deleted page disappears from `manifest.json`; its file `page_<id>.json` stays in the folder. Page IDs are never reused (`next_page_id`), so the file cannot collide with a new page. If the page is restored in the same session, the app writes it again. A deleted page disappears from `manifest.json`; its file `page_<id>.json` stays in the folder. Page IDs are never reused (`next_page_id`), so the file cannot collide with a new page. If the page is restored in the same session, the app writes it again.
### Syncing between devices
If the notebooks are kept in a folder synced by Nextcloud, Google Drive, Syncthing or similar:
- `.opened_by.json` (`{"device": "<host name>", "since": <unix time>}`) is written when a notebook is opened and removed when it is closed. A marker from another device leads to a warning; the lock file `.lock` only protects against a second instance on the same computer.
- While all local changes are saved, the app checks the folder every 3 seconds (and when the window gets the focus). Changed page files are reloaded, a changed `manifest.json` brings in new, removed or reordered pages and titles.
- Conflict copies of sync clients (`page_<id> (….json`, `page_<id>_….json`, `page_<id>.sync-conflict-….json`) are added as new pages after the original and renamed to `<name>.imported`.
### Newer versions ### Newer versions
Files with a higher `format_version` than supported are not opened – this way an older app version cannot lose content it does not know. Files with a higher `format_version` than supported are not opened – this way an older app version cannot lose content it does not know.
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Manifest of the Android app (Issue #42). scripts/package-android.sh fills in the version.
NativeActivity loads libink_notes.so, whose android_main runs the app. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.pansi.inknotes"
android:versionCode="@VERSION_CODE@"
android:versionName="@VERSION@">
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<application
android:label="ink-notes"
android:icon="@mipmap/ic_launcher"
android:hasCode="false"
android:extractNativeLibs="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<!-- configChanges: rotating the tablet or attaching a keyboard must not restart the
activity; the app adapts to the new window size itself -->
<activity
android:name="android.app.NativeActivity"
android:exported="true"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation|density|uiMode|fontScale|locale|layoutDirection">
<meta-data android:name="android.app.lib_name" android:value="ink_notes" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
+25
View File
@@ -84,6 +84,31 @@
</branding> </branding>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="0.39.3" date="2026-10-27">
<description>
<p>Much lower battery use: the app no longer redraws the window continuously while nothing happens.</p>
</description>
</release>
<release version="0.39.2" date="2026-10-27">
<description>
<p>PDF export now uses its own small PDF writer on lopdf 0.46 instead of printpdf; the exported files look the same.</p>
</description>
</release>
<release version="0.39.1" date="2026-10-27">
<description>
<p>Windows: the mouse works again; Windows Ink no longer reports it as a pen.</p>
</description>
</release>
<release version="0.39.0" date="2026-10-27">
<description>
<p>First experimental Windows version as a portable program. Internal groundwork for Android; nothing changes on Linux.</p>
</description>
</release>
<release version="0.38.0" date="2026-10-27">
<description>
<p>The notebooks can be stored in a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox. Changes from other devices are taken over automatically, conflict copies become pages of their own, and a warning appears when a notebook is open on another device.</p>
</description>
</release>
<release version="0.37.0" date="2026-10-27"> <release version="0.37.0" date="2026-10-27">
<description> <description>
<p>Saber notebooks (.sbn2, .sba, .sbn) can be imported as new notebooks, with strokes, pen pressure, highlighters, shapes, typed text, images and PDF backgrounds.</p> <p>Saber notebooks (.sbn2, .sba, .sbn) can be imported as new notebooks, with strokes, pen pressure, highlighters, shapes, typed text, images and PDF backgrounds.</p>
+390
View File
@@ -38,6 +38,19 @@
"dest": "cargo/vendor/adler2-2.0.1", "dest": "cargo/vendor/adler2-2.0.1",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/aes/aes-0.9.3.crate",
"sha256": "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32",
"dest": "cargo/vendor/aes-0.9.3"
},
{
"type": "inline",
"contents": "{\"package\": \"35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32\", \"files\": {}}",
"dest": "cargo/vendor/aes-0.9.3",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -116,6 +129,32 @@
"dest": "cargo/vendor/android-properties-0.2.2", "dest": "cargo/vendor/android-properties-0.2.2",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/android_log-sys/android_log-sys-0.3.2.crate",
"sha256": "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d",
"dest": "cargo/vendor/android_log-sys-0.3.2"
},
{
"type": "inline",
"contents": "{\"package\": \"84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d\", \"files\": {}}",
"dest": "cargo/vendor/android_log-sys-0.3.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/android_logger/android_logger-0.13.3.crate",
"sha256": "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f",
"dest": "cargo/vendor/android_logger-0.13.3"
},
{
"type": "inline",
"contents": "{\"package\": \"c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f\", \"files\": {}}",
"dest": "cargo/vendor/android_logger-0.13.3",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -311,6 +350,32 @@
"dest": "cargo/vendor/block-buffer-0.10.4", "dest": "cargo/vendor/block-buffer-0.10.4",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/block-buffer/block-buffer-0.12.1.crate",
"sha256": "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa",
"dest": "cargo/vendor/block-buffer-0.12.1"
},
{
"type": "inline",
"contents": "{\"package\": \"d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa\", \"files\": {}}",
"dest": "cargo/vendor/block-buffer-0.12.1",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/block-padding/block-padding-0.4.2.crate",
"sha256": "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b",
"dest": "cargo/vendor/block-padding-0.4.2"
},
{
"type": "inline",
"contents": "{\"package\": \"710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b\", \"files\": {}}",
"dest": "cargo/vendor/block-padding-0.4.2",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -467,6 +532,19 @@
"dest": "cargo/vendor/calloop-wayland-source-0.2.0", "dest": "cargo/vendor/calloop-wayland-source-0.2.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/cbc/cbc-0.2.1.crate",
"sha256": "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896",
"dest": "cargo/vendor/cbc-0.2.1"
},
{
"type": "inline",
"contents": "{\"package\": \"ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896\", \"files\": {}}",
"dest": "cargo/vendor/cbc-0.2.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -532,6 +610,32 @@
"dest": "cargo/vendor/cfg_aliases-0.2.2", "dest": "cargo/vendor/cfg_aliases-0.2.2",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/chacha20/chacha20-0.10.2.crate",
"sha256": "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06",
"dest": "cargo/vendor/chacha20-0.10.2"
},
{
"type": "inline",
"contents": "{\"package\": \"65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06\", \"files\": {}}",
"dest": "cargo/vendor/chacha20-0.10.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/cipher/cipher-0.5.2.crate",
"sha256": "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c",
"dest": "cargo/vendor/cipher-0.5.2"
},
{
"type": "inline",
"contents": "{\"package\": \"e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c\", \"files\": {}}",
"dest": "cargo/vendor/cipher-0.5.2",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -649,6 +753,19 @@
"dest": "cargo/vendor/concurrent-queue-2.5.0", "dest": "cargo/vendor/concurrent-queue-2.5.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/const-oid/const-oid-0.10.2.crate",
"sha256": "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c",
"dest": "cargo/vendor/const-oid-0.10.2"
},
{
"type": "inline",
"contents": "{\"package\": \"a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c\", \"files\": {}}",
"dest": "cargo/vendor/const-oid-0.10.2",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -714,6 +831,19 @@
"dest": "cargo/vendor/core_detect-1.0.0", "dest": "cargo/vendor/core_detect-1.0.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/cpubits/cpubits-0.1.1.crate",
"sha256": "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae",
"dest": "cargo/vendor/cpubits-0.1.1"
},
{
"type": "inline",
"contents": "{\"package\": \"15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae\", \"files\": {}}",
"dest": "cargo/vendor/cpubits-0.1.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -727,6 +857,19 @@
"dest": "cargo/vendor/cpufeatures-0.2.17", "dest": "cargo/vendor/cpufeatures-0.2.17",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/cpufeatures/cpufeatures-0.3.1.crate",
"sha256": "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566",
"dest": "cargo/vendor/cpufeatures-0.3.1"
},
{
"type": "inline",
"contents": "{\"package\": \"5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566\", \"files\": {}}",
"dest": "cargo/vendor/cpufeatures-0.3.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -779,6 +922,19 @@
"dest": "cargo/vendor/crypto-common-0.1.7", "dest": "cargo/vendor/crypto-common-0.1.7",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/crypto-common/crypto-common-0.2.2.crate",
"sha256": "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453",
"dest": "cargo/vendor/crypto-common-0.2.2"
},
{
"type": "inline",
"contents": "{\"package\": \"ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453\", \"files\": {}}",
"dest": "cargo/vendor/crypto-common-0.2.2",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -844,6 +1000,19 @@
"dest": "cargo/vendor/digest-0.10.7", "dest": "cargo/vendor/digest-0.10.7",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/digest/digest-0.11.3.crate",
"sha256": "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2",
"dest": "cargo/vendor/digest-0.11.3"
},
{
"type": "inline",
"contents": "{\"package\": \"f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2\", \"files\": {}}",
"dest": "cargo/vendor/digest-0.11.3",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -922,6 +1091,19 @@
"dest": "cargo/vendor/downcast-rs-1.2.1", "dest": "cargo/vendor/downcast-rs-1.2.1",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/ecb/ecb-0.2.1.crate",
"sha256": "26f2a8b3e564eba0877223dc343703ad0385794e882e6d13f3a4dd5c6b1f41ac",
"dest": "cargo/vendor/ecb-0.2.1"
},
{
"type": "inline",
"contents": "{\"package\": \"26f2a8b3e564eba0877223dc343703ad0385794e882e6d13f3a4dd5c6b1f41ac\", \"files\": {}}",
"dest": "cargo/vendor/ecb-0.2.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -1013,6 +1195,19 @@
"dest": "cargo/vendor/enum_dispatch-0.3.13", "dest": "cargo/vendor/enum_dispatch-0.3.13",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/env_logger/env_logger-0.10.2.crate",
"sha256": "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580",
"dest": "cargo/vendor/env_logger-0.10.2"
},
{
"type": "inline",
"contents": "{\"package\": \"4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580\", \"files\": {}}",
"dest": "cargo/vendor/env_logger-0.10.2",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -1754,6 +1949,19 @@
"dest": "cargo/vendor/home-0.5.12", "dest": "cargo/vendor/home-0.5.12",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/hybrid-array/hybrid-array-0.4.15.crate",
"sha256": "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17",
"dest": "cargo/vendor/hybrid-array-0.4.15"
},
{
"type": "inline",
"contents": "{\"package\": \"27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17\", \"files\": {}}",
"dest": "cargo/vendor/hybrid-array-0.4.15",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -1936,6 +2144,19 @@
"dest": "cargo/vendor/indexmap-2.14.2", "dest": "cargo/vendor/indexmap-2.14.2",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/inout/inout-0.2.5.crate",
"sha256": "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f",
"dest": "cargo/vendor/inout-0.2.5"
},
{
"type": "inline",
"contents": "{\"package\": \"3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f\", \"files\": {}}",
"dest": "cargo/vendor/inout-0.2.5",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -2222,6 +2443,19 @@
"dest": "cargo/vendor/log-0.4.34", "dest": "cargo/vendor/log-0.4.34",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/lopdf/lopdf-0.46.0.crate",
"sha256": "d43f64cb8c0d673ff84245a6de9e0172c0cc05dc5dd9d263660b5b4a02b6c4ae",
"dest": "cargo/vendor/lopdf-0.46.0"
},
{
"type": "inline",
"contents": "{\"package\": \"d43f64cb8c0d673ff84245a6de9e0172c0cc05dc5dd9d263660b5b4a02b6c4ae\", \"files\": {}}",
"dest": "cargo/vendor/lopdf-0.46.0",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -2248,6 +2482,19 @@
"dest": "cargo/vendor/malloc_buf-0.0.6", "dest": "cargo/vendor/malloc_buf-0.0.6",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/md-5/md-5-0.11.0.crate",
"sha256": "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98",
"dest": "cargo/vendor/md-5-0.11.0"
},
{
"type": "inline",
"contents": "{\"package\": \"69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98\", \"files\": {}}",
"dest": "cargo/vendor/md-5-0.11.0",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -2430,6 +2677,19 @@
"dest": "cargo/vendor/nohash-hasher-0.2.0", "dest": "cargo/vendor/nohash-hasher-0.2.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/nom/nom-8.0.0.crate",
"sha256": "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405",
"dest": "cargo/vendor/nom-8.0.0"
},
{
"type": "inline",
"contents": "{\"package\": \"df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405\", \"files\": {}}",
"dest": "cargo/vendor/nom-8.0.0",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -3119,6 +3379,32 @@
"dest": "cargo/vendor/r-efi-6.0.0", "dest": "cargo/vendor/r-efi-6.0.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/rand/rand-0.10.3.crate",
"sha256": "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af",
"dest": "cargo/vendor/rand-0.10.3"
},
{
"type": "inline",
"contents": "{\"package\": \"65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af\", \"files\": {}}",
"dest": "cargo/vendor/rand-0.10.3",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/rand_core/rand_core-0.10.1.crate",
"sha256": "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69",
"dest": "cargo/vendor/rand_core-0.10.1"
},
{
"type": "inline",
"contents": "{\"package\": \"63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69\", \"files\": {}}",
"dest": "cargo/vendor/rand_core-0.10.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -3132,6 +3418,19 @@
"dest": "cargo/vendor/range-alloc-0.1.5", "dest": "cargo/vendor/range-alloc-0.1.5",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/rangemap/rangemap-1.8.0.crate",
"sha256": "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d",
"dest": "cargo/vendor/rangemap-1.8.0"
},
{
"type": "inline",
"contents": "{\"package\": \"a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d\", \"files\": {}}",
"dest": "cargo/vendor/rangemap-1.8.0",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -3535,6 +3834,19 @@
"dest": "cargo/vendor/sha2-0.10.9", "dest": "cargo/vendor/sha2-0.10.9",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/sha2/sha2-0.11.1.crate",
"sha256": "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19",
"dest": "cargo/vendor/sha2-0.11.1"
},
{
"type": "inline",
"contents": "{\"package\": \"47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19\", \"files\": {}}",
"dest": "cargo/vendor/sha2-0.11.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -3743,6 +4055,19 @@
"dest": "cargo/vendor/strict-num-0.1.1", "dest": "cargo/vendor/strict-num-0.1.1",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/stringprep/stringprep-0.1.5.crate",
"sha256": "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1",
"dest": "cargo/vendor/stringprep-0.1.5"
},
{
"type": "inline",
"contents": "{\"package\": \"7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1\", \"files\": {}}",
"dest": "cargo/vendor/stringprep-0.1.5",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -4042,6 +4367,19 @@
"dest": "cargo/vendor/tinystr-0.8.4", "dest": "cargo/vendor/tinystr-0.8.4",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/tinyvec/tinyvec-1.13.3.crate",
"sha256": "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee",
"dest": "cargo/vendor/tinyvec-1.13.3"
},
{
"type": "inline",
"contents": "{\"package\": \"fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee\", \"files\": {}}",
"dest": "cargo/vendor/tinyvec-1.13.3",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -4146,6 +4484,19 @@
"dest": "cargo/vendor/typenum-1.20.1", "dest": "cargo/vendor/typenum-1.20.1",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.18.crate",
"sha256": "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5",
"dest": "cargo/vendor/unicode-bidi-0.3.18"
},
{
"type": "inline",
"contents": "{\"package\": \"5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5\", \"files\": {}}",
"dest": "cargo/vendor/unicode-bidi-0.3.18",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -4159,6 +4510,32 @@
"dest": "cargo/vendor/unicode-ident-1.0.26", "dest": "cargo/vendor/unicode-ident-1.0.26",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/unicode-normalization/unicode-normalization-0.1.26.crate",
"sha256": "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d",
"dest": "cargo/vendor/unicode-normalization-0.1.26"
},
{
"type": "inline",
"contents": "{\"package\": \"75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d\", \"files\": {}}",
"dest": "cargo/vendor/unicode-normalization-0.1.26",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/unicode-properties/unicode-properties-0.1.4.crate",
"sha256": "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d",
"dest": "cargo/vendor/unicode-properties-0.1.4"
},
{
"type": "inline",
"contents": "{\"package\": \"7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d\", \"files\": {}}",
"dest": "cargo/vendor/unicode-properties-0.1.4",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -4601,6 +4978,19 @@
"dest": "cargo/vendor/weezl-0.1.12", "dest": "cargo/vendor/weezl-0.1.12",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/weezl/weezl-0.2.1.crate",
"sha256": "d4ca08e5ef825b65b056d9efbd95c8750683f0a6d0466d02e96dc2e4e360f3d2",
"dest": "cargo/vendor/weezl-0.2.1"
},
{
"type": "inline",
"contents": "{\"package\": \"d4ca08e5ef825b65b056d9efbd95c8750683f0a6d0466d02e96dc2e4e360f3d2\", \"files\": {}}",
"dest": "cargo/vendor/weezl-0.2.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
+25
View File
@@ -84,6 +84,31 @@
</branding> </branding>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="0.39.3" date="2026-10-27">
<description>
<p>Much lower battery use: the app no longer redraws the window continuously while nothing happens.</p>
</description>
</release>
<release version="0.39.2" date="2026-10-27">
<description>
<p>PDF export now uses its own small PDF writer on lopdf 0.46 instead of printpdf; the exported files look the same.</p>
</description>
</release>
<release version="0.39.1" date="2026-10-27">
<description>
<p>Windows: the mouse works again; Windows Ink no longer reports it as a pen.</p>
</description>
</release>
<release version="0.39.0" date="2026-10-27">
<description>
<p>First experimental Windows version as a portable program. Internal groundwork for Android; nothing changes on Linux.</p>
</description>
</release>
<release version="0.38.0" date="2026-10-27">
<description>
<p>The notebooks can be stored in a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox. Changes from other devices are taken over automatically, conflict copies become pages of their own, and a warning appears when a notebook is open on another device.</p>
</description>
</release>
<release version="0.37.0" date="2026-10-27"> <release version="0.37.0" date="2026-10-27">
<description> <description>
<p>Saber notebooks (.sbn2, .sba, .sbn) can be imported as new notebooks, with strokes, pen pressure, highlighters, shapes, typed text, images and PDF backgrounds.</p> <p>Saber notebooks (.sbn2, .sba, .sbn) can be imported as new notebooks, with strokes, pen pressure, highlighters, shapes, typed text, images and PDF backgrounds.</p>
+5
View File
@@ -3,6 +3,11 @@
Notebook app for pen, touch and mouse on Linux (tested on Zorin OS 18 / Ubuntu 24.04). Notebook app for pen, touch and mouse on Linux (tested on Zorin OS 18 / Ubuntu 24.04).
### Highlights: ### Highlights:
- **Battery drain fixed**: ink-notes redrew its window at full frame rate even when nothing happened, which kept the app and the desktop (e.g. gnome-shell) busy and drained the battery. It now only draws when something changes; idle CPU load drops to practically zero. Also applies to Windows. Internally, the Android version now follows the app lifecycle and can be packed into an APK (not part of the release yet)
- **PDF export on current lopdf**: The PDF export uses its own small PDF writer on top of lopdf 0.46 instead of the outdated printpdf 0.7 (which pinned lopdf 0.31). Exported PDFs look the same – layers, searchable text, images, highlighters and bookmarks stay as before
- **Windows mouse fix**: The mouse works normally again in the Windows version – Windows Ink reported it as a pen, so clicks and moves went the wrong way. Nothing changes on Linux
- **Windows (experimental)**: `ink-notes_<version>_x86_64.exe` is a portable program for Windows 10/11 – just start it, no installation. Notebooks and settings are stored in `%APPDATA%\ink-notes`, pen input uses Windows Ink, updates replace the `.exe` and take effect at the next start. Not yet tested on real tablet hardware – feedback welcome. Nothing changes on Linux; internally the groundwork for an Android version was laid
- **Sync between devices**: ☰ → Storage location puts the notebooks into a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox (existing notebooks are copied, the originals stay). Changes from other devices show up within seconds while everything local is saved, conflict copies of the sync client become pages of their own, and opening a notebook that is open on another device shows a warning
- **Import from Saber**: ☰ → Import (or dragging the file into the window) now also opens Saber notebooks (`.sbn2` with its asset files next to it, `.sba` archives, old `.sbn`) – strokes with pen pressure, highlighters, shapes, typed text, images and PDF backgrounds - **Import from Saber**: ☰ → Import (or dragging the file into the window) now also opens Saber notebooks (`.sbn2` with its asset files next to it, `.sba` archives, old `.sbn`) – strokes with pen pressure, highlighters, shapes, typed text, images and PDF backgrounds
- **Import from Xournal++ and Rnote**: ☰ → Import (or dragging the file into the window) now also opens Xournal++ (`.xopp`, `.xoj`) and Rnote (`.rnote`) notebooks as new notebooks – strokes with pen pressure, highlighters, shapes, texts, images, paper patterns and Xournal++ PDF backgrounds; PDF pages imported in Rnote become images, infinite Rnote documents an endless notebook - **Import from Xournal++ and Rnote**: ☰ → Import (or dragging the file into the window) now also opens Xournal++ (`.xopp`, `.xoj`) and Rnote (`.rnote`) notebooks as new notebooks – strokes with pen pressure, highlighters, shapes, texts, images, paper patterns and Xournal++ PDF backgrounds; PDF pages imported in Rnote become images, infinite Rnote documents an endless notebook
- **Faster export**: PDF and PNG export and copying a selection as an image are about six times faster and PDFs are up to eight times smaller, because stroke outlines are simplified before export (at most 0.01 mm off; `INK_NOTES_EXACT_OUTLINES=1` exports every point as before) - **Faster export**: PDF and PNG export and copying a selection as an image are about six times faster and PDFs are up to eight times smaller, because stroke outlines are simplified before export (at most 0.01 mm off; `INK_NOTES_EXACT_OUTLINES=1` exports every point as before)
+9 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# ============================================================================== # ==============================================================================
# Haupt-Release-Build-Skript für ink-notes (Zorin OS 18 / Linux) # Haupt-Release-Build-Skript für ink-notes (Zorin OS 18 / Linux)
# Erstellt .deb, .AppImage, SHA256-Prüfsummen und deren Minisign-Signatur in target/ # Erstellt .deb, .AppImage, Windows-.exe, SHA256-Prüfsummen und deren Minisign-Signatur in target/
# ============================================================================== # ==============================================================================
set -euo pipefail set -euo pipefail
@@ -13,6 +13,7 @@ cd "${ROOT_DIR}"
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2) VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
DEB_NAME="ink-notes_${VERSION}_amd64.deb" DEB_NAME="ink-notes_${VERSION}_amd64.deb"
APPIMAGE_NAME="ink-notes_${VERSION}_x86_64.AppImage" APPIMAGE_NAME="ink-notes_${VERSION}_x86_64.AppImage"
EXE_NAME="ink-notes_${VERSION}_x86_64.exe"
CHECKSUM_FILE="SHA256SUMS.txt" CHECKSUM_FILE="SHA256SUMS.txt"
echo "======================================================================" echo "======================================================================"
@@ -25,12 +26,15 @@ echo "======================================================================"
# 2. AppImage bauen (.AppImage) # 2. AppImage bauen (.AppImage)
"${SCRIPT_DIR}/package-appimage.sh" "${SCRIPT_DIR}/package-appimage.sh"
# 3. Checksums berechnen # 3. Portable Windows program (.exe)
"${SCRIPT_DIR}/package-windows.sh"
# 4. Checksums berechnen
echo "=== Berechne SHA256-Prüfsummen in target/${CHECKSUM_FILE} ===" echo "=== Berechne SHA256-Prüfsummen in target/${CHECKSUM_FILE} ==="
cd "${ROOT_DIR}/target" cd "${ROOT_DIR}/target"
sha256sum "${DEB_NAME}" "${APPIMAGE_NAME}" > "${CHECKSUM_FILE}" sha256sum "${DEB_NAME}" "${APPIMAGE_NAME}" "${EXE_NAME}" > "${CHECKSUM_FILE}"
# 4. Prüfsummen signieren (Pflicht für In-App-Updates) # 5. Prüfsummen signieren (Pflicht für In-App-Updates)
# Signiert wird mit rsign2 (minisign-kompatibles Format): Der Schlüssel wurde mit # Signiert wird mit rsign2 (minisign-kompatibles Format): Der Schlüssel wurde mit
# `rsign generate -W` erzeugt; das minisign-CLI kann ihn ohne Terminal nicht laden. # `rsign generate -W` erzeugt; das minisign-CLI kann ihn ohne Terminal nicht laden.
SIGNATURE_FILE="${CHECKSUM_FILE}.minisig" SIGNATURE_FILE="${CHECKSUM_FILE}.minisig"
@@ -73,7 +77,7 @@ fi
echo "======================================================================" echo "======================================================================"
echo "Release-Artefakte für v${VERSION} erfolgreich erstellt:" echo "Release-Artefakte für v${VERSION} erfolgreich erstellt:"
echo "======================================================================" echo "======================================================================"
ls -lh "${DEB_NAME}" "${APPIMAGE_NAME}" "${CHECKSUM_FILE}" ls -lh "${DEB_NAME}" "${APPIMAGE_NAME}" "${EXE_NAME}" "${CHECKSUM_FILE}"
if [ -f "${SIGNATURE_FILE}" ]; then ls -lh "${SIGNATURE_FILE}"; fi if [ -f "${SIGNATURE_FILE}" ]; then ls -lh "${SIGNATURE_FILE}"; fi
echo "" echo ""
echo "Inhalt von target/${CHECKSUM_FILE}:" echo "Inhalt von target/${CHECKSUM_FILE}:"
+94
View File
@@ -0,0 +1,94 @@
#!/usr/bin/env bash
# ==============================================================================
# Builds the Android app target/ink-notes_<version>_arm64.apk (Issues #42, #45)
# without Gradle: the Rust library is built as cdylib with the NDK, aapt2 links the
# manifest and the icon, zipalign and apksigner finish the APK.
#
# Needs the Android SDK (build-tools, platform android-34) and the NDK:
# ANDROID_HOME SDK folder (default: ~/android-sdk)
# ANDROID_NDK_HOME NDK folder (default: newest in $ANDROID_HOME/ndk)
#
# Signing key (all three, otherwise the debug key ~/.android/debug.keystore is used and
# created if missing; such an APK is only meant for testing):
# ANDROID_KEYSTORE, ANDROID_KEYSTORE_PASS, ANDROID_KEY_ALIAS
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${ROOT_DIR}"
TARGET="aarch64-linux-android"
ABI="arm64-v8a"
MIN_SDK=26
TARGET_SDK=34
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
IFS=. read -r MAJOR MINOR PATCH <<<"${VERSION%%-*}"
VERSION_CODE=$((MAJOR * 10000 + MINOR * 100 + PATCH))
APK_NAME="ink-notes_${VERSION}_arm64.apk"
ANDROID_HOME="${ANDROID_HOME:-${HOME}/android-sdk}"
if [ -z "${ANDROID_NDK_HOME:-}" ]; then
ANDROID_NDK_HOME=$(ls -d "${ANDROID_HOME}"/ndk/*/ 2>/dev/null | sort -V | tail -n1)
fi
BUILD_TOOLS=$(ls -d "${ANDROID_HOME}"/build-tools/*/ 2>/dev/null | sort -V | tail -n1)
ANDROID_JAR="${ANDROID_HOME}/platforms/android-${TARGET_SDK}/android.jar"
NDK_BIN="${ANDROID_NDK_HOME%/}/toolchains/llvm/prebuilt/linux-x86_64/bin"
for needed in "${NDK_BIN}/${TARGET}${MIN_SDK}-clang" "${BUILD_TOOLS}aapt2" "${ANDROID_JAR}"; do
if [ ! -e "${needed}" ]; then
echo "FEHLER: ${needed} nicht gefunden (Android-SDK/NDK, siehe Kopf des Skripts)."
exit 1
fi
done
if command -v rustup >/dev/null 2>&1; then
rustup target add "${TARGET}"
fi
echo "=== [1/4] Baue libink_notes.so (${TARGET}) ==="
export CC_aarch64_linux_android="${NDK_BIN}/${TARGET}${MIN_SDK}-clang"
export AR_aarch64_linux_android="${NDK_BIN}/llvm-ar"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${NDK_BIN}/${TARGET}${MIN_SDK}-clang"
cargo rustc --release --lib --crate-type cdylib --target "${TARGET}"
LIB="${CARGO_TARGET_DIR:-target}/${TARGET}/release/libink_notes.so"
echo "=== [2/4] Ressourcen und Manifest ==="
WORK="target/android-apk"
rm -rf "${WORK}"
mkdir -p "${WORK}/res/mipmap-xxxhdpi" "${WORK}/compiled" "${WORK}/apk/lib/${ABI}"
cp assets/ink-notes.png "${WORK}/res/mipmap-xxxhdpi/ic_launcher.png"
sed -e "s/@VERSION_CODE@/${VERSION_CODE}/" -e "s/@VERSION@/${VERSION}/" \
packaging/android/AndroidManifest.xml >"${WORK}/AndroidManifest.xml"
"${BUILD_TOOLS}aapt2" compile --dir "${WORK}/res" -o "${WORK}/compiled/res.zip"
"${BUILD_TOOLS}aapt2" link -o "${WORK}/unaligned.apk" -I "${ANDROID_JAR}" \
--manifest "${WORK}/AndroidManifest.xml" \
--min-sdk-version "${MIN_SDK}" --target-sdk-version "${TARGET_SDK}" \
"${WORK}/compiled/res.zip"
echo "=== [3/4] Native Bibliothek hinzufügen ==="
cp "${LIB}" "${WORK}/apk/lib/${ABI}/"
(cd "${WORK}/apk" && zip -q -r ../unaligned.apk lib)
"${BUILD_TOOLS}zipalign" -f -p 4 "${WORK}/unaligned.apk" "${WORK}/aligned.apk"
echo "=== [4/4] Signieren ==="
if [ -n "${ANDROID_KEYSTORE:-}" ] && [ -n "${ANDROID_KEYSTORE_PASS:-}" ] && [ -n "${ANDROID_KEY_ALIAS:-}" ]; then
KEYSTORE="${ANDROID_KEYSTORE}"
KEY_ALIAS="${ANDROID_KEY_ALIAS}"
export KS_PASS="${ANDROID_KEYSTORE_PASS}"
else
KEYSTORE="${HOME}/.android/debug.keystore"
KEY_ALIAS="androiddebugkey"
export KS_PASS="android"
if [ ! -f "${KEYSTORE}" ]; then
mkdir -p "$(dirname "${KEYSTORE}")"
keytool -genkeypair -keystore "${KEYSTORE}" -storepass android -keypass android \
-alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=Android Debug,O=Android,C=US"
fi
echo "Hinweis: Signiert mit dem Debug-Schlüssel ${KEYSTORE} (nur zum Testen)."
fi
"${BUILD_TOOLS}apksigner" sign --ks "${KEYSTORE}" --ks-key-alias "${KEY_ALIAS}" \
--ks-pass env:KS_PASS --key-pass env:KS_PASS \
--out "target/${APK_NAME}" "${WORK}/aligned.apk"
"${BUILD_TOOLS}apksigner" verify "target/${APK_NAME}"
ls -lh "target/${APK_NAME}"
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# ==============================================================================
# Builds the portable Windows program target/ink-notes_<version>_x86_64.exe (Issue #48)
# by cross-compiling on Linux. Needs the MinGW-w64 compiler
# (Debian/Ubuntu: gcc-mingw-w64-x86-64) for the C parts of the dependencies.
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${ROOT_DIR}"
TARGET="x86_64-pc-windows-gnu"
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
EXE_NAME="ink-notes_${VERSION}_x86_64.exe"
if ! command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1; then
echo "FEHLER: x86_64-w64-mingw32-gcc nicht gefunden (Paket gcc-mingw-w64-x86-64)."
exit 1
fi
if command -v rustup >/dev/null 2>&1; then
rustup target add "${TARGET}"
fi
echo "=== Baue ${EXE_NAME} ==="
cargo build --release --target "${TARGET}"
cp "${CARGO_TARGET_DIR:-target}/${TARGET}/release/ink-notes.exe" "target/${EXE_NAME}"
ls -lh "target/${EXE_NAME}"
+4 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# ============================================================================== # ==============================================================================
# Veröffentlicht ein Release auf dem Gitea-Server (gitea.pansi.eu) # Veröffentlicht ein Release auf dem Gitea-Server (gitea.pansi.eu)
# Lädt .deb, .AppImage, SHA256SUMS.txt und SHA256SUMS.txt.minisig idempotent als Release-Assets hoch. # Lädt .deb, .AppImage, .exe, SHA256SUMS.txt und SHA256SUMS.txt.minisig idempotent als Release-Assets hoch.
# ============================================================================== # ==============================================================================
set -euo pipefail set -euo pipefail
@@ -32,6 +32,7 @@ RELEASE_TITLE="ink-notes ${TAG_NAME}"
DEB_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_amd64.deb" DEB_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_amd64.deb"
APPIMAGE_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_x86_64.AppImage" APPIMAGE_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_x86_64.AppImage"
EXE_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_x86_64.exe"
CHECKSUMS_FILE="${ROOT_DIR}/target/SHA256SUMS.txt" CHECKSUMS_FILE="${ROOT_DIR}/target/SHA256SUMS.txt"
SIGNATURE_FILE="${CHECKSUMS_FILE}.minisig" SIGNATURE_FILE="${CHECKSUMS_FILE}.minisig"
TEMPLATE_FILE="${ROOT_DIR}/packaging/release-notes.md.tmpl" TEMPLATE_FILE="${ROOT_DIR}/packaging/release-notes.md.tmpl"
@@ -42,7 +43,7 @@ if [ ! -f "${TEMPLATE_FILE}" ]; then
fi fi
# Sicherstellen, dass die Artefakte existieren # Sicherstellen, dass die Artefakte existieren
if [ ! -f "${DEB_FILE}" ] || [ ! -f "${APPIMAGE_FILE}" ] || [ ! -f "${CHECKSUMS_FILE}" ]; then if [ ! -f "${DEB_FILE}" ] || [ ! -f "${APPIMAGE_FILE}" ] || [ ! -f "${EXE_FILE}" ] || [ ! -f "${CHECKSUMS_FILE}" ]; then
echo "Artefakte nicht vollständig gefunden. Führe build-release.sh aus..." echo "Artefakte nicht vollständig gefunden. Führe build-release.sh aus..."
"${SCRIPT_DIR}/build-release.sh" "${SCRIPT_DIR}/build-release.sh"
fi fi
@@ -236,6 +237,7 @@ except Exception:
upload_asset "${DEB_FILE}" upload_asset "${DEB_FILE}"
upload_asset "${APPIMAGE_FILE}" upload_asset "${APPIMAGE_FILE}"
upload_asset "${EXE_FILE}"
upload_asset "${CHECKSUMS_FILE}" upload_asset "${CHECKSUMS_FILE}"
upload_asset "${SIGNATURE_FILE}" upload_asset "${SIGNATURE_FILE}"
+1626 -347
View File
File diff suppressed because it is too large. Load diff
+3 -15
View File
@@ -690,21 +690,9 @@ impl AutosaveController {
/// Liefert das Verzeichnis für Notfall-Wiederherstellungsdateien ($XDG_DATA_HOME/ink-notes/recovery). /// Liefert das Verzeichnis für Notfall-Wiederherstellungsdateien ($XDG_DATA_HOME/ink-notes/recovery).
pub fn recovery_dir() -> PathBuf { pub fn recovery_dir() -> PathBuf {
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") { crate::paths::data_dir()
if !xdg.is_empty() { .map(|d| d.join("recovery"))
return PathBuf::from(xdg).join("ink-notes").join("recovery"); .unwrap_or_else(|| PathBuf::from(".").join(".recovery"))
}
}
if let Ok(home) = std::env::var("HOME") {
if !home.is_empty() {
return PathBuf::from(home)
.join(".local")
.join("share")
.join("ink-notes")
.join("recovery");
}
}
PathBuf::from(".").join(".recovery")
} }
impl Drop for AutosaveController { impl Drop for AutosaveController {
+43 -5
View File
@@ -165,7 +165,10 @@ struct NeighborPage {
} }
pub struct CanvasState { pub struct CanvasState {
pub surface: wgpu::Surface<'static>, /// Drawing surface of the window; `None` while the app is in the background on Android
/// (the native window only exists between `Resumed` and `Suspended`)
surface: Option<wgpu::Surface<'static>>,
instance: wgpu::Instance,
/// Verwendeter Grafikadapter (für erneute Abfrage der Surface-Fähigkeiten bei Größenänderung) /// Verwendeter Grafikadapter (für erneute Abfrage der Surface-Fähigkeiten bei Größenänderung)
adapter: wgpu::Adapter, adapter: wgpu::Adapter,
/// Multisampling der Zeichenfläche (1 = aus) und das zugehörige Zwischenbild /// Multisampling der Zeichenfläche (1 = aus) und das zugehörige Zwischenbild
@@ -591,7 +594,8 @@ impl CanvasState {
let egui_renderer = egui_wgpu::Renderer::new(&device, render_format(&config), None, 1); let egui_renderer = egui_wgpu::Renderer::new(&device, render_format(&config), None, 1);
Ok(Self { Ok(Self {
surface, surface: Some(surface),
instance,
adapter, adapter,
msaa_samples, msaa_samples,
msaa_view, msaa_view,
@@ -727,14 +731,42 @@ impl CanvasState {
self.update_uniforms(); self.update_uniforms();
} }
/// Releases the drawing surface: on Android the native window goes away when the app
/// is sent to the background (`Event::Suspended`). Drawing is skipped until [`Self::resume`].
pub fn suspend(&mut self) {
self.surface = None;
}
/// Creates the drawing surface again for the window (`Event::Resumed` on Android).
pub fn resume(&mut self, window: Arc<Window>) -> Result<(), Box<dyn std::error::Error>> {
if self.surface.is_some() {
return Ok(());
}
let surface = self.instance.create_surface(window.clone())?;
if !surface
.get_capabilities(&self.adapter)
.formats
.contains(&self.config.format)
{
return Err("surface format changed".into());
}
self.surface = Some(surface);
// Configures the new surface (the window may have changed size meanwhile)
self.resize(window.inner_size());
Ok(())
}
/// Passt die Surface und Projektionsmatrizen an eine neue Fenstergröße an. /// Passt die Surface und Projektionsmatrizen an eine neue Fenstergröße an.
pub fn resize(&mut self, new_size: PhysicalSize<u32>) { pub fn resize(&mut self, new_size: PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 { if new_size.width > 0 && new_size.height > 0 {
self.size = new_size; self.size = new_size;
self.config.width = new_size.width; self.config.width = new_size.width;
self.config.height = new_size.height; self.config.height = new_size.height;
let Some(surface) = &self.surface else {
return;
};
// Fähigkeiten neu abfragen: Ein nicht (mehr) angebotener Modus führt in wgpu zum Absturz // Fähigkeiten neu abfragen: Ein nicht (mehr) angebotener Modus führt in wgpu zum Absturz
let caps = self.surface.get_capabilities(&self.adapter); let caps = surface.get_capabilities(&self.adapter);
if !caps.present_modes.contains(&self.config.present_mode) { if !caps.present_modes.contains(&self.config.present_mode) {
match choose_present_mode(&caps.present_modes) { match choose_present_mode(&caps.present_modes) {
Some(mode) => self.config.present_mode = mode, Some(mode) => self.config.present_mode = mode,
@@ -750,7 +782,7 @@ impl CanvasState {
} }
} }
} }
self.surface.configure(&self.device, &self.config); surface.configure(&self.device, &self.config);
self.msaa_view = create_msaa_view(&self.device, &self.config, self.msaa_samples); self.msaa_view = create_msaa_view(&self.device, &self.config, self.msaa_samples);
self.stencil_view = create_stencil_view(&self.device, &self.config, self.msaa_samples); self.stencil_view = create_stencil_view(&self.device, &self.config, self.msaa_samples);
self.recalculate_viewport(); self.recalculate_viewport();
@@ -1386,7 +1418,13 @@ impl CanvasState {
.update_texture(&self.device, &self.queue, *id, image_delta); .update_texture(&self.device, &self.queue, *id, image_delta);
} }
let output = self.surface.get_current_texture()?; let Some(surface) = &self.surface else {
for id in &textures_delta.free {
self.egui_renderer.free_texture(id);
}
return Ok(());
};
let output = surface.get_current_texture()?;
let view = output.texture.create_view(&wgpu::TextureViewDescriptor { let view = output.texture.create_view(&wgpu::TextureViewDescriptor {
format: Some(render_format(&self.config)), format: Some(render_format(&self.config)),
..Default::default() ..Default::default()
+574
View File
@@ -0,0 +1,574 @@
//! Notices changes that another device made to the open notebook through a sync client
//! such as Nextcloud or Google Drive (Issue #49).
//!
//! Every few seconds the notebook folder is scanned (only file times and sizes). Pages whose
//! file changed are compared with the page in memory and reloaded if they differ; a changed
//! page order, new or removed pages and titles from the manifest are taken over; conflict
//! copies made by sync clients (`page_3 (conflicted copy …).json`, `page_3 (1).json`,
//! `page_3.sync-conflict-….json`) become pages of their own, so nothing is lost. The check
//! only runs while all local changes are saved, so it never overwrites anything unsaved.
use std::collections::{HashMap, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant, SystemTime};
use crate::document::{Notebook, Page, PageBackground};
use crate::storage::{self, NotebookManifest, OpenMarker, PageData};
/// Time between two checks.
pub const INTERVAL: Duration = Duration::from_secs(3);
/// Modification time, size and, for small files, a hash of the content.
type Fingerprint = (Option<SystemTime>, u64, Option<u64>);
/// Files up to this size are also compared by content: file times are only as fine as the
/// kernel clock tick, so a file rewritten right after a check with the same length (e.g. a
/// manifest with one page replaced by another) would otherwise look unchanged.
const HASHED_FILE_SIZE: u64 = 64 * 1024;
fn content_hash(path: &Path) -> Option<u64> {
use std::hash::{Hash, Hasher};
let bytes = fs::read(path).ok()?;
let mut hasher = std::collections::hash_map::DefaultHasher::new();
bytes.hash(&mut hasher);
Some(hasher.finish())
}
/// What a check found and took over.
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Outcome {
/// Pages reloaded because their file changed
pub reloaded_pages: usize,
/// Pages added, removed, reordered or retitled through the manifest
pub structure_changed: bool,
/// Ids of the conflict copies added as pages (they need saving)
pub conflict_pages: Vec<u64>,
/// Another device has just opened the notebook
pub opened_elsewhere: Option<OpenMarker>,
}
impl Outcome {
pub fn is_empty(&self) -> bool {
*self == Outcome::default()
}
}
pub struct DiskWatch {
pub dir: PathBuf,
known: HashMap<String, Fingerprint>,
/// Files that are neither pages nor conflict copies we could read
ignored: HashSet<String>,
next_check: Instant,
}
/// Fingerprints of the JSON files in the notebook folder.
fn scan(dir: &Path) -> HashMap<String, Fingerprint> {
let Ok(entries) = fs::read_dir(dir) else {
return HashMap::new();
};
entries
.flatten()
.filter_map(|entry| {
let name = entry.file_name().to_string_lossy().into_owned();
if !name.ends_with(".json") {
return None;
}
let meta = entry.metadata().ok()?;
if !meta.is_file() {
return None;
}
let hash = (meta.len() <= HASHED_FILE_SIZE)
.then(|| content_hash(&entry.path()))
.flatten();
Some((name, (meta.modified().ok(), meta.len(), hash)))
})
.collect()
}
/// Page id of a regular page file (`page_<id>.json`).
fn page_file_id(name: &str) -> Option<u64> {
name.strip_prefix("page_")?
.strip_suffix(".json")?
.parse()
.ok()
}
/// Page id a conflict copy belongs to: `page_<id>` followed by something else.
pub fn conflict_copy_of(name: &str) -> Option<u64> {
if page_file_id(name).is_some() {
return None;
}
let rest = name.strip_prefix("page_")?.strip_suffix(".json")?;
let digits: String = rest.chars().take_while(char::is_ascii_digit).collect();
let tail = &rest[digits.len()..];
let marked =
tail.starts_with(" (") || tail.starts_with(".sync-conflict") || tail.starts_with('_');
(marked && !digits.is_empty())
.then(|| digits.parse().ok())
.flatten()
}
/// Page content without the format version (that differs between app versions).
fn content(mut data: PageData) -> PageData {
data.format_version = 0;
data
}
impl DiskWatch {
pub fn new(dir: PathBuf, now: Instant) -> Self {
Self {
known: scan(&dir),
dir,
ignored: HashSet::new(),
next_check: now + INTERVAL,
}
}
pub fn deadline(&self) -> Instant {
self.next_check
}
pub fn is_due(&self, now: Instant) -> bool {
now >= self.next_check
}
/// Skips the check that is due now (e.g. while drawing).
pub fn postpone(&mut self, now: Instant) {
self.next_check = now + INTERVAL;
}
/// Checks right away at the next opportunity (e.g. when the window gets the focus).
pub fn check_soon(&mut self, now: Instant) {
self.next_check = now;
}
/// Takes over what changed on disk. Call only while all local changes are saved.
pub fn check(
&mut self,
notebook: &mut Notebook,
manifest: &mut NotebookManifest,
now: Instant,
) -> Outcome {
self.next_check = now + INTERVAL;
let mut outcome = Outcome::default();
let current = scan(&self.dir);
let changed = |name: &str| current.get(name) != self.known.get(name);
let mut retry: HashSet<String> = HashSet::new();
if changed(storage::OPEN_MARKER_FILE) {
outcome.opened_elsewhere = fs::read(self.dir.join(storage::OPEN_MARKER_FILE))
.ok()
.and_then(|b| serde_json::from_slice::<OpenMarker>(&b).ok())
.filter(|m| m.device != storage::device_name());
}
// Page order, titles, new and removed pages
let mut fresh_pages: HashSet<u64> = HashSet::new();
if changed("manifest.json") {
match storage::load_manifest(&self.dir) {
Ok(theirs) => match self.apply_manifest(notebook, manifest, theirs) {
Ok(Some(new_ids)) => {
fresh_pages = new_ids;
outcome.structure_changed = true;
}
Ok(None) => {}
Err(()) => {
retry.insert("manifest.json".to_string());
}
},
Err(_) => {
retry.insert("manifest.json".to_string());
}
}
}
// Changed page files
for name in current.keys().filter(|n| changed(n)) {
let Some(id) = page_file_id(name) else {
continue;
};
let Some(page) = notebook.pages.iter_mut().find(|p| p.id == id) else {
continue;
};
if !page.is_loaded || fresh_pages.contains(&id) {
continue;
}
match storage::load_page(&self.dir, id) {
Ok(data) => {
if content(PageData::from(&*page)) != content(data.clone()) {
let mut reloaded = data.to_page();
reloaded.title = reloaded.title.or_else(|| page.title.clone());
*page = reloaded;
outcome.reloaded_pages += 1;
}
}
// Possibly still being written by the sync client: try again next time
Err(_) => {
retry.insert(name.clone());
}
}
}
// Conflict copies of sync clients become pages of their own
let mut copies: Vec<&String> = current
.keys()
.filter(|n| !self.ignored.contains(*n))
.filter(|n| conflict_copy_of(n).is_some())
.collect();
copies.sort();
for name in copies {
let path = self.dir.join(name);
let data = fs::read(&path)
.ok()
.and_then(|b| serde_json::from_slice::<PageData>(&b).ok());
match data {
Some(data) => {
let of = conflict_copy_of(name).unwrap_or(0);
outcome
.conflict_pages
.push(add_conflict_page(notebook, data, of));
// Keep the file, but don't take it over again
let _ = fs::rename(&path, path.with_extension("json.imported"));
}
None => {
self.ignored.insert(name.clone());
}
}
}
if !outcome.conflict_pages.is_empty() {
manifest.sync_from_notebook(notebook);
}
// Remember what we have seen, except files to look at again
let mut known = current;
for name in retry {
match self.known.get(&name) {
Some(old) => known.insert(name, *old),
None => known.remove(&name),
};
}
self.known = known;
outcome
}
/// Takes over the page list of a manifest written elsewhere. Returns the ids of pages
/// that are now unloaded placeholders, or `None` if nothing about the pages changed.
/// Fails (to be tried again) while the page to show can't be read yet.
fn apply_manifest(
&self,
notebook: &mut Notebook,
manifest: &mut NotebookManifest,
theirs: NotebookManifest,
) -> Result<Option<HashSet<u64>>, ()> {
let mut ours = manifest.clone();
ours.sync_from_notebook(notebook);
if ours.pages == theirs.pages && ours.title == theirs.title {
return Ok(None);
}
let current_id = notebook.current_page().id;
// The page shown afterwards must be loaded. Read it before changing anything: a file
// the sync client is still writing must not end up set aside as damaged.
let shown = theirs
.pages
.iter()
.find(|m| m.id == current_id)
.or(theirs.pages.first())
.map(|m| m.id);
let mut shown_data = None;
if let Some(id) = shown {
if !notebook.pages.iter().any(|p| p.id == id && p.is_loaded) {
match storage::load_page(&self.dir, id) {
Ok(data) => shown_data = Some(data),
// Never saved because still empty
Err(storage::StorageError::PageNotFound(_)) => {}
Err(_) => return Err(()),
}
}
}
let mut old: HashMap<u64, Page> = notebook.pages.drain(..).map(|p| (p.id, p)).collect();
let mut placeholders = HashSet::new();
for meta in &theirs.pages {
let background = meta.background.unwrap_or(PageBackground::Grid5mm);
let size = storage::page_size_from(meta.size);
let mut page = match old.remove(&meta.id) {
Some(mut page) => {
page.background = background;
page.size = size;
page
}
None => {
placeholders.insert(meta.id);
Page::new_unloaded(meta.id, background).with_size(size)
}
};
page.title = meta.title.clone();
notebook.pages.push(page);
}
if notebook.pages.is_empty() {
notebook.pages.push(Page::new(1, PageBackground::Grid5mm));
}
notebook.current_page_index = notebook
.pages
.iter()
.position(|p| p.id == current_id)
.unwrap_or(0)
.min(notebook.pages.len() - 1);
notebook.next_page_id = notebook.next_page_id.max(theirs.next_page_id);
notebook.next_stroke_id = notebook.next_stroke_id.max(theirs.next_stroke_id);
let index = notebook.current_page_index;
if !notebook.pages[index].is_loaded {
let page = &mut notebook.pages[index];
let mut loaded = match shown_data {
Some(data) => data.to_page(),
None => Page::new(page.id, page.background).with_size(page.size),
};
loaded.title = loaded.title.or(page.title.take());
*page = loaded;
placeholders.remove(&page.id);
}
let layout = manifest.layout;
*manifest = theirs;
manifest.layout = manifest.layout.or(layout);
manifest.sync_from_notebook(notebook);
Ok(Some(placeholders))
}
}
/// Adds a conflict copy as a new page after page `of` (or at the end), with fresh ids.
/// Returns the id of the new page.
fn add_conflict_page(notebook: &mut Notebook, mut data: PageData, of: u64) -> u64 {
let id = notebook.next_page_id;
data.id = id;
notebook.next_page_id += 1;
for stroke in &mut data.strokes {
stroke.id = notebook.next_stroke_id;
notebook.next_stroke_id += 1;
}
let original = notebook.pages.iter().position(|p| p.id == of);
let title = original
.and_then(|i| notebook.pages[i].title.clone())
.or(data.title.take());
data.title = Some(match title {
Some(title) => crate::t!("Konfliktkopie: {title}", title = title).to_string(),
None => crate::t!("Konfliktkopie").to_string(),
});
let page = data.to_page();
let at = original.map_or(notebook.pages.len(), |i| i + 1);
notebook.pages.insert(at, page);
if at <= notebook.current_page_index {
notebook.current_page_index += 1;
}
id
}
#[cfg(test)]
mod tests {
use super::*;
use crate::document::{Stroke, StylusSample};
fn stroke(id: u64, y: f32) -> Stroke {
let points = (0..5)
.map(|i| StylusSample {
position: glam::Vec2::new(100.0 + 50.0 * i as f32, y),
pressure: 0.5,
timestamp: 0.0,
})
.collect();
Stroke::new(id, points, Vec::new(), [0.0, 0.0, 0.0, 1.0])
}
/// Saved notebook with one stroke on its only page.
fn saved_notebook(dir: &Path) -> (Notebook, NotebookManifest) {
let mut notebook = Notebook::new();
notebook.current_page_mut().add_stroke(stroke(1, 100.0));
notebook.next_stroke_id = 2;
let mut manifest = NotebookManifest::new("nb", "Mathe");
storage::save_notebook(dir, &notebook, &mut manifest).unwrap();
(notebook, manifest)
}
#[test]
fn test_conflict_copy_names() {
assert_eq!(
conflict_copy_of("page_3 (conflicted copy 2026-10-27).json"),
Some(3)
);
assert_eq!(conflict_copy_of("page_12 (1).json"), Some(12));
assert_eq!(
conflict_copy_of("page_3.sync-conflict-20261027-1200-ABC.json"),
Some(3)
);
assert_eq!(conflict_copy_of("page_3_conflict.json"), Some(3));
assert_eq!(conflict_copy_of("page_3.json"), None);
assert_eq!(conflict_copy_of("page_x (1).json"), None);
assert_eq!(conflict_copy_of("manifest (1).json"), None);
assert_eq!(conflict_copy_of("page_3.json.imported"), None);
}
#[test]
fn test_own_saves_are_not_reported() {
let dir = tempfile::tempdir().unwrap();
let (mut notebook, mut manifest) = saved_notebook(dir.path());
let now = Instant::now();
let mut watch = DiskWatch::new(dir.path().to_path_buf(), now);
notebook.current_page_mut().add_stroke(stroke(2, 200.0));
notebook.add_page(PageBackground::Blank);
storage::save_notebook(dir.path(), &notebook, &mut manifest).unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert!(outcome.is_empty(), "{outcome:?}");
assert_eq!(notebook.pages.len(), 2);
}
#[test]
fn test_changes_from_another_device_are_taken_over() {
let dir = tempfile::tempdir().unwrap();
let (mut notebook, mut manifest) = saved_notebook(dir.path());
let now = Instant::now();
let mut watch = DiskWatch::new(dir.path().to_path_buf(), now);
assert!(!watch.is_due(now));
// The other device adds a stroke on page 1 and a second page with a title
let (mut theirs, mut their_manifest) = storage::load_notebook(dir.path()).unwrap();
theirs.current_page_mut().add_stroke(stroke(5, 300.0));
let index = theirs.add_page(PageBackground::Lined);
theirs.pages[index].add_stroke(stroke(6, 400.0));
theirs.pages[index].title = Some("Übung".to_string());
theirs.next_stroke_id = 7;
storage::save_notebook(dir.path(), &theirs, &mut their_manifest).unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert_eq!(outcome.reloaded_pages, 1);
assert!(outcome.structure_changed);
assert!(outcome.conflict_pages.is_empty());
assert_eq!(notebook.pages.len(), 2);
assert_eq!(notebook.pages[0].strokes.len(), 2);
assert_eq!(notebook.pages[1].title.as_deref(), Some("Übung"));
assert_eq!(notebook.pages[1].background, PageBackground::Lined);
assert!(notebook.next_stroke_id >= 7);
assert_eq!(manifest.pages.len(), 2);
// The new page loads from disk when needed
storage::ensure_page_loaded(dir.path(), &mut notebook, 1).unwrap();
assert_eq!(notebook.pages[1].strokes.len(), 1);
// Nothing new: nothing to report
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert!(outcome.is_empty(), "{outcome:?}");
}
#[test]
fn test_page_still_being_synced_is_tried_again() {
let dir = tempfile::tempdir().unwrap();
let (mut notebook, mut manifest) = saved_notebook(dir.path());
let now = Instant::now();
let mut watch = DiskWatch::new(dir.path().to_path_buf(), now);
// Elsewhere page 1 was deleted and page 2 added; its file is still half written
let (mut theirs, mut their_manifest) = storage::load_notebook(dir.path()).unwrap();
let index = theirs.add_page(PageBackground::Blank);
theirs.pages[index].add_stroke(stroke(9, 100.0));
storage::save_notebook(dir.path(), &theirs, &mut their_manifest).unwrap();
their_manifest.pages.remove(0);
storage::save_manifest(dir.path(), &their_manifest).unwrap();
let page_file = dir.path().join("page_2.json");
let complete = fs::read(&page_file).unwrap();
fs::write(&page_file, &complete[..complete.len() / 2]).unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert!(outcome.is_empty(), "{outcome:?}");
assert_eq!(notebook.pages.len(), 1);
assert_eq!(notebook.pages[0].id, 1);
assert!(page_file.exists(), "must not be set aside as damaged");
fs::write(&page_file, &complete).unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert!(outcome.structure_changed);
assert_eq!(notebook.pages.len(), 1);
assert_eq!(notebook.current_page().id, 2);
assert!(notebook.current_page().is_loaded);
assert_eq!(notebook.current_page().strokes.len(), 1);
}
#[test]
fn test_conflict_copy_becomes_a_page() {
let dir = tempfile::tempdir().unwrap();
let (mut notebook, mut manifest) = saved_notebook(dir.path());
notebook.add_page(PageBackground::Blank);
notebook.current_page_index = 1;
storage::save_notebook(dir.path(), &notebook, &mut manifest).unwrap();
let now = Instant::now();
let mut watch = DiskWatch::new(dir.path().to_path_buf(), now);
let mut copy = PageData::from(&notebook.pages[0]);
copy.strokes.push(
PageData::from(&{
let mut page = Page::new(1, PageBackground::Blank);
page.add_stroke(stroke(1, 500.0));
page
})
.strokes[0]
.clone(),
);
let name = "page_1 (conflicted copy 2026-10-27).json";
fs::write(dir.path().join(name), serde_json::to_vec(&copy).unwrap()).unwrap();
fs::write(dir.path().join("page_2 (1).json"), b"{ kaputt").unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert_eq!(outcome.conflict_pages.len(), 1);
assert_eq!(notebook.pages.len(), 3);
let added = &notebook.pages[1];
assert_eq!(added.id, outcome.conflict_pages[0]);
assert_eq!(added.strokes.len(), 2);
assert!(added.title.is_some());
// Fresh ids, no clash with the original page
assert!(added.strokes.iter().all(|s| s.id >= 2));
assert_eq!(notebook.pages[0].strokes.len(), 1);
// The current page stays the same
assert_eq!(notebook.current_page_index, 2);
assert_eq!(manifest.pages.len(), 3);
assert!(!dir.path().join(name).exists());
assert!(dir.path().join(format!("{name}.imported")).exists());
// Taken over only once; the unreadable file is left alone
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert!(outcome.is_empty(), "{outcome:?}");
assert!(dir.path().join("page_2 (1).json").exists());
}
#[test]
fn test_open_marker() {
let dir = tempfile::tempdir().unwrap();
let (mut notebook, mut manifest) = saved_notebook(dir.path());
let marker_path = dir.path().join(storage::OPEN_MARKER_FILE);
let foreign = OpenMarker {
device: "tablet-of-pia".to_string(),
since: 1,
};
fs::write(&marker_path, serde_json::to_vec(&foreign).unwrap()).unwrap();
// Opening warns about the other device and puts our own marker in place
let lock = storage::NotebookLock::acquire(dir.path()).unwrap();
assert_eq!(lock.open_elsewhere.as_ref(), Some(&foreign));
let ours: OpenMarker = serde_json::from_slice(&fs::read(&marker_path).unwrap()).unwrap();
assert_eq!(ours.device, storage::device_name());
// The other device opens it again
let now = Instant::now();
let mut watch = DiskWatch::new(dir.path().to_path_buf(), now);
fs::write(&marker_path, serde_json::to_vec(&foreign).unwrap()).unwrap();
let outcome = watch.check(&mut notebook, &mut manifest, now);
assert_eq!(outcome.opened_elsewhere, Some(foreign));
// A foreign marker is not removed on closing
drop(lock);
assert!(marker_path.exists());
let lock = storage::NotebookLock::acquire(dir.path()).unwrap();
drop(lock);
assert!(!marker_path.exists());
}
}
+67 -127
View File
@@ -1,4 +1,4 @@
//! Verlustfreier Vektor-PDF-Export des gesamten Notizbuchs via printpdf. //! Verlustfreier Vektor-PDF-Export des gesamten Notizbuchs (PDF-Ausgabe: [`crate::pdf_writer`]).
//! //!
//! Features: //! Features:
//! - Hochformat DIN A4 (210 mm x 297 mm) //! - Hochformat DIN A4 (210 mm x 297 mm)
@@ -8,7 +8,7 @@
//! - Vektor-Hintergründe (Kariert 5mm, Liniert, Punktraster, Blanko) //! - Vektor-Hintergründe (Kariert 5mm, Liniert, Punktraster, Blanko)
//! - Zwei Export-Strategien: //! - Zwei Export-Strategien:
//! - `FilledPolygon`: Glatte gefüllte Polygone aus den Triangle-Strip-Hüllen (variable Pinselstärke) //! - `FilledPolygon`: Glatte gefüllte Polygone aus den Triangle-Strip-Hüllen (variable Pinselstärke)
//! - `BezierCurve`: Glatte kubische Bézier-Kurven via `printpdf::Line` //! - `BezierCurve`: Glatte kubische Bézier-Kurven via `pdf_writer::Line`
use std::collections::HashMap; use std::collections::HashMap;
use std::error::Error; use std::error::Error;
@@ -16,14 +16,15 @@ use std::fs::File;
use std::io::BufWriter; use std::io::BufWriter;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use printpdf::path::{PaintMode, WindingOrder};
use printpdf::{Color, Line, Mm, PdfDocument, PdfDocumentReference, Point, Polygon, Rgb};
use crate::assets::AssetStore; use crate::assets::AssetStore;
use crate::background::{PatternColor, DOT_SIZE, GRID_5MM_SPACING, LINED_SPACING}; use crate::background::{PatternColor, DOT_SIZE, GRID_5MM_SPACING, LINED_SPACING};
use crate::document::{ use crate::document::{
Notebook, Page, PageBackground, Stroke, A4_HEIGHT_MM, A4_WIDTH_MM, PAGE_HEIGHT, PAGE_WIDTH, Notebook, Page, PageBackground, Stroke, A4_HEIGHT_MM, A4_WIDTH_MM, PAGE_HEIGHT, PAGE_WIDTH,
}; };
use crate::pdf_writer::{
Color, Line, Mm, PaintMode, PdfDocument, PdfDocumentReference, Point, Polygon, Rgb,
WindingOrder,
};
use crate::t; use crate::t;
use ab_glyph::Font as _; use ab_glyph::Font as _;
@@ -56,9 +57,7 @@ pub fn default_documents_dir() -> PathBuf {
} }
} }
if let Ok(home) = std::env::var("HOME") { if let Some(home) = crate::paths::home_dir() {
if !home.trim().is_empty() {
let home = PathBuf::from(home);
let user_dirs = let user_dirs =
std::fs::read_to_string(home.join(".config/user-dirs.dirs")).unwrap_or_default(); std::fs::read_to_string(home.join(".config/user-dirs.dirs")).unwrap_or_default();
if let Some(dir) = if let Some(dir) =
@@ -69,7 +68,6 @@ pub fn default_documents_dir() -> PathBuf {
} }
return home.join("Documents"); return home.join("Documents");
} }
}
PathBuf::from(".") PathBuf::from(".")
} }
@@ -150,19 +148,19 @@ fn pdf_page_mm(page: &Page) -> (Mm, Mm) {
/// Beginnt eine Ebene: Koordinaten beziehen sich auf eine A4-hohe Seite (siehe /// Beginnt eine Ebene: Koordinaten beziehen sich auf eine A4-hohe Seite (siehe
/// [`page_to_pdf_mm`]) und werden auf die tatsächliche Höhe von `page` verschoben. /// [`page_to_pdf_mm`]) und werden auf die tatsächliche Höhe von `page` verschoben.
fn begin_page_layer(layer: &printpdf::PdfLayerReference, page: &Page) { fn begin_page_layer(layer: &crate::pdf_writer::PdfLayerReference, page: &Page) {
layer.save_graphics_state(); layer.save_graphics_state();
let dy = (page.size.y - PAGE_HEIGHT) * PT_PER_UNIT; let dy = (page.size.y - PAGE_HEIGHT) * PT_PER_UNIT;
if dy != 0.0 { if dy != 0.0 {
layer.set_ctm(printpdf::CurTransMat::Translate( layer.set_ctm(crate::pdf_writer::CurTransMat::Translate(
printpdf::Pt(0.0), crate::pdf_writer::Pt(0.0),
printpdf::Pt(dy), crate::pdf_writer::Pt(dy),
)); ));
} }
} }
/// Beendet eine mit [`begin_page_layer`] begonnene Ebene. /// Beendet eine mit [`begin_page_layer`] begonnene Ebene.
fn end_page_layer(layer: &printpdf::PdfLayerReference) { fn end_page_layer(layer: &crate::pdf_writer::PdfLayerReference) {
layer.restore_graphics_state(); layer.restore_graphics_state();
} }
@@ -214,7 +212,7 @@ pub fn export_notebook_to_bytes(
return export_notebook_to_bytes(&cropped, strategy, assets, pattern); return export_notebook_to_bytes(&cropped, strategy, assets, pattern);
} }
let doc = generate_pdf_document(notebook, strategy, assets, pattern)?; let doc = generate_pdf_document(notebook, strategy, assets, pattern)?;
let bytes = add_alpha_states(fix_text_encoding(doc.save_to_bytes()?, notebook)?, notebook)?; let bytes = add_alpha_states(doc.save_to_bytes()?, notebook)?;
// Importierte PDF-Seiten als Vektorgrafik unterlegen // Importierte PDF-Seiten als Vektorgrafik unterlegen
let underlays = pdf_underlays(notebook); let underlays = pdf_underlays(notebook);
@@ -240,7 +238,7 @@ pub fn export_notebook_to_bytes(
raster.insert(underlay.target_page); raster.insert(underlay.target_page);
} }
let doc = generate_pdf_document_with(notebook, strategy, assets, pattern, &raster)?; let doc = generate_pdf_document_with(notebook, strategy, assets, pattern, &raster)?;
let bytes = add_alpha_states(fix_text_encoding(doc.save_to_bytes()?, notebook)?, notebook)?; let bytes = add_alpha_states(doc.save_to_bytes()?, notebook)?;
let remaining: Vec<_> = underlays let remaining: Vec<_> = underlays
.into_iter() .into_iter()
.filter(|u| !raster.contains(&u.target_page)) .filter(|u| !raster.contains(&u.target_page))
@@ -252,35 +250,6 @@ pub fn export_notebook_to_bytes(
Ok(merged) Ok(merged)
} }
/// printpdf schreibt Lesezeichen-Titel als rohes UTF-8, PDF-Betrachter lesen Textstrings aber
/// als PDFDocEncoding oder UTF-16BE: Umlaute und Gedankenstriche würden verstümmelt. Titel
/// mit Nicht-ASCII-Zeichen werden deshalb nach UTF-16BE (mit BOM) umgeschrieben.
fn fix_text_encoding(bytes: Vec<u8>, notebook: &Notebook) -> Result<Vec<u8>, Box<dyn Error>> {
let needs_fix = notebook
.pages
.iter()
.filter_map(|p| p.title.as_deref())
.any(|t| !t.is_ascii());
if !needs_fix {
return Ok(bytes);
}
let mut doc = printpdf::lopdf::Document::load_mem(&bytes)?;
for object in doc.objects.values_mut() {
let Ok(dict) = object.as_dict_mut() else {
continue;
};
if let Ok(printpdf::lopdf::Object::String(raw, format)) = dict.get_mut(b"Title") {
if let Some(utf16) = utf16be_text(raw) {
*raw = utf16;
*format = printpdf::lopdf::StringFormat::Hexadecimal;
}
}
}
let mut out = Vec::new();
doc.save_to(&mut out)?;
Ok(out)
}
/// Name des Grafikzustands für halbtransparente Tinte mit Deckkraft `alpha` (auf Prozent /// Name des Grafikzustands für halbtransparente Tinte mit Deckkraft `alpha` (auf Prozent
/// gerundet); `None` für deckende Farben. /// gerundet); `None` für deckende Farben.
fn alpha_state_name(alpha: f32) -> Option<String> { fn alpha_state_name(alpha: f32) -> Option<String> {
@@ -288,12 +257,12 @@ fn alpha_state_name(alpha: f32) -> Option<String> {
(percent < 100).then(|| format!("InkAlpha{percent}")) (percent < 100).then(|| format!("InkAlpha{percent}"))
} }
/// printpdf kann keine Grafikzustände mit Deckkraft anlegen: Die Tintenebene verweist mit /// Grafikzustände mit Deckkraft: Die Tintenebene verweist mit
/// `gs` auf die Namen aus [`alpha_state_name`], die Zustände selbst (`ca`/`CA`) werden hier /// `gs` auf die Namen aus [`alpha_state_name`], die Zustände selbst (`ca`/`CA`) werden hier
/// in die Ressourcen jeder Seite eingetragen. Ohne halbtransparente Striche bleibt das PDF /// in die Ressourcen jeder Seite eingetragen. Ohne halbtransparente Striche bleibt das PDF
/// unverändert. /// unverändert.
fn add_alpha_states(bytes: Vec<u8>, notebook: &Notebook) -> Result<Vec<u8>, Box<dyn Error>> { fn add_alpha_states(bytes: Vec<u8>, notebook: &Notebook) -> Result<Vec<u8>, Box<dyn Error>> {
use printpdf::lopdf::{Dictionary, Object}; use lopdf::{Dictionary, Object};
let mut states: Vec<(String, f32)> = notebook let mut states: Vec<(String, f32)> = notebook
.pages .pages
@@ -308,7 +277,7 @@ fn add_alpha_states(bytes: Vec<u8>, notebook: &Notebook) -> Result<Vec<u8>, Box<
states.sort_by(|a, b| a.0.cmp(&b.0)); states.sort_by(|a, b| a.0.cmp(&b.0));
states.dedup_by(|a, b| a.0 == b.0); states.dedup_by(|a, b| a.0 == b.0);
let mut doc = printpdf::lopdf::Document::load_mem(&bytes)?; let mut doc = lopdf::Document::load_mem(&bytes)?;
let page_ids: Vec<_> = doc.get_pages().into_values().collect(); let page_ids: Vec<_> = doc.get_pages().into_values().collect();
for page_id in page_ids { for page_id in page_ids {
let resources = dict_object_id(&mut doc, page_id, b"Resources")?; let resources = dict_object_id(&mut doc, page_id, b"Resources")?;
@@ -331,11 +300,11 @@ fn add_alpha_states(bytes: Vec<u8>, notebook: &Notebook) -> Result<Vec<u8>, Box<
/// Kennung des Wörterbuchs unter `key` im Objekt `owner`; ein eingebettetes oder fehlendes /// Kennung des Wörterbuchs unter `key` im Objekt `owner`; ein eingebettetes oder fehlendes
/// Wörterbuch wird dafür zu einem eigenen Objekt. /// Wörterbuch wird dafür zu einem eigenen Objekt.
fn dict_object_id( fn dict_object_id(
doc: &mut printpdf::lopdf::Document, doc: &mut lopdf::Document,
owner: printpdf::lopdf::ObjectId, owner: lopdf::ObjectId,
key: &[u8], key: &[u8],
) -> Result<printpdf::lopdf::ObjectId, Box<dyn Error>> { ) -> Result<lopdf::ObjectId, Box<dyn Error>> {
use printpdf::lopdf::{Dictionary, Object}; use lopdf::{Dictionary, Object};
let entry = doc.get_object(owner)?.as_dict()?.get(key).ok().cloned(); let entry = doc.get_object(owner)?.as_dict()?.get(key).ok().cloned();
if let Some(Object::Reference(id)) = entry { if let Some(Object::Reference(id)) = entry {
@@ -352,20 +321,6 @@ fn dict_object_id(
Ok(id) Ok(id)
} }
/// UTF-8-Text als PDF-Textstring in UTF-16BE mit BOM; `None` bei reinem ASCII oder
/// ungültigem UTF-8.
fn utf16be_text(raw: &[u8]) -> Option<Vec<u8>> {
let text = std::str::from_utf8(raw).ok()?;
if text.is_ascii() {
return None;
}
let mut out = vec![0xFE, 0xFF];
for unit in text.encode_utf16() {
out.extend_from_slice(&unit.to_be_bytes());
}
Some(out)
}
/// Unterlagen für alle Seiten mit importierter PDF-Seite. /// Unterlagen für alle Seiten mit importierter PDF-Seite.
fn pdf_underlays(notebook: &Notebook) -> Vec<crate::pdf_merge::Underlay> { fn pdf_underlays(notebook: &Notebook) -> Vec<crate::pdf_merge::Underlay> {
notebook notebook
@@ -390,7 +345,7 @@ fn pdf_underlays(notebook: &Notebook) -> Vec<crate::pdf_merge::Underlay> {
.collect() .collect()
} }
/// Generiert das `printpdf::PdfDocumentReference` für alle Seiten des Notizbuchs. /// Generiert das `crate::pdf_writer::PdfDocumentReference` für alle Seiten des Notizbuchs.
/// Importierte PDF-Seiten sind darin noch nicht enthalten; die legt /// Importierte PDF-Seiten sind darin noch nicht enthalten; die legt
/// [`export_notebook_to_bytes`] anschließend als Vektorgrafik darunter. /// [`export_notebook_to_bytes`] anschließend als Vektorgrafik darunter.
pub fn generate_pdf_document( pub fn generate_pdf_document(
@@ -450,7 +405,7 @@ fn generate_pdf_document_with(
} }
let page_ref = doc.get_page(page_idx); let page_ref = doc.get_page(page_idx);
render_background_layer(&page_ref.get_layer(layer_bg), page, pattern); render_background_layer(&page_ref.get_layer(layer_bg), page, pattern);
let layer = |name: &str, render: &dyn Fn(&printpdf::PdfLayerReference)| { let layer = |name: &str, render: &dyn Fn(&crate::pdf_writer::PdfLayerReference)| {
let layer = page_ref.add_layer(name); let layer = page_ref.add_layer(name);
begin_page_layer(&layer, page); begin_page_layer(&layer, page);
render(&layer); render(&layer);
@@ -473,7 +428,7 @@ fn generate_pdf_document_with(
/// Rendert das Vektorraster auf Layer 1 ("Background"). /// Rendert das Vektorraster auf Layer 1 ("Background").
fn render_background_layer( fn render_background_layer(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
page: &Page, page: &Page,
pattern: PatternColor, pattern: PatternColor,
) { ) {
@@ -484,7 +439,7 @@ fn render_background_layer(
.color(crate::background::PaperTheme::White) .color(crate::background::PaperTheme::White)
.map(crate::background::linear_to_srgb); .map(crate::background::linear_to_srgb);
let grid_color = Color::Rgb(Rgb::new(r, g, b, None)); let grid_color = Color::Rgb(Rgb::new(r, g, b, None));
layer.set_outline_color(grid_color.clone()); layer.set_outline_color(grid_color);
layer.set_outline_thickness(0.4); // Feine 0.15 mm Haarlinie (ca. 0.4 pt) layer.set_outline_thickness(0.4); // Feine 0.15 mm Haarlinie (ca. 0.4 pt)
layer.set_fill_color(grid_color); layer.set_fill_color(grid_color);
@@ -570,7 +525,11 @@ fn render_background_layer(
} }
/// Rendert alle Striche einer Seite auf Layer 2 ("Ink"). /// Rendert alle Striche einer Seite auf Layer 2 ("Ink").
fn render_ink_layer(layer: &printpdf::PdfLayerReference, page: &Page, strategy: ExportStrategy) { fn render_ink_layer(
layer: &crate::pdf_writer::PdfLayerReference,
page: &Page,
strategy: ExportStrategy,
) {
for stroke in &page.strokes { for stroke in &page.strokes {
if stroke.is_object() { if stroke.is_object() {
continue; continue;
@@ -581,9 +540,9 @@ fn render_ink_layer(layer: &printpdf::PdfLayerReference, page: &Page, strategy:
let alpha_state = alpha_state_name(stroke.color[3]); let alpha_state = alpha_state_name(stroke.color[3]);
if let Some(name) = &alpha_state { if let Some(name) = &alpha_state {
layer.save_graphics_state(); layer.save_graphics_state();
layer.add_operation(printpdf::lopdf::content::Operation::new( layer.add_operation(lopdf::content::Operation::new(
"gs", "gs",
vec![printpdf::lopdf::Object::Name(name.as_bytes().to_vec())], vec![lopdf::Object::Name(name.as_bytes().to_vec())],
)); ));
} }
if let Some(ref shape) = stroke.shape { if let Some(ref shape) = stroke.shape {
@@ -651,8 +610,8 @@ fn pdf_image_xobject(
assets: &AssetStore, assets: &AssetStore,
asset: &str, asset: &str,
corners: &[glam::Vec2; 4], corners: &[glam::Vec2; 4],
) -> Result<printpdf::ImageXObject, Box<dyn Error>> { ) -> Result<crate::pdf_writer::ImageXObject, Box<dyn Error>> {
use printpdf::{ColorBits, ColorSpace, ImageFilter, ImageXObject, Px}; use crate::pdf_writer::{ColorSpace, ImageFilter, ImageXObject, Px};
let bytes = assets.read_bytes(asset)?; let bytes = assets.read_bytes(asset)?;
let decoded = image::load_from_memory(&bytes)?; let decoded = image::load_from_memory(&bytes)?;
@@ -668,12 +627,9 @@ fn pdf_image_xobject(
width: Px(decoded.width() as usize), width: Px(decoded.width() as usize),
height: Px(decoded.height() as usize), height: Px(decoded.height() as usize),
color_space, color_space,
bits_per_component: ColorBits::Bit8,
interpolate: true, interpolate: true,
image_data: bytes, image_data: bytes,
image_filter: Some(ImageFilter::DCT), image_filter: Some(ImageFilter::DCT),
smask: None,
clipping_bbox: None,
}); });
} }
} }
@@ -703,7 +659,7 @@ fn pdf_image_xobject(
/// Rendert die eingefügten Bilder einer Seite. Fehlt eine Bilddatei, erscheint an ihrer /// Rendert die eingefügten Bilder einer Seite. Fehlt eine Bilddatei, erscheint an ihrer
/// Stelle eine graue Fläche, damit der Export nicht abbricht. /// Stelle eine graue Fläche, damit der Export nicht abbricht.
fn render_image_layer( fn render_image_layer(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
page: &Page, page: &Page,
assets: Option<&AssetStore>, assets: Option<&AssetStore>,
) { ) {
@@ -728,7 +684,7 @@ fn render_image_layer(
fn embed_text_fonts( fn embed_text_fonts(
doc: &PdfDocumentReference, doc: &PdfDocumentReference,
notebook: &Notebook, notebook: &Notebook,
) -> Result<HashMap<TextFont, printpdf::IndirectFontRef>, Box<dyn Error>> { ) -> Result<HashMap<TextFont, crate::pdf_writer::IndirectFontRef>, Box<dyn Error>> {
let mut fonts = HashMap::new(); let mut fonts = HashMap::new();
let used = notebook let used = notebook
.pages .pages
@@ -747,9 +703,9 @@ fn embed_text_fonts(
/// Koordinatensystem (eine Einheit = eine Seiteneinheit, y nach oben) gesetzt, das eine /// Koordinatensystem (eine Einheit = eine Seiteneinheit, y nach oben) gesetzt, das eine
/// Transformationsmatrix auf seine Ecken abbildet – so stimmen Drehung und Skalierung. /// Transformationsmatrix auf seine Ecken abbildet – so stimmen Drehung und Skalierung.
fn render_text_layer( fn render_text_layer(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
page: &Page, page: &Page,
fonts: &HashMap<TextFont, printpdf::IndirectFontRef>, fonts: &HashMap<TextFont, crate::pdf_writer::IndirectFontRef>,
) { ) {
for stroke in &page.strokes { for stroke in &page.strokes {
let (Some(text), Some(corners)) = (&stroke.text, stroke.object_corners()) else { let (Some(text), Some(corners)) = (&stroke.text, stroke.object_corners()) else {
@@ -766,7 +722,7 @@ fn render_text_layer(
let o = page_to_pdf_pt(origin); let o = page_to_pdf_pt(origin);
let matrix = [right.x * k, -right.y * k, -down.x * k, down.y * k, o.x, o.y]; let matrix = [right.x * k, -right.y * k, -down.x * k, down.y * k, o.x, o.y];
layer.save_graphics_state(); layer.save_graphics_state();
layer.set_ctm(printpdf::CurTransMat::Raw(matrix)); layer.set_ctm(crate::pdf_writer::CurTransMat::Raw(matrix));
layer.set_fill_color(Color::Rgb(Rgb::new( layer.set_fill_color(Color::Rgb(Rgb::new(
stroke.color[0], stroke.color[0],
stroke.color[1], stroke.color[1],
@@ -779,9 +735,9 @@ fn render_text_layer(
if line.text.trim().is_empty() { if line.text.trim().is_empty() {
continue; continue;
} }
layer.set_text_matrix(printpdf::TextMatrix::Translate( layer.set_text_matrix(crate::pdf_writer::TextMatrix::Translate(
printpdf::Pt(0.0), crate::pdf_writer::Pt(0.0),
printpdf::Pt(-layout.baseline(i)), crate::pdf_writer::Pt(-layout.baseline(i)),
)); ));
// Glyphen samt Unterschneidung wie auf dem Bildschirm (Abstände in 1/1000 Em) // Glyphen samt Unterschneidung wie auf dem Bildschirm (Abstände in 1/1000 Em)
let face = text.font.face(); let face = text.font.face();
@@ -799,45 +755,31 @@ fn render_text_layer(
} }
/// Graue 1×1-Fläche für fehlende Bilder. /// Graue 1×1-Fläche für fehlende Bilder.
fn placeholder_xobject() -> printpdf::ImageXObject { fn placeholder_xobject() -> crate::pdf_writer::ImageXObject {
rgb_xobject(1, 1, vec![200, 200, 200]) rgb_xobject(1, 1, vec![200, 200, 200])
} }
fn rgb_xobject(width: u32, height: u32, rgb: Vec<u8>) -> printpdf::ImageXObject { fn rgb_xobject(width: u32, height: u32, rgb: Vec<u8>) -> crate::pdf_writer::ImageXObject {
printpdf::ImageXObject { crate::pdf_writer::ImageXObject {
width: printpdf::Px(width as usize), width: crate::pdf_writer::Px(width as usize),
height: printpdf::Px(height as usize), height: crate::pdf_writer::Px(height as usize),
color_space: printpdf::ColorSpace::Rgb, color_space: crate::pdf_writer::ColorSpace::Rgb,
bits_per_component: printpdf::ColorBits::Bit8,
interpolate: true, interpolate: true,
image_data: rgb, image_data: rgb,
image_filter: None, image_filter: None,
smask: None,
clipping_bbox: None,
} }
} }
/// Zeichnet ein Bild so, dass es die Ecken oben links, oben rechts, unten rechts, /// Zeichnet ein Bild so, dass es die Ecken oben links, oben rechts, unten rechts,
/// unten links ausfüllt. /// unten links ausfüllt.
fn draw_image_xobject( fn draw_image_xobject(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
xobject: printpdf::ImageXObject, xobject: crate::pdf_writer::ImageXObject,
corners: &[glam::Vec2; 4], corners: &[glam::Vec2; 4],
) { ) {
let (width, height) = (xobject.width.0 as f32, xobject.height.0 as f32);
layer.save_graphics_state(); layer.save_graphics_state();
layer.set_ctm(printpdf::CurTransMat::Raw(image_matrix(corners))); layer.set_ctm(crate::pdf_writer::CurTransMat::Raw(image_matrix(corners)));
// Bei 72 dpi ist ein Pixel ein Punkt; die Skalierung bildet das Bild auf das layer.add_image(xobject);
// Einheitsquadrat ab, die Matrix oben auf die Bildecken
printpdf::Image::from(xobject).add_to_layer(
layer.clone(),
printpdf::ImageTransform {
dpi: Some(72.0),
scale_x: Some(1.0 / width),
scale_y: Some(1.0 / height),
..Default::default()
},
);
layer.restore_graphics_state(); layer.restore_graphics_state();
} }
@@ -847,7 +789,7 @@ const PDF_RASTER_DPI: f32 = 200.0;
/// Bettet die importierte PDF-Seite als gerendertes Bild ein (Ausweichlösung). /// Bettet die importierte PDF-Seite als gerendertes Bild ein (Ausweichlösung).
fn render_pdf_raster( fn render_pdf_raster(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
page: &Page, page: &Page,
assets: Option<&AssetStore>, assets: Option<&AssetStore>,
) { ) {
@@ -885,19 +827,19 @@ fn render_pdf_raster(
/// Rendert eine mathematisch bereinigte Form (Gerade, Kreis, Rechteck, Koordinatensystem) /// Rendert eine mathematisch bereinigte Form (Gerade, Kreis, Rechteck, Koordinatensystem)
/// als verlustfreien Vektorpfad im PDF. /// als verlustfreien Vektorpfad im PDF.
fn render_recognized_shape( fn render_recognized_shape(
layer: &printpdf::PdfLayerReference, layer: &crate::pdf_writer::PdfLayerReference,
shape: &crate::geometry::RecognizedShape, shape: &crate::geometry::RecognizedShape,
color: [f32; 4], color: [f32; 4],
) { ) {
use crate::geometry::RecognizedShape; use crate::geometry::RecognizedShape;
let stroke_color = Color::Rgb(Rgb::new(color[0], color[1], color[2], None)); let stroke_color = Color::Rgb(Rgb::new(color[0], color[1], color[2], None));
layer.set_outline_color(stroke_color.clone()); layer.set_outline_color(stroke_color);
layer.set_outline_thickness(1.5); // ca. 0.5 mm Standard-Liniendicke layer.set_outline_thickness(1.5); // ca. 0.5 mm Standard-Liniendicke
// Wie auf dem Bildschirm: spitze Ecken und stumpfe Enden (der Grafikzustand kann noch // Wie auf dem Bildschirm: spitze Ecken und stumpfe Enden (der Grafikzustand kann noch
// runde Verbindungen von einem vorherigen Freihandstrich enthalten) // runde Verbindungen von einem vorherigen Freihandstrich enthalten)
layer.set_line_cap_style(printpdf::LineCapStyle::Butt); layer.set_line_cap_style(crate::pdf_writer::LineCapStyle::Butt);
layer.set_line_join_style(printpdf::LineJoinStyle::Miter); layer.set_line_join_style(crate::pdf_writer::LineJoinStyle::Miter);
match shape { match shape {
RecognizedShape::Line { start, end } => { RecognizedShape::Line { start, end } => {
@@ -1181,7 +1123,7 @@ fn render_recognized_shape(
} }
/// Strategie A: Gefülltes Polygon aus den Triangle-Strip-Hüllpunkten. /// Strategie A: Gefülltes Polygon aus den Triangle-Strip-Hüllpunkten.
fn render_stroke_polygon(layer: &printpdf::PdfLayerReference, stroke: &Stroke) { fn render_stroke_polygon(layer: &crate::pdf_writer::PdfLayerReference, stroke: &Stroke) {
if stroke.vertices.is_empty() { if stroke.vertices.is_empty() {
return; return;
} }
@@ -1269,8 +1211,8 @@ fn exact_outlines() -> bool {
*EXACT.get_or_init(|| std::env::var_os("INK_NOTES_EXACT_OUTLINES").is_some_and(|v| v != "0")) *EXACT.get_or_init(|| std::env::var_os("INK_NOTES_EXACT_OUTLINES").is_some_and(|v| v != "0"))
} }
/// Strategie B: Kubische Bézier-Kurven aus den Abtastpunkten via printpdf::Line. /// Strategie B: Kubische Bézier-Kurven aus den Abtastpunkten via crate::pdf_writer::Line.
fn render_stroke_bezier(layer: &printpdf::PdfLayerReference, stroke: &Stroke) { fn render_stroke_bezier(layer: &crate::pdf_writer::PdfLayerReference, stroke: &Stroke) {
if stroke.points.is_empty() { if stroke.points.is_empty() {
return; return;
} }
@@ -1282,8 +1224,8 @@ fn render_stroke_bezier(layer: &printpdf::PdfLayerReference, stroke: &Stroke) {
None, None,
)); ));
layer.set_outline_color(outline_color); layer.set_outline_color(outline_color);
layer.set_line_cap_style(printpdf::LineCapStyle::Round); layer.set_line_cap_style(crate::pdf_writer::LineCapStyle::Round);
layer.set_line_join_style(printpdf::LineJoinStyle::Round); layer.set_line_join_style(crate::pdf_writer::LineJoinStyle::Round);
// Durchschnittliche Linienstärke aus dem Druck berechnen // Durchschnittliche Linienstärke aus dem Druck berechnen
let avg_pressure = let avg_pressure =
@@ -1756,10 +1698,10 @@ mod tests {
PatternColor::default(), PatternColor::default(),
) )
.unwrap(); .unwrap();
let doc = printpdf::lopdf::Document::load_mem(&bytes).unwrap(); let doc = lopdf::Document::load_mem(&bytes).unwrap();
assert_eq!(doc.get_pages().len(), 2); assert_eq!(doc.get_pages().len(), 2);
for page_id in doc.get_pages().into_values() { for page_id in doc.get_pages().into_values() {
let content = doc.get_page_content(page_id).unwrap(); let content = doc.get_page_content(page_id);
assert!( assert!(
String::from_utf8_lossy(&content).starts_with("q "), String::from_utf8_lossy(&content).starts_with("q "),
"Originalseite fehlt als Unterlage" "Originalseite fehlt als Unterlage"
@@ -1867,7 +1809,7 @@ mod tests {
PatternColor::default(), PatternColor::default(),
) )
.unwrap(); .unwrap();
let doc = printpdf::lopdf::Document::load_mem(&bytes).unwrap(); let doc = lopdf::Document::load_mem(&bytes).unwrap();
let catalog = doc.catalog().unwrap(); let catalog = doc.catalog().unwrap();
assert!(catalog.has(b"Outlines"), "Lesezeichen fehlen"); assert!(catalog.has(b"Outlines"), "Lesezeichen fehlen");
@@ -1878,8 +1820,7 @@ mod tests {
.filter_map(|o| o.as_dict().ok()) .filter_map(|o| o.as_dict().ok())
.filter(|d| d.has(b"Parent")) .filter(|d| d.has(b"Parent"))
.filter_map(|d| match d.get(b"Title") { .filter_map(|d| match d.get(b"Title") {
Ok(printpdf::lopdf::Object::String(raw, _)) => { Ok(lopdf::Object::String(raw, _)) => Some(if raw.starts_with(&[0xFE, 0xFF]) {
Some(if raw.starts_with(&[0xFE, 0xFF]) {
let units: Vec<u16> = raw[2..] let units: Vec<u16> = raw[2..]
.chunks(2) .chunks(2)
.map(|c| u16::from_be_bytes([c[0], c[1]])) .map(|c| u16::from_be_bytes([c[0], c[1]]))
@@ -1887,8 +1828,7 @@ mod tests {
String::from_utf16(&units).unwrap() String::from_utf16(&units).unwrap()
} else { } else {
String::from_utf8(raw.clone()).unwrap() String::from_utf8(raw.clone()).unwrap()
}) }),
}
_ => None, _ => None,
}) })
.collect(); .collect();
+31 -1
View File
@@ -24,6 +24,8 @@ pub enum PickerKind {
Image, Image,
/// PDF, Xournal++, Rnote or Saber file to import as a new notebook /// PDF, Xournal++, Rnote or Saber file to import as a new notebook
Import, Import,
/// Folder for the notebooks (Issue #49): lists folders only
Folder,
} }
impl PickerKind { impl PickerKind {
@@ -32,6 +34,7 @@ impl PickerKind {
match self { match self {
PickerKind::Image => is_supported_image_path(path), PickerKind::Image => is_supported_image_path(path),
PickerKind::Import => crate::import::is_importable_path(path), PickerKind::Import => crate::import::is_importable_path(path),
PickerKind::Folder => false,
} }
} }
} }
@@ -64,6 +67,7 @@ impl FilePicker {
let preferred = match kind { let preferred = match kind {
PickerKind::Image => tn!("🖼 Bilder"), PickerKind::Image => tn!("🖼 Bilder"),
PickerKind::Import => tn!("⬇ Downloads"), PickerKind::Import => tn!("⬇ Downloads"),
PickerKind::Folder => tn!("🏠 Persönlicher Ordner"),
}; };
let all = shortcuts(); let all = shortcuts();
all.iter() all.iter()
@@ -136,7 +140,7 @@ pub fn list_dir(dir: &Path, kind: PickerKind) -> std::io::Result<Vec<PickerEntry
/// mit den Ordnern aus `~/.config/user-dirs.dirs` (z. B. „Bilder“ statt „Pictures“). Die /// mit den Ordnern aus `~/.config/user-dirs.dirs` (z. B. „Bilder“ statt „Pictures“). Die
/// Bezeichnungen sind deutsch, angezeigt werden sie mit `i18n::tr`. /// Bezeichnungen sind deutsch, angezeigt werden sie mit `i18n::tr`.
pub fn shortcuts() -> Vec<(&'static str, PathBuf)> { pub fn shortcuts() -> Vec<(&'static str, PathBuf)> {
let Some(home) = std::env::var_os("HOME").map(PathBuf::from) else { let Some(home) = crate::paths::home_dir() else {
return Vec::new(); return Vec::new();
}; };
let user_dirs = let user_dirs =
@@ -158,6 +162,30 @@ pub fn shortcuts() -> Vec<(&'static str, PathBuf)> {
list.push((tn!("🖥 Schreibtisch"), p)); list.push((tn!("🖥 Schreibtisch"), p));
} }
list.push((tn!("🏠 Persönlicher Ordner"), home)); list.push((tn!("🏠 Persönlicher Ordner"), home));
// Drives (Windows has no single root)
#[cfg(windows)]
{
const DRIVES: [&str; 24] = [
"💽 C:", "💽 D:", "💽 E:", "💽 F:", "💽 G:", "💽 H:", "💽 I:", "💽 J:", "💽 K:",
"💽 L:", "💽 M:", "💽 N:", "💽 O:", "💽 P:", "💽 Q:", "💽 R:", "💽 S:", "💽 T:",
"💽 U:", "💽 V:", "💽 W:", "💽 X:", "💽 Y:", "💽 Z:",
];
// Looked up once: a disconnected network drive can take seconds to answer
static FOUND: std::sync::OnceLock<Vec<(&str, PathBuf)>> = std::sync::OnceLock::new();
let found = FOUND.get_or_init(|| {
DRIVES
.iter()
.map(|label| {
(
*label,
PathBuf::from(format!("{}\\", &label[label.len() - 2..])),
)
})
.filter(|(_, root)| root.is_dir())
.collect()
});
list.extend(found.iter().cloned());
}
list list
} }
@@ -225,6 +253,7 @@ mod tests {
"Uni.sbn2" "Uni.sbn2"
] ]
); );
assert_eq!(names(PickerKind::Folder), ["aOrdner", "zOrdner"]);
} }
#[test] #[test]
@@ -249,6 +278,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)]
fn test_parse_user_dirs() { fn test_parse_user_dirs() {
let home = Path::new("/home/anna"); let home = Path::new("/home/anna");
let content = "# Kommentar\nXDG_DESKTOP_DIR=\"$HOME/Schreibtisch\"\nXDG_PICTURES_DIR=\"$HOME/Bilder\"\nXDG_MUSIC_DIR=\"/daten/Musik\"\n"; let content = "# Kommentar\nXDG_DESKTOP_DIR=\"$HOME/Schreibtisch\"\nXDG_PICTURES_DIR=\"$HOME/Bilder\"\nXDG_MUSIC_DIR=\"/daten/Musik\"\n";
+1
View File
@@ -151,6 +151,7 @@ mod tests {
("assets.rs", include_str!("assets.rs")), ("assets.rs", include_str!("assets.rs")),
("autosave.rs", include_str!("autosave.rs")), ("autosave.rs", include_str!("autosave.rs")),
("background.rs", include_str!("background.rs")), ("background.rs", include_str!("background.rs")),
("disk_watch.rs", include_str!("disk_watch.rs")),
("document.rs", include_str!("document.rs")), ("document.rs", include_str!("document.rs")),
("export.rs", include_str!("export.rs")), ("export.rs", include_str!("export.rs")),
("file_picker.rs", include_str!("file_picker.rs")), ("file_picker.rs", include_str!("file_picker.rs")),
+25
View File
@@ -464,4 +464,29 @@ pub const EN: &[(&str, &str)] = &[
("📄 Importieren (PDF, Xournal++, Rnote, Saber) …", "📄 Import (PDF, Xournal++, Rnote, Saber) …"), ("📄 Importieren (PDF, Xournal++, Rnote, Saber) …", "📄 Import (PDF, Xournal++, Rnote, Saber) …"),
("Keine Saber-Datei", "Not a Saber file"), ("Keine Saber-Datei", "Not a Saber file"),
("Saber-Datei zu alt: bitte in einem aktuellen Saber öffnen und neu speichern", "Saber file too old: please open it in a current Saber and save it again"), ("Saber-Datei zu alt: bitte in einem aktuellen Saber öffnen und neu speichern", "Saber file too old: please open it in a current Saber and save it again"),
("Die Notizbücher liegen bereits dort", "The notebooks are already there"),
("Konfliktkopien als eigene Seiten übernommen: {count}", "Conflict copies added as separate pages: {count}"),
("Speicherort geändert, {count} Notizbücher kopiert", "Storage location changed, {count} notebooks copied"),
("Speicherort geändert: {path}", "Storage location changed: {path}"),
("Speicherort nicht nutzbar: {err}", "Storage location not usable: {err}"),
("Änderungen von einem anderen Gerät übernommen", "Changes from another device taken over"),
("⚠ Auch auf '{device}' geöffnet – Änderungen dort können deine überschreiben", "⚠ Also open on '{device}' – changes there may overwrite yours"),
("⚠ Gerade auf '{device}' geöffnet – Änderungen dort können deine überschreiben", "⚠ Just opened on '{device}' – changes there may overwrite yours"),
("Konfliktkopie", "Conflict copy"),
("Konfliktkopie: {title}", "Conflict copy: {title}"),
("Die Notizbücher liegen dann im Unterordner „ink-notes“ des gewählten Ordners, z. B. im Nextcloud- oder Google-Drive-Ordner. Ist er noch leer, werden die vorhandenen Notizbücher dorthin kopiert; die alten bleiben erhalten.", "The notebooks are then kept in the subfolder “ink-notes” of the chosen folder, e.g. in your Nextcloud or Google Drive folder. If it is still empty, the existing notebooks are copied there; the old ones are kept."),
("Keine Unterordner", "No subfolders"),
("SPEICHERORT", "STORAGE LOCATION"),
("Speicherort wählen", "Choose storage location"),
("Standard", "Default"),
("Z. B. einen Nextcloud- oder Google-Drive-Ordner wählen, um die Notizbücher mit anderen Geräten abzugleichen", "E.g. choose a Nextcloud or Google Drive folder to sync the notebooks with other devices"),
("Zurück zum Standard-Speicherort", "Back to the default storage location"),
("✔ Diesen Ordner wählen", "✔ Choose this folder"),
("📁 Ändern …", "📁 Change …"),
("📁 Speicherort wählen", "📁 Choose storage location"),
("Update installiert – gilt ab dem nächsten Start", "Update installed – takes effect at the next start"),
("🔄 Update installieren", "🔄 Install update"),
("Konnte Backup ({path}) nicht anlegen: {e}. Update abgebrochen, altes Programm unverändert.", "Could not create backup ({path}): {e}. Update cancelled, old program unchanged."),
("Konnte Programm nicht ersetzen: {e}. Altes Programm bleibt unverändert.", "Could not replace the program: {e}. The old program stays unchanged."),
("Ungültiger Programmpfad.", "Invalid program path."),
]; ];
+36
View File
@@ -5,6 +5,7 @@ pub mod assets;
pub mod autosave; pub mod autosave;
pub mod background; pub mod background;
pub mod canvas; pub mod canvas;
pub mod disk_watch;
pub mod document; pub mod document;
pub mod export; pub mod export;
pub mod file_picker; pub mod file_picker;
@@ -17,8 +18,10 @@ pub mod import;
pub mod library; pub mod library;
pub mod osk; pub mod osk;
pub mod page_export; pub mod page_export;
pub mod paths;
pub mod pdf_doc; pub mod pdf_doc;
pub mod pdf_merge; pub mod pdf_merge;
pub mod pdf_writer;
pub mod platform; pub mod platform;
pub mod rnote; pub mod rnote;
pub mod ruler; pub mod ruler;
@@ -32,3 +35,36 @@ pub mod ui;
pub mod updater; pub mod updater;
pub mod viewport; pub mod viewport;
pub mod xopp; pub mod xopp;
/// Entry point on Android (Issue #42), called by the native activity.
///
/// `scripts/package-android.sh` builds the library and packs it into an APK.
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app: winit::platform::android::activity::AndroidApp) {
use winit::platform::android::EventLoopBuilderExtAndroid;
android_logger::init_once(
android_logger::Config::default()
.with_max_level(log::LevelFilter::Info)
.with_tag("ink-notes"),
);
// Panics would otherwise only go to stderr, which Android discards
std::panic::set_hook(Box::new(|info| log::error!("{info}")));
if let Some(dir) = app.internal_data_path() {
paths::set_app_dir(dir);
}
let event_loop = match winit::event_loop::EventLoopBuilder::new()
.with_android_app(app)
.build()
{
Ok(event_loop) => event_loop,
Err(err) => {
log::error!("event loop: {err}");
return;
}
};
if let Err(err) = app::run_with(event_loop) {
log::error!("{err}");
}
}
+8
View File
@@ -3,6 +3,14 @@
//! //!
//! Desktop entry point; the app itself is [`ink_notes::app`]. //! Desktop entry point; the app itself is [`ink_notes::app`].
// No console window next to the app on Windows (debug builds keep it for the log)
#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
#[cfg(not(target_os = "android"))]
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
ink_notes::app::run() ink_notes::app::run()
} }
/// On Android the app starts in `android_main` of the library.
#[cfg(target_os = "android")]
fn main() {}
+21 -142
View File
@@ -12,21 +12,29 @@
//! ohnehin nicht aus. Daher meldet das eigene Objekt einen Platzhalter als Umgebungstext und //! ohnehin nicht aus. Daher meldet das eigene Objekt einen Platzhalter als Umgebungstext und
//! übersetzt die Löschwünsche in Tastendrücke (Rücktaste/Entf) für egui. //! übersetzt die Löschwünsche in Tastendrücke (Rücktaste/Entf) für egui.
use std::ffi::c_void; #[cfg(target_os = "linux")]
mod wayland;
#[cfg(target_os = "linux")]
pub use wayland::KeyboardRequester;
use wayland_client::{ /// Elsewhere the system shows the on-screen keyboard by itself; nothing to request.
delegate_noop, #[cfg(not(target_os = "linux"))]
protocol::{wl_registry, wl_seat}, pub struct KeyboardRequester;
Connection, Dispatch, EventQueue, QueueHandle,
};
use wayland_protocols::wp::text_input::zv3::client::{
zwp_text_input_manager_v3::ZwpTextInputManagerV3,
zwp_text_input_v3::{self, ZwpTextInputV3},
};
/// Platzhalter-Umgebungstext: ein Zeichen vor der Schreibmarke, damit die Rücktaste der #[cfg(not(target_os = "linux"))]
/// Bildschirmtastatur immer etwas zu löschen hat (ein Byte = ein Zeichen) impl KeyboardRequester {
const SURROUNDING_PLACEHOLDER: &str = " "; /// # Safety
/// Nothing to uphold; `unsafe` like the Wayland version.
pub unsafe fn for_window(_window: &winit::window::Window) -> Option<Self> {
None
}
pub fn request(&mut self) {}
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
Vec::new()
}
}
/// Wandelt Texteingaben ohne Vorschau (Preedit) in normale Texteingaben um. /// Wandelt Texteingaben ohne Vorschau (Preedit) in normale Texteingaben um.
/// ///
@@ -74,135 +82,6 @@ pub fn should_request(was_active: bool, active: bool, pressed: bool) -> bool {
active && (!was_active || pressed) active && (!was_active || pressed)
} }
#[derive(Default)]
struct State {
seat: Option<wl_seat::WlSeat>,
manager: Option<ZwpTextInputManagerV3>,
text_input: Option<ZwpTextInputV3>,
/// Von der Bildschirmtastatur gewünschtes Löschen (Zeichen vor/nach der Schreibmarke)
delete_back: u32,
delete_forward: u32,
}
/// Eigenes text-input-Objekt, mit dem ink-notes die Bildschirmtastatur anfordert
pub struct KeyboardRequester {
conn: Connection,
queue: EventQueue<State>,
state: State,
}
impl KeyboardRequester {
/// Hängt sich an die Wayland-Verbindung des Fensters.
///
/// # Safety
/// `wl_display` muss auf die `wl_display` des Fensters zeigen und gültig bleiben, solange
/// der `KeyboardRequester` lebt.
pub unsafe fn new(wl_display: *mut c_void) -> Self {
// Safety: an den Aufrufer weitergereicht
let backend =
unsafe { wayland_backend::client::Backend::from_foreign_display(wl_display.cast()) };
let conn = Connection::from_backend(backend);
let queue = conn.new_event_queue();
conn.display().get_registry(&queue.handle(), ());
let _ = conn.flush();
Self {
conn,
queue,
state: State::default(),
}
}
/// Verarbeitet eingetroffene Ereignisse; einmal pro Frame aufrufen.
pub fn pump(&mut self) {
let _ = self.queue.dispatch_pending(&mut self.state);
if self.state.text_input.is_none() {
if let (Some(manager), Some(seat)) = (&self.state.manager, &self.state.seat) {
self.state.text_input =
Some(manager.get_text_input(seat, &self.queue.handle(), ()));
}
}
}
/// Bittet den Compositor, die Bildschirmtastatur einzublenden. Muss nach dem `enable` von
/// winit kommen (also nach `handle_platform_output`).
pub fn request(&mut self) {
self.pump();
if let Some(text_input) = &self.state.text_input {
text_input.enable();
self.send_surrounding_placeholder();
}
}
/// Tastendrücke für das seit dem letzten Aufruf gewünschte Löschen (vor `begin_frame`
/// aufrufen und an die egui-Eingabe anhängen)
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
self.pump();
// Den Platzhalter hier nicht neu melden: Die Tastatur löscht bei jeder neuen Meldung
// erneut, solange die Rücktaste gedrückt ist – ein kurzes Antippen löschte sonst doppelt.
let back = std::mem::take(&mut self.state.delete_back);
let forward = std::mem::take(&mut self.state.delete_forward);
deletion_key_events(back, forward)
}
fn send_surrounding_placeholder(&self) {
if let Some(text_input) = &self.state.text_input {
let len = SURROUNDING_PLACEHOLDER.len() as i32;
text_input.set_surrounding_text(SURROUNDING_PLACEHOLDER.to_owned(), len, len);
text_input.commit();
let _ = self.conn.flush();
}
}
}
impl Dispatch<wl_registry::WlRegistry, ()> for State {
fn event(
state: &mut Self,
registry: &wl_registry::WlRegistry,
event: wl_registry::Event,
_: &(),
_: &Connection,
qh: &QueueHandle<Self>,
) {
if let wl_registry::Event::Global {
name, interface, ..
} = event
{
match interface.as_str() {
"wl_seat" if state.seat.is_none() => {
state.seat = Some(registry.bind(name, 1, qh, ()));
}
"zwp_text_input_manager_v3" if state.manager.is_none() => {
state.manager = Some(registry.bind(name, 1, qh, ()));
}
_ => {}
}
}
}
}
delegate_noop!(State: ignore wl_seat::WlSeat);
delegate_noop!(State: ZwpTextInputManagerV3);
impl Dispatch<ZwpTextInputV3, ()> for State {
fn event(
state: &mut Self,
_: &ZwpTextInputV3,
event: zwp_text_input_v3::Event,
_: &(),
_: &Connection,
_: &QueueHandle<Self>,
) {
// Getippter Text kommt über winit; hier nur das Löschen
if let zwp_text_input_v3::Event::DeleteSurroundingText {
before_length,
after_length,
} = event
{
state.delete_back += before_length;
state.delete_forward += after_length;
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
+163
View File
@@ -0,0 +1,163 @@
//! Wayland part of [`super`]: an own text-input object on the window's connection.
use std::ffi::c_void;
use wayland_client::{
delegate_noop,
protocol::{wl_registry, wl_seat},
Connection, Dispatch, EventQueue, QueueHandle,
};
use wayland_protocols::wp::text_input::zv3::client::{
zwp_text_input_manager_v3::ZwpTextInputManagerV3,
zwp_text_input_v3::{self, ZwpTextInputV3},
};
use super::deletion_key_events;
/// Platzhalter-Umgebungstext: ein Zeichen vor der Schreibmarke, damit die Rücktaste der
/// Bildschirmtastatur immer etwas zu löschen hat (ein Byte = ein Zeichen)
const SURROUNDING_PLACEHOLDER: &str = " ";
#[derive(Default)]
struct State {
seat: Option<wl_seat::WlSeat>,
manager: Option<ZwpTextInputManagerV3>,
text_input: Option<ZwpTextInputV3>,
/// Von der Bildschirmtastatur gewünschtes Löschen (Zeichen vor/nach der Schreibmarke)
delete_back: u32,
delete_forward: u32,
}
/// Eigenes text-input-Objekt, mit dem ink-notes die Bildschirmtastatur anfordert
pub struct KeyboardRequester {
conn: Connection,
queue: EventQueue<State>,
state: State,
}
impl KeyboardRequester {
/// Requester for the window if it runs on Wayland.
///
/// # Safety
/// The window must outlive the requester.
pub unsafe fn for_window(window: &winit::window::Window) -> Option<Self> {
use winit::raw_window_handle::{HasDisplayHandle, RawDisplayHandle};
match window.display_handle().map(|handle| handle.as_raw()) {
// Safety: passed on to the caller
Ok(RawDisplayHandle::Wayland(handle)) => {
Some(unsafe { Self::new(handle.display.as_ptr()) })
}
_ => None,
}
}
/// Hängt sich an die Wayland-Verbindung des Fensters.
///
/// # Safety
/// `wl_display` muss auf die `wl_display` des Fensters zeigen und gültig bleiben, solange
/// der `KeyboardRequester` lebt.
pub unsafe fn new(wl_display: *mut c_void) -> Self {
// Safety: an den Aufrufer weitergereicht
let backend =
unsafe { wayland_backend::client::Backend::from_foreign_display(wl_display.cast()) };
let conn = Connection::from_backend(backend);
let queue = conn.new_event_queue();
conn.display().get_registry(&queue.handle(), ());
let _ = conn.flush();
Self {
conn,
queue,
state: State::default(),
}
}
/// Verarbeitet eingetroffene Ereignisse; einmal pro Frame aufrufen.
pub fn pump(&mut self) {
let _ = self.queue.dispatch_pending(&mut self.state);
if self.state.text_input.is_none() {
if let (Some(manager), Some(seat)) = (&self.state.manager, &self.state.seat) {
self.state.text_input =
Some(manager.get_text_input(seat, &self.queue.handle(), ()));
}
}
}
/// Bittet den Compositor, die Bildschirmtastatur einzublenden. Muss nach dem `enable` von
/// winit kommen (also nach `handle_platform_output`).
pub fn request(&mut self) {
self.pump();
if let Some(text_input) = &self.state.text_input {
text_input.enable();
self.send_surrounding_placeholder();
}
}
/// Tastendrücke für das seit dem letzten Aufruf gewünschte Löschen (vor `begin_frame`
/// aufrufen und an die egui-Eingabe anhängen)
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
self.pump();
// Den Platzhalter hier nicht neu melden: Die Tastatur löscht bei jeder neuen Meldung
// erneut, solange die Rücktaste gedrückt ist – ein kurzes Antippen löschte sonst doppelt.
let back = std::mem::take(&mut self.state.delete_back);
let forward = std::mem::take(&mut self.state.delete_forward);
deletion_key_events(back, forward)
}
fn send_surrounding_placeholder(&self) {
if let Some(text_input) = &self.state.text_input {
let len = SURROUNDING_PLACEHOLDER.len() as i32;
text_input.set_surrounding_text(SURROUNDING_PLACEHOLDER.to_owned(), len, len);
text_input.commit();
let _ = self.conn.flush();
}
}
}
impl Dispatch<wl_registry::WlRegistry, ()> for State {
fn event(
state: &mut Self,
registry: &wl_registry::WlRegistry,
event: wl_registry::Event,
_: &(),
_: &Connection,
qh: &QueueHandle<Self>,
) {
if let wl_registry::Event::Global {
name, interface, ..
} = event
{
match interface.as_str() {
"wl_seat" if state.seat.is_none() => {
state.seat = Some(registry.bind(name, 1, qh, ()));
}
"zwp_text_input_manager_v3" if state.manager.is_none() => {
state.manager = Some(registry.bind(name, 1, qh, ()));
}
_ => {}
}
}
}
}
delegate_noop!(State: ignore wl_seat::WlSeat);
delegate_noop!(State: ZwpTextInputManagerV3);
impl Dispatch<ZwpTextInputV3, ()> for State {
fn event(
state: &mut Self,
_: &ZwpTextInputV3,
event: zwp_text_input_v3::Event,
_: &(),
_: &Connection,
_: &QueueHandle<Self>,
) {
// Getippter Text kommt über winit; hier nur das Löschen
if let zwp_text_input_v3::Event::DeleteSurroundingText {
before_length,
after_length,
} = event
{
state.delete_back += before_length;
state.delete_forward += after_length;
}
}
}
+74
View File
@@ -0,0 +1,74 @@
//! Folders for notebooks, settings and downloads on each platform (Issues #42, #48).
//!
//! - Linux: XDG (`~/.local/share/ink-notes`, `~/.config/ink-notes`, `~/.cache/ink-notes`)
//! - Windows: `%APPDATA%\ink-notes` for data and settings, `%LOCALAPPDATA%\ink-notes` for
//! downloads
//! - Android: the app's internal folder, set once at startup with [`set_app_dir`]
//!
//! The environment is read on every call, so tests can point the folders elsewhere.
use std::path::PathBuf;
use std::sync::OnceLock;
/// Fixed app folder (Android: internal storage of the app)
static APP_DIR: OnceLock<PathBuf> = OnceLock::new();
/// Puts data, settings and downloads below `dir` (Android, where there is no XDG or home).
pub fn set_app_dir(dir: PathBuf) {
let _ = APP_DIR.set(dir);
}
/// Value of an environment variable, unless empty.
fn env_dir(key: &str) -> Option<PathBuf> {
std::env::var_os(key)
.filter(|v| !v.to_string_lossy().trim().is_empty())
.map(PathBuf::from)
}
/// Home folder of the user.
pub fn home_dir() -> Option<PathBuf> {
if cfg!(windows) {
env_dir("USERPROFILE").or_else(|| env_dir("HOME"))
} else {
env_dir("HOME")
}
}
/// Folder for notebooks and emergency backups.
pub fn data_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.clone());
}
if cfg!(windows) {
return env_dir("APPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_DATA_HOME")
.or_else(|| home_dir().map(|h| h.join(".local").join("share")))
.map(|d| d.join("ink-notes"))
}
/// Folder for the settings (`ui.json`).
pub fn config_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.join("config"));
}
if cfg!(windows) {
return env_dir("APPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_CONFIG_HOME")
.or_else(|| home_dir().map(|h| h.join(".config")))
.map(|d| d.join("ink-notes"))
}
/// Folder for downloaded updates.
pub fn cache_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.join("cache"));
}
if cfg!(windows) {
return env_dir("LOCALAPPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_CACHE_HOME")
.or_else(|| home_dir().map(|h| h.join(".cache")))
.map(|d| d.join("ink-notes"))
}
+3 -3
View File
@@ -1,13 +1,13 @@
//! Legt beim PDF-Export die Originalseiten importierter PDFs als Vektorgrafik unter die //! Legt beim PDF-Export die Originalseiten importierter PDFs als Vektorgrafik unter die
//! Notizen (Text bleibt scharf und auswählbar). //! Notizen (Text bleibt scharf und auswählbar).
//! //!
//! Vorgehen: Das von printpdf erzeugte PDF wird mit `lopdf` geöffnet. Jede benötigte Seite //! Vorgehen: Das vom Export erzeugte PDF wird mit `lopdf` geöffnet. Jede benötigte Seite
//! des Quell-PDFs wird als Form-XObject (Inhalt + Ressourcen der Seite) übernommen und am //! des Quell-PDFs wird als Form-XObject (Inhalt + Ressourcen der Seite) übernommen und am
//! Anfang der Zielseite gezeichnet, also unter Hintergrund, Bildern und Tinte. //! Anfang der Zielseite gezeichnet, also unter Hintergrund, Bildern und Tinte.
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use printpdf::lopdf::{Dictionary, Document, Object, ObjectId, Stream}; use lopdf::{Dictionary, Document, Object, ObjectId, Stream};
use crate::t; use crate::t;
@@ -361,7 +361,7 @@ mod tests {
2, 2,
"Quellseiten dürfen nicht als eigene Seiten auftauchen" "Quellseiten dürfen nicht als eigene Seiten auftauchen"
); );
let first = doc.get_page_content(pages[0]).unwrap(); let first = doc.get_page_content(pages[0]);
let text = String::from_utf8_lossy(&first); let text = String::from_utf8_lossy(&first);
assert!( assert!(
text.starts_with("q "), text.starts_with("q "),
+879
View File
@@ -0,0 +1,879 @@
//! Small PDF writer on top of `lopdf` for the vector export.
//!
//! Replaces printpdf 0.7, which still depended on lopdf 0.31. The interface follows the part
//! of printpdf that [`crate::export`] used: a document with pages, each page with named
//! layers (optional content groups, shown as layers in PDF viewers) that collect drawing
//! operations, embedded TrueType fonts for real, searchable text, images and bookmarks.
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::error::Error;
use std::rc::Rc;
use ab_glyph::Font as _;
use lopdf::content::{Content, Operation};
use lopdf::{Dictionary, Document, Object, ObjectId, Stream, StringFormat};
/// Length in millimetres.
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Mm(pub f32);
/// Length in PDF points (1/72 inch).
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Pt(pub f32);
impl From<Mm> for Pt {
fn from(mm: Mm) -> Self {
Pt(mm.0 * 72.0 / 25.4)
}
}
/// Size in pixels.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Px(pub usize);
/// Point on the page (origin bottom left).
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Point {
pub x: Pt,
pub y: Pt,
}
impl Point {
pub fn new(x: Mm, y: Mm) -> Self {
Self {
x: x.into(),
y: y.into(),
}
}
}
/// Open or closed polyline; a point marked `true` followed by another marked `true` starts a
/// cubic Bézier segment (the two are its control points, the next one its end point).
#[derive(Debug, Clone)]
pub struct Line {
pub points: Vec<(Point, bool)>,
pub is_closed: bool,
}
/// How a polygon is painted.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PaintMode {
Fill,
Stroke,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WindingOrder {
NonZero,
}
/// Closed shape of one or more rings (same point marking as [`Line`]).
#[derive(Debug, Clone)]
pub struct Polygon {
pub rings: Vec<Vec<(Point, bool)>>,
pub mode: PaintMode,
pub winding_order: WindingOrder,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Rgb {
pub r: f32,
pub g: f32,
pub b: f32,
}
impl Rgb {
/// The last argument (ICC profile in printpdf) is ignored.
pub fn new(r: f32, g: f32, b: f32, _icc: Option<()>) -> Self {
Self { r, g, b }
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Color {
Rgb(Rgb),
}
/// Change of the coordinate system (`cm`).
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CurTransMat {
Translate(Pt, Pt),
Raw([f32; 6]),
}
/// Text position within a text section (`Tm`).
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum TextMatrix {
Translate(Pt, Pt),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineCapStyle {
Butt,
Round,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineJoinStyle {
Miter,
Round,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ColorSpace {
Rgb,
Greyscale,
}
/// Image data already compressed in this format (embedded unchanged).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImageFilter {
/// JPEG
DCT,
}
/// Image with 8 bits per component.
#[derive(Debug, Clone)]
pub struct ImageXObject {
pub width: Px,
pub height: Px,
pub color_space: ColorSpace,
pub interpolate: bool,
/// Raw samples, or the compressed data for `image_filter`
pub image_data: Vec<u8>,
pub image_filter: Option<ImageFilter>,
}
/// Font embedded with [`PdfDocumentReference::add_external_font`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct IndirectFontRef {
index: usize,
}
impl IndirectFontRef {
fn resource_name(&self) -> String {
format!("F{}", self.index)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PdfPageIndex(pub usize);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PdfLayerIndex(pub usize);
struct LayerData {
name: String,
operations: Vec<Operation>,
/// Font of the current text section (to record the glyphs it uses)
current_font: Option<usize>,
}
struct PageData {
width: Pt,
height: Pt,
layers: Vec<LayerData>,
images: Vec<ImageXObject>,
}
struct FontData {
face: ab_glyph::FontRef<'static>,
bytes: &'static [u8],
used_glyphs: BTreeSet<u16>,
}
struct DocumentData {
title: String,
pages: Vec<PageData>,
fonts: Vec<FontData>,
bookmarks: Vec<(String, usize)>,
}
/// Entry point like printpdf's `PdfDocument::new`.
pub struct PdfDocument;
impl PdfDocument {
/// New document with a first page of the given size and its first layer.
#[allow(clippy::new_ret_no_self)]
pub fn new(
title: &str,
width: Mm,
height: Mm,
layer: &str,
) -> (PdfDocumentReference, PdfPageIndex, PdfLayerIndex) {
let doc = PdfDocumentReference(Rc::new(RefCell::new(DocumentData {
title: title.to_string(),
pages: Vec::new(),
fonts: Vec::new(),
bookmarks: Vec::new(),
})));
let (page, layer) = doc.add_page(width, height, layer);
(doc, page, layer)
}
}
/// The document being built; cheap to clone, all clones share it.
#[derive(Clone)]
pub struct PdfDocumentReference(Rc<RefCell<DocumentData>>);
impl PdfDocumentReference {
/// Appends a page with its first layer.
pub fn add_page(&self, width: Mm, height: Mm, layer: &str) -> (PdfPageIndex, PdfLayerIndex) {
let mut doc = self.0.borrow_mut();
doc.pages.push(PageData {
width: width.into(),
height: height.into(),
layers: vec![LayerData {
name: layer.to_string(),
operations: Vec::new(),
current_font: None,
}],
images: Vec::new(),
});
(PdfPageIndex(doc.pages.len() - 1), PdfLayerIndex(0))
}
/// Bookmark (outline entry) pointing at a page.
pub fn add_bookmark(&self, title: String, page: PdfPageIndex) {
self.0.borrow_mut().bookmarks.push((title, page.0));
}
pub fn get_page(&self, page: PdfPageIndex) -> PdfPageReference {
PdfPageReference {
doc: self.clone(),
page: page.0,
}
}
/// Embeds a TrueType/OpenType font with TrueType outlines (Type0 font, Identity-H).
pub fn add_external_font(
&self,
bytes: &'static [u8],
) -> Result<IndirectFontRef, Box<dyn Error>> {
let face = ab_glyph::FontRef::try_from_slice(bytes)?;
let mut doc = self.0.borrow_mut();
doc.fonts.push(FontData {
face,
bytes,
used_glyphs: BTreeSet::new(),
});
Ok(IndirectFontRef {
index: doc.fonts.len() - 1,
})
}
/// Writes the document.
pub fn save_to_bytes(self) -> Result<Vec<u8>, Box<dyn Error>> {
let data = self.0.borrow();
let mut doc = Document::with_version("1.5");
let pages_id = doc.new_object_id();
// Fonts: shared by all pages
let mut font_resources = Dictionary::new();
for (index, font) in data.fonts.iter().enumerate() {
let id = write_font(&mut doc, font, index)?;
font_resources.set(format!("F{index}"), Object::Reference(id));
}
// One optional content group per layer name, in the order of appearance
let mut layer_names: Vec<&str> = Vec::new();
for layer in data.pages.iter().flat_map(|p| &p.layers) {
if !layer_names.contains(&layer.name.as_str()) {
layer_names.push(&layer.name);
}
}
let ocgs: Vec<ObjectId> = layer_names
.iter()
.map(|name| {
let mut ocg = Dictionary::new();
ocg.set("Type", Object::Name(b"OCG".to_vec()));
ocg.set("Name", text_string(name));
doc.add_object(ocg)
})
.collect();
let mut page_ids = Vec::new();
for page in &data.pages {
let mut operations = Vec::new();
let mut properties = Dictionary::new();
for layer in &page.layers {
let index = layer_names
.iter()
.position(|n| *n == layer.name)
.unwrap_or(0);
let tag = format!("MC{index}");
properties.set(tag.clone(), Object::Reference(ocgs[index]));
operations.push(Operation::new(
"BDC",
vec![Object::Name(b"OC".to_vec()), Object::Name(tag.into_bytes())],
));
operations.push(Operation::new("q", vec![]));
operations.extend(layer.operations.iter().cloned());
operations.push(Operation::new("Q", vec![]));
operations.push(Operation::new("EMC", vec![]));
}
let mut contents = Stream::new(Dictionary::new(), Content { operations }.encode()?);
contents.compress()?;
let contents_id = doc.add_object(contents);
let mut xobjects = Dictionary::new();
for (i, image) in page.images.iter().enumerate() {
let id = doc.add_object(image_stream(image)?);
xobjects.set(format!("X{i}"), Object::Reference(id));
}
let mut resources = Dictionary::new();
resources.set("Font", Object::Dictionary(font_resources.clone()));
resources.set("XObject", Object::Dictionary(xobjects));
resources.set("Properties", Object::Dictionary(properties));
let resources_id = doc.add_object(resources);
let mut dict = Dictionary::new();
dict.set("Type", Object::Name(b"Page".to_vec()));
dict.set("Parent", Object::Reference(pages_id));
dict.set(
"MediaBox",
Object::Array(vec![
0.into(),
0.into(),
page.width.0.into(),
page.height.0.into(),
]),
);
dict.set("Contents", Object::Reference(contents_id));
dict.set("Resources", Object::Reference(resources_id));
page_ids.push(doc.add_object(dict));
}
let mut pages = Dictionary::new();
pages.set("Type", Object::Name(b"Pages".to_vec()));
pages.set(
"Kids",
Object::Array(page_ids.iter().map(|id| Object::Reference(*id)).collect()),
);
pages.set("Count", Object::Integer(page_ids.len() as i64));
doc.objects.insert(pages_id, Object::Dictionary(pages));
let mut catalog = Dictionary::new();
catalog.set("Type", Object::Name(b"Catalog".to_vec()));
catalog.set("Pages", Object::Reference(pages_id));
let ocg_refs: Vec<Object> = ocgs.iter().map(|id| Object::Reference(*id)).collect();
let mut default_config = Dictionary::new();
default_config.set("Order", Object::Array(ocg_refs.clone()));
let mut oc_properties = Dictionary::new();
oc_properties.set("OCGs", Object::Array(ocg_refs));
oc_properties.set("D", Object::Dictionary(default_config));
catalog.set("OCProperties", Object::Dictionary(oc_properties));
if !data.bookmarks.is_empty() {
let outlines = write_outlines(&mut doc, &data.bookmarks, &page_ids);
catalog.set("Outlines", Object::Reference(outlines));
catalog.set("PageMode", Object::Name(b"UseOutlines".to_vec()));
}
let catalog_id = doc.add_object(catalog);
let mut info = Dictionary::new();
info.set("Title", text_string(&data.title));
info.set("Producer", text_string("ink-notes"));
let info_id = doc.add_object(info);
doc.trailer.set("Root", Object::Reference(catalog_id));
doc.trailer.set("Info", Object::Reference(info_id));
let mut out = Vec::new();
doc.save_to(&mut out)?;
Ok(out)
}
}
/// PDF text string: literal for ASCII, otherwise UTF-16BE with byte order mark.
pub fn text_string(text: &str) -> Object {
if text.is_ascii() {
return Object::String(text.as_bytes().to_vec(), StringFormat::Literal);
}
let mut bytes = vec![0xFE, 0xFF];
for unit in text.encode_utf16() {
bytes.extend_from_slice(&unit.to_be_bytes());
}
Object::String(bytes, StringFormat::Hexadecimal)
}
/// Outline tree with one entry per bookmark; returns the outline root.
fn write_outlines(
doc: &mut Document,
bookmarks: &[(String, usize)],
pages: &[ObjectId],
) -> ObjectId {
let root_id = doc.new_object_id();
let ids: Vec<ObjectId> = bookmarks.iter().map(|_| doc.new_object_id()).collect();
for (i, (title, page)) in bookmarks.iter().enumerate() {
let mut item = Dictionary::new();
item.set("Title", text_string(title));
item.set("Parent", Object::Reference(root_id));
if i > 0 {
item.set("Prev", Object::Reference(ids[i - 1]));
}
if let Some(next) = ids.get(i + 1) {
item.set("Next", Object::Reference(*next));
}
if let Some(page_id) = pages.get(*page) {
item.set(
"Dest",
Object::Array(vec![
Object::Reference(*page_id),
Object::Name(b"Fit".to_vec()),
]),
);
}
doc.objects.insert(ids[i], Object::Dictionary(item));
}
let mut root = Dictionary::new();
root.set("Type", Object::Name(b"Outlines".to_vec()));
root.set("First", Object::Reference(ids[0]));
root.set("Last", Object::Reference(ids[ids.len() - 1]));
root.set("Count", Object::Integer(ids.len() as i64));
doc.objects.insert(root_id, Object::Dictionary(root));
root_id
}
/// Image XObject stream.
fn image_stream(image: &ImageXObject) -> Result<Stream, Box<dyn Error>> {
let mut dict = Dictionary::new();
dict.set("Type", Object::Name(b"XObject".to_vec()));
dict.set("Subtype", Object::Name(b"Image".to_vec()));
dict.set("Width", Object::Integer(image.width.0 as i64));
dict.set("Height", Object::Integer(image.height.0 as i64));
let color_space: &[u8] = match image.color_space {
ColorSpace::Rgb => b"DeviceRGB",
ColorSpace::Greyscale => b"DeviceGray",
};
dict.set("ColorSpace", Object::Name(color_space.to_vec()));
dict.set("BitsPerComponent", Object::Integer(8));
dict.set("Interpolate", Object::Boolean(image.interpolate));
match image.image_filter {
Some(ImageFilter::DCT) => {
dict.set("Filter", Object::Name(b"DCTDecode".to_vec()));
Ok(Stream::new(dict, image.image_data.clone()).with_compression(false))
}
None => {
let mut stream = Stream::new(dict, image.image_data.clone());
stream.compress()?;
Ok(stream)
}
}
}
/// Embeds a font as Type0 font with a CIDFontType2 descendant (glyph ids as character codes),
/// widths and a ToUnicode map of the glyphs used, so that the text can be searched and copied.
fn write_font(
doc: &mut Document,
font: &FontData,
index: usize,
) -> Result<ObjectId, Box<dyn Error>> {
let face = &font.face;
let units_per_em = face.units_per_em().unwrap_or(1000.0);
let scale = 1000.0 / units_per_em;
let name = format!("InkNotesFont{index}");
let mut file = Stream::new(
Dictionary::from_iter(vec![("Length1", Object::Integer(font.bytes.len() as i64))]),
font.bytes.to_vec(),
);
file.compress()?;
let file_id = doc.add_object(file);
let ascent = (face.ascent_unscaled() * scale).round() as i64;
let descent = (face.descent_unscaled() * scale).round() as i64;
let mut descriptor = Dictionary::new();
descriptor.set("Type", Object::Name(b"FontDescriptor".to_vec()));
descriptor.set("FontName", Object::Name(name.clone().into_bytes()));
descriptor.set("Flags", Object::Integer(32));
descriptor.set(
"FontBBox",
Object::Array(vec![0.into(), descent.into(), 1000.into(), ascent.into()]),
);
descriptor.set("ItalicAngle", Object::Integer(0));
descriptor.set("Ascent", Object::Integer(ascent));
descriptor.set("Descent", Object::Integer(descent));
descriptor.set("CapHeight", Object::Integer(ascent));
descriptor.set("StemV", Object::Integer(80));
descriptor.set("FontFile2", Object::Reference(file_id));
let descriptor_id = doc.add_object(descriptor);
// Widths of the glyphs used: gid [width]
let mut widths = Vec::new();
for &gid in &font.used_glyphs {
let width = face.h_advance_unscaled(ab_glyph::GlyphId(gid)) * scale;
widths.push(Object::Integer(gid as i64));
widths.push(Object::Array(vec![Object::Integer(width.round() as i64)]));
}
let mut system_info = Dictionary::new();
system_info.set("Registry", Object::string_literal("Adobe"));
system_info.set("Ordering", Object::string_literal("Identity"));
system_info.set("Supplement", Object::Integer(0));
let mut descendant = Dictionary::new();
descendant.set("Type", Object::Name(b"Font".to_vec()));
descendant.set("Subtype", Object::Name(b"CIDFontType2".to_vec()));
descendant.set("BaseFont", Object::Name(name.clone().into_bytes()));
descendant.set("CIDSystemInfo", Object::Dictionary(system_info));
descendant.set("FontDescriptor", Object::Reference(descriptor_id));
descendant.set("CIDToGIDMap", Object::Name(b"Identity".to_vec()));
descendant.set("DW", Object::Integer(1000));
descendant.set("W", Object::Array(widths));
let descendant_id = doc.add_object(descendant);
let mut to_unicode = Stream::new(Dictionary::new(), to_unicode_cmap(font).into_bytes());
to_unicode.compress()?;
let to_unicode_id = doc.add_object(to_unicode);
let mut dict = Dictionary::new();
dict.set("Type", Object::Name(b"Font".to_vec()));
dict.set("Subtype", Object::Name(b"Type0".to_vec()));
dict.set("BaseFont", Object::Name(name.into_bytes()));
dict.set("Encoding", Object::Name(b"Identity-H".to_vec()));
dict.set(
"DescendantFonts",
Object::Array(vec![Object::Reference(descendant_id)]),
);
dict.set("ToUnicode", Object::Reference(to_unicode_id));
Ok(doc.add_object(dict))
}
/// CMap from the glyph ids used to their characters (UTF-16BE).
fn to_unicode_cmap(font: &FontData) -> String {
let mut chars: BTreeMap<u16, char> = BTreeMap::new();
for (gid, c) in font.face.codepoint_ids() {
if font.used_glyphs.contains(&gid.0) {
// Prefer the lowest code point (e.g. a letter over a compatibility form)
let entry = chars.entry(gid.0).or_insert(c);
if c < *entry {
*entry = c;
}
}
}
let mut cmap = String::from(
"/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n\
/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n\
/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n\
1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n",
);
let entries: Vec<(u16, char)> = chars.into_iter().collect();
for block in entries.chunks(100) {
cmap.push_str(&format!("{} beginbfchar\n", block.len()));
for (gid, c) in block {
let mut units = [0u16; 2];
let hex: String = c
.encode_utf16(&mut units)
.iter()
.map(|u| format!("{u:04X}"))
.collect();
cmap.push_str(&format!("<{gid:04X}> <{hex}>\n"));
}
cmap.push_str("endbfchar\n");
}
cmap.push_str("endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n");
cmap
}
pub struct PdfPageReference {
doc: PdfDocumentReference,
page: usize,
}
impl PdfPageReference {
pub fn get_layer(&self, layer: PdfLayerIndex) -> PdfLayerReference {
PdfLayerReference {
doc: self.doc.clone(),
page: self.page,
layer: layer.0,
}
}
/// Adds a layer drawn above the existing ones.
pub fn add_layer(&self, name: &str) -> PdfLayerReference {
let mut doc = self.doc.0.borrow_mut();
let layers = &mut doc.pages[self.page].layers;
layers.push(LayerData {
name: name.to_string(),
operations: Vec::new(),
current_font: None,
});
PdfLayerReference {
doc: self.doc.clone(),
page: self.page,
layer: layers.len() - 1,
}
}
}
/// A layer of a page; all drawing goes through it.
#[derive(Clone)]
pub struct PdfLayerReference {
doc: PdfDocumentReference,
page: usize,
layer: usize,
}
impl PdfLayerReference {
fn with_layer<T>(&self, f: impl FnOnce(&mut LayerData) -> T) -> T {
let mut doc = self.doc.0.borrow_mut();
f(&mut doc.pages[self.page].layers[self.layer])
}
fn push(&self, operator: &str, operands: Vec<Object>) {
self.add_operation(Operation::new(operator, operands));
}
pub fn add_operation(&self, operation: Operation) {
self.with_layer(|layer| layer.operations.push(operation));
}
pub fn save_graphics_state(&self) {
self.push("q", vec![]);
}
pub fn restore_graphics_state(&self) {
self.push("Q", vec![]);
}
pub fn set_ctm(&self, matrix: CurTransMat) {
let m = match matrix {
CurTransMat::Translate(x, y) => [1.0, 0.0, 0.0, 1.0, x.0, y.0],
CurTransMat::Raw(m) => m,
};
self.push("cm", m.iter().map(|&v| v.into()).collect());
}
pub fn set_fill_color(&self, color: Color) {
let Color::Rgb(c) = color;
self.push("rg", vec![c.r.into(), c.g.into(), c.b.into()]);
}
pub fn set_outline_color(&self, color: Color) {
let Color::Rgb(c) = color;
self.push("RG", vec![c.r.into(), c.g.into(), c.b.into()]);
}
pub fn set_outline_thickness(&self, thickness: f32) {
self.push("w", vec![thickness.into()]);
}
pub fn set_line_cap_style(&self, style: LineCapStyle) {
let value = match style {
LineCapStyle::Butt => 0,
LineCapStyle::Round => 1,
};
self.push("J", vec![Object::Integer(value)]);
}
pub fn set_line_join_style(&self, style: LineJoinStyle) {
let value = match style {
LineJoinStyle::Miter => 0,
LineJoinStyle::Round => 1,
};
self.push("j", vec![Object::Integer(value)]);
}
pub fn add_line(&self, line: Line) {
if line.points.is_empty() {
return;
}
let mut operations = path_operations(&line.points);
operations.push(Operation::new(
if line.is_closed { "s" } else { "S" },
vec![],
));
self.with_layer(|layer| layer.operations.extend(operations));
}
pub fn add_polygon(&self, polygon: Polygon) {
let mut operations: Vec<Operation> = polygon
.rings
.iter()
.filter(|ring| !ring.is_empty())
.flat_map(|ring| path_operations(ring))
.collect();
if operations.is_empty() {
return;
}
operations.push(Operation::new(
match polygon.mode {
PaintMode::Fill => "f",
PaintMode::Stroke => "s",
},
vec![],
));
self.with_layer(|layer| layer.operations.extend(operations));
}
/// Draws `image` into the unit square of the current coordinate system.
pub fn add_image(&self, image: ImageXObject) {
let mut doc = self.doc.0.borrow_mut();
let page = &mut doc.pages[self.page];
page.images.push(image);
let name = format!("X{}", page.images.len() - 1);
page.layers[self.layer]
.operations
.push(Operation::new("Do", vec![Object::Name(name.into_bytes())]));
}
pub fn begin_text_section(&self) {
self.push("BT", vec![]);
}
pub fn end_text_section(&self) {
self.push("ET", vec![]);
self.with_layer(|layer| layer.current_font = None);
}
pub fn set_font(&self, font: &IndirectFontRef, size: f32) {
self.push(
"Tf",
vec![Object::Name(font.resource_name().into_bytes()), size.into()],
);
self.with_layer(|layer| layer.current_font = Some(font.index));
}
pub fn set_text_matrix(&self, matrix: TextMatrix) {
let TextMatrix::Translate(x, y) = matrix;
self.push(
"Tm",
vec![
1.into(),
0.into(),
0.into(),
1.into(),
x.0.into(),
y.0.into(),
],
);
}
/// Shows glyphs of the current font; each comes with a shift before it in 1/1000 em
/// (positive moves left, as in `TJ`).
pub fn write_positioned_codepoints(&self, glyphs: impl IntoIterator<Item = (i64, u16)>) {
let mut list = Vec::new();
let mut used = Vec::new();
for (shift, gid) in glyphs {
if shift != 0 {
list.push(Object::Integer(shift));
}
list.push(Object::String(
gid.to_be_bytes().to_vec(),
StringFormat::Hexadecimal,
));
used.push(gid);
}
let mut doc = self.doc.0.borrow_mut();
let layer = &mut doc.pages[self.page].layers[self.layer];
layer
.operations
.push(Operation::new("TJ", vec![Object::Array(list)]));
if let Some(font) = layer.current_font {
doc.fonts[font].used_glyphs.extend(used);
}
}
}
/// `m`, `l` and `c` operations for a point list (see [`Line`] for the Bézier marking).
fn path_operations(points: &[(Point, bool)]) -> Vec<Operation> {
let xy = |p: &Point| -> [Object; 2] { [p.x.0.into(), p.y.0.into()] };
let mut operations = vec![Operation::new("m", xy(&points[0].0).to_vec())];
let mut current = 1;
while current < points.len() {
let (previous, point) = (&points[current - 1], &points[current]);
if previous.1 && point.1 {
if let (Some(c2), Some(end)) = (points.get(current + 1), points.get(current + 2)) {
let operands = [xy(&point.0), xy(&c2.0), xy(&end.0)].concat();
operations.push(Operation::new("c", operands));
current += 3;
continue;
}
}
operations.push(Operation::new("l", xy(&point.0).to_vec()));
current += 1;
}
operations
}
#[cfg(test)]
mod tests {
use super::*;
fn line(points: &[(f32, f32, bool)]) -> Vec<(Point, bool)> {
points
.iter()
.map(|&(x, y, b)| (Point::new(Mm(x), Mm(y)), b))
.collect()
}
#[test]
fn test_path_operations_lines_and_curves() {
let ops = path_operations(&line(&[
(0.0, 0.0, true),
(1.0, 0.0, true),
(2.0, 0.0, false),
(3.0, 0.0, false),
(4.0, 0.0, false),
]));
let names: Vec<&str> = ops.iter().map(|o| o.operator.as_str()).collect();
assert_eq!(names, ["m", "c", "l"]);
assert_eq!(ops[1].operands.len(), 6);
}
#[test]
fn test_document_with_text_image_and_bookmarks() {
let (doc, page, layer) = PdfDocument::new("Test", Mm(210.0), Mm(297.0), "Background");
let font = doc
.add_external_font(crate::text::TextFont::Sans.bytes())
.unwrap();
doc.add_bookmark("Übung – 1".to_string(), page);
let background = doc.get_page(page).get_layer(layer);
background.add_polygon(Polygon {
rings: vec![line(&[
(0.0, 0.0, false),
(10.0, 0.0, false),
(10.0, 10.0, false),
])],
mode: PaintMode::Fill,
winding_order: WindingOrder::NonZero,
});
let text = doc.get_page(page).add_layer("Text");
let face = crate::text::TextFont::Sans.face();
let gids: Vec<u16> = "Hä".chars().map(|c| face.glyph_id(c).0).collect();
text.begin_text_section();
text.set_font(&font, 12.0);
text.write_positioned_codepoints(gids.iter().map(|&g| (0, g)));
text.end_text_section();
text.add_image(ImageXObject {
width: Px(1),
height: Px(1),
color_space: ColorSpace::Rgb,
interpolate: true,
image_data: vec![255, 0, 0],
image_filter: None,
});
let bytes = doc.save_to_bytes().unwrap();
let pdf = Document::load_mem(&bytes).unwrap();
assert_eq!(pdf.get_pages().len(), 1);
let page_id = *pdf.get_pages().values().next().unwrap();
let content = pdf.get_page_content(page_id);
let ops = Content::decode(&content).unwrap().operations;
let names: Vec<&str> = ops.iter().map(|o| o.operator.as_str()).collect();
for expected in ["BDC", "f", "BT", "Tf", "TJ", "ET", "Do", "EMC"] {
assert!(names.contains(&expected), "{expected} missing in {names:?}");
}
// The ToUnicode map knows both characters
let fonts = pdf.get_page_fonts(page_id).unwrap();
let font = fonts.values().next().unwrap();
let to_unicode = pdf
.get_object(font.get(b"ToUnicode").unwrap().as_reference().unwrap())
.unwrap()
.as_stream()
.unwrap()
.decompressed_content()
.unwrap();
let cmap = String::from_utf8(to_unicode).unwrap();
assert!(cmap.contains("<0048>"), "{cmap}");
assert!(cmap.contains("<00E4>"), "{cmap}");
}
}
+158
View File
@@ -58,6 +58,114 @@ pub fn display_backend_from_env() -> DisplayBackend {
) )
} }
/// Event loop for the desktop; on Linux with the display backend chosen above.
#[cfg(not(target_os = "android"))]
pub fn desktop_event_loop() -> Result<winit::event_loop::EventLoop<()>, winit::error::EventLoopError>
{
#[allow(unused_mut)]
let mut builder = winit::event_loop::EventLoopBuilder::new();
#[cfg(target_os = "linux")]
{
use winit::platform::{wayland::EventLoopBuilderExtWayland, x11::EventLoopBuilderExtX11};
match display_backend_from_env() {
DisplayBackend::X11 => {
eprintln!("[Anzeige] Verwende X11 (unter WSL Standard; übersteuerbar mit INK_NOTES_DISPLAY=wayland)");
builder.with_x11();
}
DisplayBackend::Wayland => {
eprintln!("[Anzeige] Verwende Wayland (INK_NOTES_DISPLAY=wayland)");
builder.with_wayland();
}
DisplayBackend::Automatic => {}
}
}
builder.build()
}
/// Waits until the window can be drawn to. On Android the native window only exists after
/// `Event::Resumed` (Issue #42); on the desktop it is there right away.
pub fn wait_until_resumed(
#[allow(unused_variables)] event_loop: &mut winit::event_loop::EventLoop<()>,
) {
#[cfg(target_os = "android")]
{
use winit::event::Event;
use winit::platform::pump_events::{EventLoopExtPumpEvents, PumpStatus};
let mut resumed = false;
while !resumed {
let status = event_loop.pump_events(None, |event, _| {
if matches!(event, Event::Resumed) {
resumed = true;
}
});
if let PumpStatus::Exit(_) = status {
std::process::exit(0);
}
}
}
}
/// Runs the event loop until the app quits. On Android the loop was already started by
/// [`wait_until_resumed`], so it is driven with `pump_events` (`run` would refuse to start).
pub fn run_event_loop<F>(
#[allow(unused_mut)] mut event_loop: winit::event_loop::EventLoop<()>,
#[allow(unused_mut)] mut handler: F,
) -> Result<(), winit::error::EventLoopError>
where
F: FnMut(winit::event::Event<()>, &winit::event_loop::EventLoopWindowTarget<()>),
{
#[cfg(target_os = "android")]
{
use winit::platform::pump_events::{EventLoopExtPumpEvents, PumpStatus};
loop {
if let PumpStatus::Exit(_) = event_loop.pump_events(None, &mut handler) {
return Ok(());
}
}
}
#[cfg(not(target_os = "android"))]
event_loop.run(handler)
}
/// Gives the window the app id (Wayland: app_id, X11: WM_CLASS), so that dock and task bar
/// show the app icon for it.
pub fn with_app_id(
builder: winit::window::WindowBuilder,
#[allow(unused_variables)] app_id: &str,
) -> winit::window::WindowBuilder {
#[cfg(target_os = "linux")]
{
let builder = winit::platform::wayland::WindowBuilderExtWayland::with_name(
builder,
app_id,
"ink-notes",
);
winit::platform::x11::WindowBuilderExtX11::with_name(builder, app_id, "ink-notes")
}
#[cfg(not(target_os = "linux"))]
builder
}
/// Ignores touches on the client-side title bar until `until` (palm rejection while the pen
/// is near; only Wayland draws its own title bar).
pub fn ignore_decoration_touches_until(
#[allow(unused_variables)] until: Option<std::time::Instant>,
) {
#[cfg(target_os = "linux")]
winit::platform::wayland::ignore_decoration_touches_until(until);
}
/// Time of a touch event as reported by the compositor (milliseconds, Wayland only).
pub fn take_touch_time(
#[allow(unused_variables)] id: u64,
#[allow(unused_variables)] phase: winit::event::TouchPhase,
) -> Option<u32> {
#[cfg(target_os = "linux")]
return winit::platform::wayland::take_touch_time(id, phase);
#[cfg(not(target_os = "linux"))]
None
}
/// Bringt die Ereignisse eines Tablet-Frames in eine brauchbare Reihenfolge: octotablet meldet /// Bringt die Ereignisse eines Tablet-Frames in eine brauchbare Reihenfolge: octotablet meldet
/// das Aufsetzen des Stifts (`Down`) vor der Position desselben Frames (`Pose`). Bis dahin /// das Aufsetzen des Stifts (`Down`) vor der Position desselben Frames (`Pose`). Bis dahin
/// gälte noch die alte Position – kam der Stift schnell heran (Annähern und Aufsetzen im selben /// gälte noch die alte Position – kam der Stift schnell heran (Annähern und Aufsetzen im selben
@@ -91,6 +199,56 @@ pub fn down_after_pose<T>(
ordered ordered
} }
/// System clipboard: arboard on the desktop; on Android not available yet (Issue #42).
pub mod clipboard {
#[cfg(not(target_os = "android"))]
pub use arboard::{Clipboard, ImageData};
#[cfg(target_os = "android")]
pub use android::{Clipboard, ImageData};
#[cfg(target_os = "android")]
mod android {
use std::borrow::Cow;
pub struct ImageData<'a> {
pub width: usize,
pub height: usize,
pub bytes: Cow<'a, [u8]>,
}
impl ImageData<'_> {
pub fn to_owned_img(&self) -> ImageData<'static> {
ImageData {
width: self.width,
height: self.height,
bytes: Cow::Owned(self.bytes.to_vec()),
}
}
}
pub struct Clipboard;
impl Clipboard {
pub fn new() -> Result<Self, &'static str> {
Err("not available on Android")
}
pub fn get_image(&mut self) -> Result<ImageData<'static>, &'static str> {
Err("not available on Android")
}
pub fn get_text(&mut self) -> Result<String, &'static str> {
Err("not available on Android")
}
pub fn set_image(&mut self, _image: ImageData) -> Result<(), &'static str> {
Err("not available on Android")
}
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
+7 -6
View File
@@ -229,6 +229,9 @@ pub struct UiSettings {
pub language: Option<Language>, pub language: Option<Language>,
/// Eraser radius in mm (Issue #38) /// Eraser radius in mm (Issue #38)
pub eraser_radius_mm: f32, pub eraser_radius_mm: f32,
/// Folder of the notebooks, e.g. inside a Nextcloud folder; default location if unset
/// (Issue #49)
pub storage_dir: Option<PathBuf>,
} }
impl Default for UiSettings { impl Default for UiSettings {
@@ -249,18 +252,15 @@ impl Default for UiSettings {
stylus_buttons: Vec::new(), stylus_buttons: Vec::new(),
language: None, language: None,
eraser_radius_mm: 3.0, eraser_radius_mm: 3.0,
storage_dir: None,
} }
} }
} }
impl UiSettings { impl UiSettings {
/// Standardpfad gemäß XDG-Spezifikation. /// Standardpfad gemäß XDG-Spezifikation (see [`crate::paths`] for other systems).
pub fn default_path() -> Option<PathBuf> { pub fn default_path() -> Option<PathBuf> {
let base = match std::env::var("XDG_CONFIG_HOME") { crate::paths::config_dir().map(|d| d.join("ui.json"))
Ok(dir) if !dir.trim().is_empty() => PathBuf::from(dir),
_ => PathBuf::from(std::env::var("HOME").ok()?).join(".config"),
};
Some(base.join("ink-notes").join("ui.json"))
} }
/// Lädt die Einstellungen; bei fehlender oder beschädigter Datei gelten Standardwerte. /// Lädt die Einstellungen; bei fehlender oder beschädigter Datei gelten Standardwerte.
@@ -349,6 +349,7 @@ mod tests {
], ],
language: Some(Language::English), language: Some(Language::English),
eraser_radius_mm: 6.0, eraser_radius_mm: 6.0,
storage_dir: Some(PathBuf::from("/home/pia/Nextcloud/ink-notes")),
}; };
settings.save_to(&path).unwrap(); settings.save_to(&path).unwrap();
assert_eq!(UiSettings::load_from(&path), settings); assert_eq!(UiSettings::load_from(&path), settings);
+158 -18
View File
@@ -939,23 +939,64 @@ pub fn ensure_page_loaded(
} }
} }
/// Notebook folder inside a folder the user picked as storage location (Issue #49), e.g. the
/// Nextcloud folder: `<chosen>/ink-notes`, unless the folder already is called `ink-notes`.
pub fn storage_dir_in(chosen: &Path) -> PathBuf {
if chosen.file_name().is_some_and(|n| n == "ink-notes") {
chosen.to_path_buf()
} else {
chosen.join("ink-notes")
}
}
/// Prepares `to` as new storage location. If it holds no notebooks yet, the notebooks and
/// `library.json` of `from` are copied there (lock files and open markers excluded); the
/// originals stay where they are. Returns the number of copied notebooks.
pub fn copy_storage(from: &Path, to: &Path) -> io::Result<usize> {
create_secure_dir_all(to)?;
if !list_notebooks(to).is_empty() {
return Ok(0);
}
let mut copied = 0;
for summary in list_notebooks(from) {
let target = to.join(&summary.id);
if target.exists() {
continue;
}
copy_dir(&from.join(&summary.id), &target)?;
copied += 1;
}
let library = from.join("library.json");
if library.is_file() && !to.join("library.json").exists() {
fs::copy(&library, to.join("library.json"))?;
}
Ok(copied)
}
/// Copies a notebook folder recursively, without lock file and open marker.
fn copy_dir(from: &Path, to: &Path) -> io::Result<()> {
create_secure_dir_all(to)?;
for entry in fs::read_dir(from)? {
let entry = entry?;
let name = entry.file_name();
if name == ".lock" || name == OPEN_MARKER_FILE {
continue;
}
let kind = entry.file_type()?;
if kind.is_dir() {
copy_dir(&entry.path(), &to.join(&name))?;
} else if kind.is_file() {
fs::copy(entry.path(), to.join(&name))?;
}
}
Ok(())
}
/// Gibt das Standard-Verzeichnis für Notizbücher zurück (gemäß XDG-Spezifikation). /// Gibt das Standard-Verzeichnis für Notizbücher zurück (gemäß XDG-Spezifikation).
pub fn default_storage_dir() -> PathBuf { pub fn default_storage_dir() -> PathBuf {
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") { crate::paths::data_dir()
if !xdg.is_empty() { .map(|d| d.join("notebooks"))
return PathBuf::from(xdg).join("ink-notes").join("notebooks"); .unwrap_or_else(|| PathBuf::from("./data/notebooks"))
}
}
if let Ok(home) = std::env::var("HOME") {
if !home.is_empty() {
return PathBuf::from(home)
.join(".local")
.join("share")
.join("ink-notes")
.join("notebooks");
}
}
PathBuf::from("./data/notebooks")
} }
/// Status eines Notizbuchs in der Dokumentenliste. /// Status eines Notizbuchs in der Dokumentenliste.
@@ -984,6 +1025,49 @@ pub struct NotebookSummary {
pub struct NotebookLock { pub struct NotebookLock {
_file: File, _file: File,
pub path: PathBuf, pub path: PathBuf,
/// Another device that has the notebook open according to its marker (Issue #49)
pub open_elsewhere: Option<OpenMarker>,
marker: Option<(PathBuf, OpenMarker)>,
}
/// Which device has a notebook open, and since when (Unix seconds). The `.lock` file only
/// locks on this computer; this marker (`.opened_by.json`) travels with sync clients such as
/// Nextcloud, so another device can warn before both edit at the same time (Issue #49).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct OpenMarker {
pub device: String,
pub since: u64,
}
/// File name of the [`OpenMarker`] in the notebook folder.
pub const OPEN_MARKER_FILE: &str = ".opened_by.json";
/// Name of this device (host name).
pub fn device_name() -> String {
let from_file = |path: &str| fs::read_to_string(path).ok();
std::env::var("INK_NOTES_DEVICE")
.ok()
.or_else(|| from_file("/proc/sys/kernel/hostname"))
.or_else(|| from_file("/etc/hostname"))
.or_else(|| std::env::var("COMPUTERNAME").ok())
.or_else(|| std::env::var("HOSTNAME").ok())
.map(|name| name.trim().to_string())
.filter(|name| !name.is_empty())
.unwrap_or_else(|| "?".to_string())
}
impl Drop for NotebookLock {
fn drop(&mut self) {
// Remove our marker, unless another device has replaced it meanwhile
if let Some((path, ours)) = &self.marker {
let current = fs::read(path)
.ok()
.and_then(|b| serde_json::from_slice::<OpenMarker>(&b).ok());
if current.as_ref() == Some(ours) {
let _ = fs::remove_file(path);
}
}
}
} }
impl NotebookLock { impl NotebookLock {
@@ -1007,13 +1091,38 @@ impl NotebookLock {
use fs2::FileExt; use fs2::FileExt;
match file.try_lock_exclusive() { match file.try_lock_exclusive() {
Ok(()) => Ok(Self { Ok(()) => {
let device = device_name();
let marker_path = notebook_dir.join(OPEN_MARKER_FILE);
let open_elsewhere = fs::read(&marker_path)
.ok()
.and_then(|b| serde_json::from_slice::<OpenMarker>(&b).ok())
.filter(|m| m.device != device);
let ours = OpenMarker {
device,
since: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs(),
};
let marker = serde_json::to_vec(&ours)
.ok()
.filter(|json| atomic_write_file(&marker_path, json).is_ok())
.map(|_| (marker_path, ours));
Ok(Self {
_file: file, _file: file,
path: lock_path, path: lock_path,
}), open_elsewhere,
marker,
})
}
Err(e) => { Err(e) => {
let kind = e.kind(); let kind = e.kind();
if kind == io::ErrorKind::WouldBlock || e.raw_os_error() == Some(11) { // Windows reports a held lock as ERROR_LOCK_VIOLATION
if kind == io::ErrorKind::WouldBlock
|| e.raw_os_error() == Some(11)
|| e.raw_os_error() == fs2::lock_contended_error().raw_os_error()
{
Err(StorageError::AlreadyLocked(t!( Err(StorageError::AlreadyLocked(t!(
"Notizbuch '{path}' wird bereits von einer anderen Instanz verwendet", "Notizbuch '{path}' wird bereits von einer anderen Instanz verwendet",
path = notebook_dir.display() path = notebook_dir.display()
@@ -2159,6 +2268,37 @@ mod tests {
assert_eq!(damaged_summary.unwrap().status, NotebookStatus::Damaged); assert_eq!(damaged_summary.unwrap().status, NotebookStatus::Damaged);
} }
#[test]
fn test_copy_storage_to_new_location() {
let old = tempfile::tempdir().unwrap();
let cloud = tempfile::tempdir().unwrap();
let (notebook, mut manifest, dir) = create_new_notebook(old.path(), "Mathe").unwrap();
save_notebook(&dir, &notebook, &mut manifest).unwrap();
let _lock = NotebookLock::acquire(&dir).unwrap();
fs::create_dir_all(dir.join("assets")).unwrap();
fs::write(dir.join("assets").join("bild.png"), b"png").unwrap();
fs::write(old.path().join("library.json"), b"{}").unwrap();
assert_eq!(storage_dir_in(cloud.path()), cloud.path().join("ink-notes"));
let target = storage_dir_in(cloud.path());
assert_eq!(storage_dir_in(&target), target);
assert_eq!(copy_storage(old.path(), &target).unwrap(), 1);
let copied = target.join(&manifest.id);
assert!(load_notebook(&copied).is_ok());
assert!(copied.join("assets").join("bild.png").exists());
assert!(target.join("library.json").exists());
assert!(!copied.join(".lock").exists());
assert!(!copied.join(OPEN_MARKER_FILE).exists());
// The originals stay
assert!(load_notebook(&dir).is_ok());
// Notebooks already there (e.g. from another device): nothing is copied
create_new_notebook(old.path(), "Physik").unwrap();
assert_eq!(copy_storage(old.path(), &target).unwrap(), 0);
assert_eq!(list_notebooks(&target).len(), 1);
}
#[test] #[test]
fn test_notebook_instance_lock_prevents_concurrent_open() { fn test_notebook_instance_lock_prevents_concurrent_open() {
let temp_dir = tempfile::tempdir().unwrap(); let temp_dir = tempfile::tempdir().unwrap();
+69
View File
@@ -339,6 +339,8 @@ pub enum UiAction {
InsertImageFile(std::path::PathBuf), InsertImageFile(std::path::PathBuf),
/// PDF als neues Notizbuch importieren /// PDF als neues Notizbuch importieren
ImportFile(std::path::PathBuf), ImportFile(std::path::PathBuf),
/// Store the notebooks in this folder, `None` for the default location (Issue #49)
SetStorageDir(Option<std::path::PathBuf>),
/// Aktuelle Seite als Bild oder SVG exportieren /// Aktuelle Seite als Bild oder SVG exportieren
ExportPage(PageExportKind), ExportPage(PageExportKind),
/// Titel einer Seite setzen (leer = entfernen) /// Titel einer Seite setzen (leer = entfernen)
@@ -503,6 +505,9 @@ pub struct UiState {
pub queued_actions: Vec<UiAction>, pub queued_actions: Vec<UiAction>,
/// Zuletzt in der Dateiauswahl benutzter Ordner (während der Sitzung) /// Zuletzt in der Dateiauswahl benutzter Ordner (während der Sitzung)
pub last_picker_dir: Option<std::path::PathBuf>, pub last_picker_dir: Option<std::path::PathBuf>,
/// Folder holding the notebooks and whether the user picked it (Issue #49)
pub storage_dir: std::path::PathBuf,
pub storage_dir_custom: bool,
} }
impl Default for UiState { impl Default for UiState {
@@ -588,6 +593,8 @@ impl Default for UiState {
page_title_for: None, page_title_for: None,
page_picker_list: false, page_picker_list: false,
last_picker_dir: None, last_picker_dir: None,
storage_dir: std::path::PathBuf::new(),
storage_dir_custom: false,
} }
} }
} }
@@ -674,6 +681,12 @@ impl UiState {
self.open_file_picker(PickerKind::Import); self.open_file_picker(PickerKind::Import);
} }
/// Opens the folder picker for the storage location in the home folder.
pub fn open_storage_picker(&mut self) {
self.close_overlays();
self.file_picker = Some(FilePicker::open(PickerKind::Folder, None));
}
fn open_file_picker(&mut self, kind: PickerKind) { fn open_file_picker(&mut self, kind: PickerKind) {
let dir = self.last_picker_dir.clone(); let dir = self.last_picker_dir.clone();
self.close_overlays(); self.close_overlays();
@@ -2839,6 +2852,17 @@ fn file_picker_dialog(ctx: &egui::Context, state: &mut UiState, actions: &mut Ve
Texte und Bilder werden übernommen, bei Xournal++ und Saber auch PDF-Hintergründe." Texte und Bilder werden übernommen, bei Xournal++ und Saber auch PDF-Hintergründe."
), ),
), ),
PickerKind::Folder => (
t!("Speicherort wählen"),
t!("📁 Speicherort wählen"),
"📁",
t!("Keine Unterordner"),
t!(
"Die Notizbücher liegen dann im Unterordner „ink-notes“ des gewählten Ordners, \
z. B. im Nextcloud- oder Google-Drive-Ordner. Ist er noch leer, werden die \
vorhandenen Notizbücher dorthin kopiert; die alten bleiben erhalten."
),
),
}; };
dialog_window(title, state, false).show(ctx, |ui| { dialog_window(title, state, false).show(ctx, |ui| {
ui.set_width(460.0); ui.set_width(460.0);
@@ -2877,6 +2901,16 @@ fn file_picker_dialog(ctx: &egui::Context, state: &mut UiState, actions: &mut Ve
if let Some(err) = &picker.error { if let Some(err) = &picker.error {
ui.colored_label(egui::Color32::from_rgb(255, 120, 120), err); ui.colored_label(egui::Color32::from_rgb(255, 120, 120), err);
} }
if picker_kind == PickerKind::Folder
&& ui
.add_sized(
[ui.available_width(), 30.0],
egui::Button::new(t!("✔ Diesen Ordner wählen")),
)
.clicked()
{
chosen = Some(picker.dir.clone());
}
ui.add_space(4.0); ui.add_space(4.0);
egui::ScrollArea::vertical() egui::ScrollArea::vertical()
@@ -2923,10 +2957,13 @@ fn file_picker_dialog(ctx: &egui::Context, state: &mut UiState, actions: &mut Ve
} }
} }
if let Some(path) = chosen { if let Some(path) = chosen {
if picker_kind != PickerKind::Folder {
state.last_picker_dir = state.file_picker.as_ref().map(|p| p.dir.clone()); state.last_picker_dir = state.file_picker.as_ref().map(|p| p.dir.clone());
}
actions.push(match picker_kind { actions.push(match picker_kind {
PickerKind::Image => UiAction::InsertImageFile(path), PickerKind::Image => UiAction::InsertImageFile(path),
PickerKind::Import => UiAction::ImportFile(path), PickerKind::Import => UiAction::ImportFile(path),
PickerKind::Folder => UiAction::SetStorageDir(Some(path)),
}); });
close = true; close = true;
} }
@@ -4397,6 +4434,36 @@ pub fn render_ui(
} }
}); });
section(ui, t!("SPEICHERORT"));
ui.add(
egui::Label::new(
egui::RichText::new(state.storage_dir.display().to_string())
.size(11.5)
.color(egui::Color32::from_gray(190)),
)
.truncate(true),
)
.on_hover_text(state.storage_dir.display().to_string());
ui.horizontal(|ui| {
if ui
.add_sized([115.0, 28.0], egui::Button::new(t!("📁 Ändern …")))
.on_hover_text(t!("Z. B. einen Nextcloud- oder Google-Drive-Ordner wählen, um die Notizbücher mit anderen Geräten abzugleichen"))
.clicked()
{
state.open_storage_picker();
}
if ui
.add_enabled(
state.storage_dir_custom,
egui::Button::new(t!("Standard")).min_size(egui::vec2(115.0, 28.0)),
)
.on_hover_text(t!("Zurück zum Standard-Speicherort"))
.clicked()
{
actions.push(UiAction::SetStorageDir(None));
}
});
section(ui, t!("STATUS")); section(ui, t!("STATUS"));
let (dot_color, status_text) = autosave_status_style(autosave_status); let (dot_color, status_text) = autosave_status_style(autosave_status);
ui.horizontal(|ui| { ui.horizontal(|ui| {
@@ -5009,6 +5076,7 @@ pub fn render_ui(
let is_recommended = match updater.runtime() { let is_recommended = match updater.runtime() {
crate::updater::RuntimeEnvironment::AppImage { .. } => is_appimage, crate::updater::RuntimeEnvironment::AppImage { .. } => is_appimage,
crate::updater::RuntimeEnvironment::DebPackage { .. } => is_deb, crate::updater::RuntimeEnvironment::DebPackage { .. } => is_deb,
crate::updater::RuntimeEnvironment::WindowsExe { .. } => asset.name.ends_with(".exe"),
_ => false, _ => false,
}; };
@@ -5074,6 +5142,7 @@ pub fn render_ui(
crate::updater::RuntimeEnvironment::DebPackage { .. } => t!("📦 Paket mit Software-Center öffnen / installieren"), crate::updater::RuntimeEnvironment::DebPackage { .. } => t!("📦 Paket mit Software-Center öffnen / installieren"),
crate::updater::RuntimeEnvironment::PortableOrDev { .. } crate::updater::RuntimeEnvironment::PortableOrDev { .. }
| crate::updater::RuntimeEnvironment::Flatpak => t!("📂 Im Dateimanager anzeigen"), | crate::updater::RuntimeEnvironment::Flatpak => t!("📂 Im Dateimanager anzeigen"),
crate::updater::RuntimeEnvironment::WindowsExe { .. } => t!("🔄 Update installieren"),
}; };
ui.horizontal(|ui| { ui.horizontal(|ui| {
+80 -19
View File
@@ -121,6 +121,8 @@ pub enum RuntimeEnvironment {
/// Als Flatpak installiert: Updates kommen über die Software-Verwaltung, ink-notes lädt /// Als Flatpak installiert: Updates kommen über die Software-Verwaltung, ink-notes lädt
/// selbst nichts herunter (Vorgabe von Flathub) /// selbst nichts herunter (Vorgabe von Flathub)
Flatpak, Flatpak,
/// Portable `.exe` on Windows (Issue #48), replaced in place like the AppImage
WindowsExe { exe_path: PathBuf },
} }
impl RuntimeEnvironment { impl RuntimeEnvironment {
@@ -132,8 +134,13 @@ impl RuntimeEnvironment {
) { ) {
return RuntimeEnvironment::Flatpak; return RuntimeEnvironment::Flatpak;
} }
let appimage_var = std::env::var("APPIMAGE").ok();
let current_exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("ink-notes")); let current_exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("ink-notes"));
if cfg!(windows) {
return RuntimeEnvironment::WindowsExe {
exe_path: current_exe,
};
}
let appimage_var = std::env::var("APPIMAGE").ok();
Self::detect_from(appimage_var.as_deref(), &current_exe) Self::detect_from(appimage_var.as_deref(), &current_exe)
} }
@@ -166,6 +173,7 @@ impl RuntimeEnvironment {
RuntimeEnvironment::DebPackage { .. } => t!("System-Paket (.deb)"), RuntimeEnvironment::DebPackage { .. } => t!("System-Paket (.deb)"),
RuntimeEnvironment::PortableOrDev { .. } => t!("Entwicklung / Lokal"), RuntimeEnvironment::PortableOrDev { .. } => t!("Entwicklung / Lokal"),
RuntimeEnvironment::Flatpak => "Flatpak", RuntimeEnvironment::Flatpak => "Flatpak",
RuntimeEnvironment::WindowsExe { .. } => "Windows",
} }
} }
@@ -210,18 +218,9 @@ pub fn sanitize_asset_name(raw_name: &str) -> Result<String, String> {
/// Liefert das isolierte Cache-Verzeichnis für Downloads pro Nutzer mit Rechten 0700. /// Liefert das isolierte Cache-Verzeichnis für Downloads pro Nutzer mit Rechten 0700.
pub fn get_updates_cache_dir() -> Result<PathBuf, String> { pub fn get_updates_cache_dir() -> Result<PathBuf, String> {
let base = if let Ok(xdg) = std::env::var("XDG_CACHE_HOME") { let dir = crate::paths::cache_dir()
let trimmed = xdg.trim(); .ok_or_else(|| t!("HOME-Umgebungsvariable ist nicht gesetzt.").to_string())?
if !trimmed.is_empty() { .join("updates");
PathBuf::from(trimmed)
} else {
default_user_cache_dir()?
}
} else {
default_user_cache_dir()?
};
let dir = base.join("ink-notes").join("updates");
std::fs::create_dir_all(&dir).map_err(|e| { std::fs::create_dir_all(&dir).map_err(|e| {
t!( t!(
"Konnte Update-Cache-Verzeichnis nicht anlegen ({path}): {e}", "Konnte Update-Cache-Verzeichnis nicht anlegen ({path}): {e}",
@@ -239,12 +238,6 @@ pub fn get_updates_cache_dir() -> Result<PathBuf, String> {
Ok(dir) Ok(dir)
} }
fn default_user_cache_dir() -> Result<PathBuf, String> {
let home = std::env::var("HOME")
.map_err(|_| t!("HOME-Umgebungsvariable ist nicht gesetzt.").to_string())?;
Ok(PathBuf::from(home).join(".cache"))
}
/// Löscht alte temporäre Downloads aus dem Cache-Verzeichnis. /// Löscht alte temporäre Downloads aus dem Cache-Verzeichnis.
pub fn cleanup_old_updates() { pub fn cleanup_old_updates() {
if let Ok(dir) = get_updates_cache_dir() { if let Ok(dir) = get_updates_cache_dir() {
@@ -551,6 +544,48 @@ fn http_get_with_auth_guard(
Err(t!("Zu viele Weiterleitungen (Redirect-Schleife abgebrochen).").to_string()) Err(t!("Zu viele Weiterleitungen (Redirect-Schleife abgebrochen).").to_string())
} }
/// Replaces the running `.exe` with the downloaded one (Windows). A running program can't be
/// overwritten but can be renamed: the old one becomes `<name>.bak`, the new one takes its
/// place and starts with the next launch.
pub fn replace_running_exe(downloaded: &Path, exe_path: &Path) -> Result<(), String> {
let file_name = exe_path
.file_name()
.ok_or_else(|| t!("Ungültiger Programmpfad.").to_string())?
.to_string_lossy()
.into_owned();
let dir = exe_path
.parent()
.ok_or_else(|| t!("Ungültiger Programmpfad.").to_string())?;
let new_file = dir.join(format!("{file_name}.new"));
let backup = dir.join(format!("{file_name}.bak"));
std::fs::copy(downloaded, &new_file).map_err(|e| {
let _ = std::fs::remove_file(&new_file);
t!("Konnte temporäre Update-Datei nicht schreiben: {e}", e = e)
})?;
// A backup of an earlier update is no longer running
let _ = std::fs::remove_file(&backup);
if let Err(e) = std::fs::rename(exe_path, &backup) {
let _ = std::fs::remove_file(&new_file);
return Err(t!(
"Konnte Backup ({path}) nicht anlegen: {e}. Update abgebrochen, altes Programm unverändert.",
path = backup.display(),
e = e
));
}
if let Err(e) = std::fs::rename(&new_file, exe_path) {
// Put the old program back
let _ = std::fs::rename(&backup, exe_path);
let _ = std::fs::remove_file(&new_file);
return Err(t!(
"Konnte Programm nicht ersetzen: {e}. Altes Programm bleibt unverändert.",
e = e
));
}
let _ = std::fs::remove_file(downloaded);
Ok(())
}
/// Asynchroner Controller für Update-Prüfung und Asset-Download. /// Asynchroner Controller für Update-Prüfung und Asset-Download.
pub struct UpdaterController { pub struct UpdaterController {
config: UpdaterConfig, config: UpdaterConfig,
@@ -915,6 +950,7 @@ impl UpdaterController {
"Die Flatpak-Version wird über die Software-Verwaltung aktualisiert." "Die Flatpak-Version wird über die Software-Verwaltung aktualisiert."
) )
.to_string()), .to_string()),
RuntimeEnvironment::WindowsExe { exe_path } => replace_running_exe(file_path, exe_path),
} }
} }
@@ -1102,6 +1138,31 @@ dcdeb7ac87d9e6cb8022e5a71bc7f2c56d779b4fce4efdd5bae5be3b0214884a ink-notes_0.1.
); );
} }
#[test]
fn test_replace_running_exe() {
let dir = tempfile::tempdir().unwrap();
let exe = dir.path().join("ink-notes.exe");
let downloaded = dir.path().join("ink-notes_9.9.9_x86_64.exe");
std::fs::write(&exe, b"old").unwrap();
std::fs::write(&downloaded, b"new").unwrap();
replace_running_exe(&downloaded, &exe).unwrap();
assert_eq!(std::fs::read(&exe).unwrap(), b"new");
assert_eq!(
std::fs::read(dir.path().join("ink-notes.exe.bak")).unwrap(),
b"old"
);
assert!(!downloaded.exists());
// Again: the backup of the first update is replaced
std::fs::write(&downloaded, b"newer").unwrap();
replace_running_exe(&downloaded, &exe).unwrap();
assert_eq!(std::fs::read(&exe).unwrap(), b"newer");
assert_eq!(
std::fs::read(dir.path().join("ink-notes.exe.bak")).unwrap(),
b"new"
);
}
#[test] #[test]
fn test_flatpak_detection_disables_self_update() { fn test_flatpak_detection_disables_self_update() {
assert!(is_flatpak(Some("eu.pansi.ink-notes"), false)); assert!(is_flatpak(Some("eu.pansi.ink-notes"), false));