Commit Graph

91 Commits (master)

Author SHA1 Message Date
hius07 0ceb88a9a3
Fulltext search: all entries in entire document (#11313) 4 months ago
hius07 1ef7821b66
getProps: centralize 2 (#10837)
Centralize and optimize handling document properties.
8 months ago
hrdl 20101baef6
pdfdocument: cache page text (#10450)
Updating the selection queries the same page tens of times per second. This prevents KOReader from keeping up with high-frequency input event streams.

Fixes #10443. Relies on koreader/koreader-base#1612.
12 months ago
hius07 cd56dd2edf
ReaderHighlight: pdf multi-page highlights (#9850) 1 year ago
weijiuqiao edf7cc9a61
Vocabulary builder: support extracting context from pdfs (#9622)
Move getSelectedWordContext(), now document specific,
from ReaderHighlight into each document module.
2 years ago
NiLuJe fadee1f5dc
Clarify our OOP semantics across the codebase (#9586)
Basically:

* Use `extend` for class definitions
* Use `new` for object instantiations

That includes some minor code cleanups along the way:

* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
  * ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2 years ago
NiLuJe 62059f8d68
Misc: Get rid of the legacy defaults.lua globals (#9546)
* This removes support for the following deprecated constants: `DTAP_ZONE_FLIPPING`, `DTAP_ZONE_BOOKMARK`, `DCREREADER_CONFIG_DEFAULT_FONT_GAMMA`
* The "Advanced settings" panel now highlights modified values in bold (think about:config in Firefox ;)).
* LuaData: Isolate global table lookup shenanigans, and fix a few issues in unused-in-prod codepaths.
* CodeStyle: Require module locals for Lua/C modules, too.
* ScreenSaver: Actually garbage collect our widget on close (ScreenSaver itself is not an instantiated object).
* DateTimeWidget: Code cleanups to ensure child widgets can be GC'ed.
2 years ago
poire-z 1c44c4c584 bump crengine: better SVG support with extended LunaSVG
Build crengine against LunaSVG instead of NanoSVG.
Includes:
- SerialBuf: allow serializing longer strings
- Support '<img src="data:image/svg+xml,<svg...', remove ;-cr-plain,
- CSS: attribute selectors: accept ' or " as the quote char
- Embedded fonts: fix ignored name when sharing same url
- LVImg: fix possible crash on GIF images
- Fonts: DrawTextString(): allow collecting glyphs as SVG paths
- Images parsing: cache native sizes
- SVG: enhanced SVG support with LunaSVG extended
- Add ldomNode::isImage(), handle <object> and <embed> as images
- Handle the <svg> element as an SVG image
- Support SVG images as first class documents

Make credocument the preferred engine for .svg files.
2 years ago
hius07 b7a2a27590
Highlights: add strikeout style, fix pdf highlights (#8725)
- Add new strikeout highlight style.
- Fix highlight style in pdf documents (save_document enabled)
not updated when KOReader highlight style changed.
- Fix ugly combination of mupdf and KOReader highlights
2 years ago
hius07 00b08d7b54
Bookmarks: fix sort within one page (#8616)
Accurate sorting of bookmarks located in one page depending on their positions in text.
2 years ago
NiLuJe 48da545e32 Kobo/Elipsa: More fine-grained control over the amount of online CPU
cores

* Only keep a single core online most of the time.
* Device: Add an enableCPUCores method to allow controlling the amount of
  online CPU cores.
* Move the initial core onlining setup to Kobo:init, instead of the startup script.
* Enable two CPU cores while hinting new (e.g., cache miss) pages in PDF land.
* Enable two CPU cores while processing book metadata.
* Drive-by fix to isolate the DocCache pressure check to KoptInterface
  and actually apply it when it matters most (e.g., k2pdfopt stuff).
3 years ago
poire-z e3bac94db1 PDF written highlights: fix boxes, trash cached tiles
TileCacheItem: add created_ts property.
Document: manage a tile_cache_validity_ts and ignore
older cached tiles.
This timestamps is updated when highlights are written
as annotations in, or deleted from, the PDF, so we can
get the most current rendered bitmap from MuPDF and
avoid highlight ghosts on old tiles.
Save this timestamp in doc settings so older cached to
disk tiles will also be ignored across re-openings.
Bump base for: mupdf.lua: update frontend pboxes with
MuPDF adjusted ones.
3 years ago
NiLuJe 2c4cbd12a2 DocumentRegistry: Downgrade refcount warnings to debug logging.
It can happen in perfectly sane contexts.

CReDocument: Don't destroy internal engine data when Document just
decreased the refcount (as opposed to actually tore down the document
userdata if it were the last ref).

PdfDocument: Only write edited documents if the Doc instance was torn
down.

PicDocument: Silence some DocumentRegistry related warnings
3 years ago
NiLuJe 21b067792d Cache: Rewrite based on lua-lru
Ought to be faster than our naive array-based approach.
Especially for the glyph cache, which has a solid amount of elements,
and is mostly cache hits.
(There are few things worse for performance in Lua than
table.remove @ !tail and table.insert @ !tail, which this was full of :/).

DocCache: New module that's now an actual Cache instance instead of a
weird hack. Replaces "Cache" (the instance) as used across Document &
co.
Only Cache instance with on-disk persistence.

ImageCache: Update to new Cache.

GlyphCache: Update to new Cache.
Also, actually free glyph bbs on eviction.
3 years ago
NiLuJe ce624be8b8 Cache: Fix a whole lot of things.
* Minor updates to the min & max cache sizes (16 & 64MB). Mostly to satisfy my power-of-two OCD.
  * Purge broken on-disk cache files
  * Optimize free RAM computations
  * Start dropping LRU items when running low on memory before pre-rendring (hinting) pages in non-reflowable documents.
  * Make serialize dump the most recently *displayed* page, as the actual MRU item is the most recently *hinted* page, not the current one.
  * Use more accurate item size estimations across the whole codebase.

TileCacheItem:

  * Drop lua-serialize in favor of Persist.

KoptInterface:

  * Drop lua-serialize in favor of Persist.
  * Make KOPTContext caching actually work by ensuring its hash is stable.
3 years ago
NiLuJe f3341d9dc0
PdfDocument: Unbreak highlights (#7457)
Regression since #7411
Fix #7456
3 years ago
Toromtomtom 3706196bfe
Update PDF annotations when changing bookmark text (#7411) 3 years ago
Frans de Jonge ac668ecb64
Add a few more mimetypes for OPDS (#7258)
Doesn't include application/zip as CBZ, but it will be downloaded (as ZIP).

Doesn't include CBR since that's not supported.

Closes #7218, closes #5997.
3 years ago
poire-z 8b886e5922
bump crengine: sync with upstream, new hyphenation languages (#6746)
Includes:
- (Upstream) various unimpacting changes to keep in sync
- (Upstream) Fix issues with legacy text rendering
- (Upstream) FB3/DocX/ODT: get lang and description metadata
- (Upstream) remove some global settings, make them per-doc
- TextLang, hyphenation: add Armenian, Friulian, Piedmontese,
  Romansh, Zulu and Brazilian Portuguese.

Also make cre the prefered engine for .xhtml (over MuPDF)
and for .xml (which might be HTML).
4 years ago
Galunid 15455b594d
[feat] Comics: zoom to panel (#6511)
This pull requests aims to provide convenient way to zoom in comics. The idea is when user holds/double taps (not decided yet) on a manga/comic panel, it gets cut out from the rest of the image and zoomed. More details in koreader/koreader-base#1148. Depends on koreader/koreader-base#1159
4 years ago
Frans de Jonge 2945a2fb79
Add EPUB3 extension to MuPDF document (#6013)
Loads fine, see 026140f809 (commitcomment-38122799)
4 years ago
Martín Fernández 5d103a41f8
Avoid writting highlights into read-only PDFs (#5889) 4 years ago
poire-z 7caa21a3fb [chore] Remove uneeded doc_settings:close() (#5504)
When just reading settings, no need to close and
write the file to disk.
5 years ago
poire-z 788e6d90df
Fix: don't create sidecar file when indexing pdf documents (#5384) 5 years ago
Frans de Jonge 59355200dc
[fix] PdfDocument: Hash collision (#5337)
A typo introduced in <https://github.com/koreader/koreader/pull/5282>.

This might resolve <https://github.com/koreader/koreader/issues/5323>, <https://github.com/koreader/koreader/issues/5327>.
5 years ago
Frans de Jonge f1f6eebce0
[feat] Add MuPDF EPUB/FB2 dynamic font size (#5282)
Closes #4368.
5 years ago
Frans de Jonge be87fb27a0
[chore] Convert a couple more todos (#5267)
Cf. <https://github.com/koreader/koreader/pull/5244>.

Also update check.
5 years ago
Frans de Jonge de75f6bfa3
[fix] Don't try to save highlight into non-PDF document (#5027)
* [fix] Don't try to save highlight into non-PDF document

Fixes <https://github.com/koreader/koreader/issues/5024>.

Highlighting will still work with the .sdr metadata.

* temp fix
5 years ago
Qingping Hou 1605409c60 rename runtimectl to document/canvascontext 5 years ago
Qingping Hou d749591984 decouple device from pdfdocument, font & bgr checking 5 years ago
Qingping Hou 9e57e56f95 decouple UI definitions from document modules 5 years ago
Frans de Jonge 062d9a44d1
[fix] MuPDF: set default DPI-based EPUB fontsize (#4372)
Makes an attempt at a reasonable default. References #4368.
6 years ago
NiLuJe 5871132c25
UI Behavior tweaks (#3983)
* Switch all initial highlights to "fast" update

i.e., everything that does an invert
Plus a few other things that refresh small UI elements onTap
Re #3130

* Tweak refreshtype for a number of widgets:
  * Fix iconbutton dimen
  * Make touchmenu flash on close & initial menu popup. Full-screen on close.
  * Use flashing updates when opening/closing dictionary popup. Full-screen on close.
  * Switch FileManager to partial.
    It's mostly text, and we want flash promotion there.
  * Make configdialog & menu flash on exit
  * Make FLWidget flash on close
  * virtualkeyboard: flash on layout change & popup.
  * Potentially not that great workaround to ensure we actually see the
highlights in the FM's chevrons
  * Flash when closing BookStatus Widget
  * Optimize away a quirk of the dual "fast" update in touchmenu

* Promote updates to flashing slightly more agressively.

* Document what each refreshtype actually does.

With a few guidelines on their optimal usecases.

* Switch remaining scheduleIn(0.0) to nextTick()

* Tighter scheduling timers

Shaving a hundred ms off UI callbacks...

* Cache FFI C Library namespace

* Ask MuPDF to convert pixmaps to BGR on Kobo

Fix #3949

* Mention koxtoolchain in the README

re #3972

* Kindle: Handle *all* fonts via EXT_FONT_DIR instead of bind mounts insanity

* Make black flashes in UI elements user-configurable

(All or nothing).

* Jot down some random KOA2 sysfs path
6 years ago
Frans de Jonge 8b3b2b0eb1
[fix] Better error handling when MuPDF document has no pages (#3710)
It happens in base so we don't have to worry about it in front.

References https://github.com/koreader/koreader/issues/3705
6 years ago
Frans de Jonge f6ca1c7c0a
[feat] Open with: choose which engine to use for file (#3653)
Fixes #3345

* Add SVG to MuPDF filetypes
6 years ago
Frans de Jonge d714bd3aea
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".

References https://github.com/koreader/koreader/issues/3345

* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
	* ".bmp",
	* ".gif",
	* ".hdp",
	* ".j2k",
	* ".jp2",
	* ".jpeg",
	* ".jpg",
	* ".jpx",
	* ".jxr",
	* ".pam",
	* ".pbm",
	* ".pgm",
	* ".png",
	* ".pnm",
	* ".ppm",
	* ".tif",
	* ".tiff",
        * ".wdp",
6 years ago
TnS-hun 15ec47d7e0 cbt support (#3533) (#3554) 6 years ago
TnS-hun 89164dcbd7 MuPDF 1.12 (#3547)
* addMarkupAnnotation expects a float array

* Use the latest from koreader-base with koreader/koreader-base#577

Closes #3519.
6 years ago
poire-z 53f083f516 Allow for toggling color rendering
New menu item in Screen submenu.
hasColorScreen enabled for SDL device.
7 years ago
poire-z 180f5755f4 Allow for colored rendering (#3276)
* Allow for colored rendering

Available with all engines (CRE, PDF, Images).
Needs to manually add setting: "color_rendering" = true

* Disable color for djvudocument

* Use Screen:isColorEnabled()

* Bump base
7 years ago
poire-z 64f699ba36 Store book metadata and nb of pages in new settings
They may already be available (with other statistics stuff) under
the 'stats' key, but not if Statistics plugin is disabled. As this
plugin may be migrated to SQLite, readerui and readerfooter will now
set two new properties: doc_props (containing all and only the metadata
returned by document:getDocumentProps()) and doc_pages (updated
by readerfooter on any display or font change).

PDF document: returns additional PDF properties: Keywords
and Subject (as Description).
7 years ago
Qingping Hou f95ad00b9e feat: add logger module & rewrite kobo suspend script in lua 7 years ago
chrox 5983050d79 PDF free zoom mode revisit
this should implement feature request of zoom mode for multi-columns
page in #501
This PR depends on koreader/koreader-base#435

How to use?
1. Tap the top left corner of a PDF/Djvu page to get into the flipping
mode
2. Double-tap on text block will zoom in to that column
3. Double-tap on any area will zoom out to an overview of the page
4. repeat step 2 to focus to another page block

How does it work?
1. We first find the mask of text blocks in the page. (Pic 1)
2. Then we intersect page boxes with user tap to form a page block. (Pic 2)
3. Finally we zoom the page to the page block and center current view to
that block. (Pic 3)
8 years ago
Qingping Hou 11ee8d6fcc refactor: use new KeyValuePage widget for displaying statistics 8 years ago
Alex Pletnev fbf98ed920 #1710 FR: Add support of statistics plugin for pdf 8 years ago
chrox 8b85cbf157 add support for password protected zip/cbz documents 9 years ago
Alexander Pletnev 52d821df00 Add Statistic plugin (#1581 Amount of hours spent on a book) 9 years ago
chrox b80dd1f966 add fulltext search for PDF documents 10 years ago
Hans-Werner Hilse 0a74dc6072 add needed ffi module when saving annotations 10 years ago
Hans-Werner Hilse e0868826ad use new FFI based mupdf API
This will use the new API where the Lua/C interface was used before
and also drop usage of mupdfimg wrapper which is now implemented
within the mupdf interface
10 years ago