From d25d449a268c3685d1349520ee283afc73339ca8 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sat, 17 Aug 2019 19:10:54 +0200 Subject: [PATCH] bump crengine and others, adds HTML extended debug view (#5219) Bump crengine: background image and other fixes: - View HTML: option to show text unicode codepoints - Fix attribute parsing: decode &-encoded chars - Text: allow wrap after more unicode spaces and hyphen - Fix: no left hanging when hanging punctuation disabled - lvtextfm.cpp: more comments, some formatting cleanup - Optimize background image drawing - CSS: fix background-image file path resolution Bump luasec to 0.8.1 Bump harfbuzz to 2.6.0 cre.cpp: Adds setBackgroundImage() proxy function to crengine facility to set background textures (this is unrelated to the background-image CSS fixes). No frontend code (yet) to select such an image. View HTML: adds a 3rd view (extended debug view), showing the unicode codepoint of each char and crengine rendereing methods. --- base | 2 +- .../apps/reader/modules/readerhighlight.lua | 25 +++++++++++++++---- frontend/document/credocument.lua | 5 ++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/base b/base index 6085f3711..680e67ff5 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 6085f3711bd5a42c2f75f65716bcd88ecc6079ef +Subproject commit 680e67ff5c3f7fc08e4d4c09f6e1580018d46e86 diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 27bcf932f..7ce4d71ad 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -632,17 +632,22 @@ function ReaderHighlight:viewSelectionHTML(debug_view) if self.selected_text and self.selected_text.pos0 and self.selected_text.pos1 then -- For available flags, see the "#define WRITENODEEX_*" in crengine/src/lvtinydom.cpp local html_flags = 0x3030 -- valid and classic displayed HTML, with only block nodes indented - if debug_view then + if not debug_view then + debug_view = 0 + end + if debug_view == 1 then -- Each node on a line, with markers and numbers of skipped chars and siblings shown, -- with possibly invalid HTML (text nodes not escaped) html_flags = 0x3353 - -- html_flags = 0x3753 -- use this to additionally see rendering methods + elseif debug_view == 2 then + -- Additionally see rendering methods and unicode codepoint of each char + html_flags = 0x3757 end local html, css_files = self.ui.document:getHTMLFromXPointers(self.selected_text.pos0, self.selected_text.pos1, html_flags, true) if html then -- Make some invisible chars visible - if debug_view then + if debug_view >= 1 then html = html:gsub("\xC2\xA0", "␣") -- no break space: open box html = html:gsub("\xC2\xAD", "⋅") -- soft hyphen: dot operator (smaller than middle dot ·) -- Prettify inlined CSS (from , put in an internal @@ -700,11 +705,21 @@ function ReaderHighlight:viewSelectionHTML(debug_view) table.insert(buttons_table, {button}) end end + local next_debug_text + local next_debug_view = debug_view + 1 + if next_debug_view == 1 then + next_debug_text = _("Switch to debug view") + elseif next_debug_view == 2 then + next_debug_text = _("Switch to extended debug view") + else + next_debug_view = 0 + next_debug_text = _("Switch to standard view") + end table.insert(buttons_table, {{ - text = debug_view and _("Switch to standard view") or _("Switch to debug view"), + text = next_debug_text, callback = function() UIManager:close(textviewer) - self:viewSelectionHTML(not debug_view) + self:viewSelectionHTML(next_debug_view) end, }}) table.insert(buttons_table, {{ diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 905bc2424..8b7c13425 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -782,6 +782,11 @@ function CreDocument:setStatusLineProp(prop) self._document:setStringProperty("window.status.line", prop) end +function CreDocument:setBackgroundImage(img_path) -- use nil to unset + logger.dbg("CreDocument: set background image", img_path) + self._document:setBackgroundImage(img_path) +end + function CreDocument:findText(pattern, origin, reverse, caseInsensitive) logger.dbg("CreDocument: find text", pattern, origin, reverse, caseInsensitive) return self._document:findText(