This fix makes the behaviour of Back command handler in crereader
identical with that in unireader, i.e. the last position is saved in
Jump History when pressing Back, so you can return to it by pressing
Shift-Back enough times.
Also, with this change we would need to handle the need for redrawing
the current page because the :addJump() method can force the call to
fillToc() (if TOC is not already present) and this will display
"Retrieving TOC..." message which will need clearing away.
Even after restoring to the previous version, this function had a slight
bug that would cause a crash on valid .zip files (e.g.
mupdf-thirdparty.zip in kindlepdfviewer make tree). The reason is
because the value of s may be not nil, but the string.match() would
return nil and so string.lower() would get nil as an argument and crash.
So, we have to guard against this carefully.
When I rewrote the function CREReader:ZipContentExt() I lost
the code path leading to "Error unzipping file." message.
This was now restored, plus two required changes:
1. There is no need to surround io.popen() with assert() as it
never fails, not even if the command is non-existent. Besides,
even if it did, crashing the whole viewer just because for
some reason we can't unzip the file is not a good idea.
2. The "while tmp" after tmp=assert() assignment is meaningless.
Even after removing assert() it is still meaningless because io.popen()
can never return nil, oddly enough.
Technically, the only serious problem in this function was the code:
local tmp = assert(io.popen('unzip -l \"'..fname..'\"', "r"))
while tmp do
s = tmp:read("*line")
if i > 3 then tmp:close(); break; end
i = i + 1
end
It is meaningless to evaluate the truth of the return value of assert()
and the above code gives the impression that it relies on the
(undocumented and unreliable) fact that after tmp:close() tmp will be
nil, even though in actual fact it does because it breaks out of the
loop.
However, having looked at the function I saw that the whole thing
can be rewritten in a much simpler way:
local tmp = assert(io.popen('unzip -l \"'..fname..'\" | head -4 | tail -1', "r"))
s = tmp:read("*line")
tmp:close()
Redraw the current page when selecting a TOC entry.
Otherwise the correct page is shown only after the next Menu press
or anything else that does current page redraw, e.g. Shift-R.
UniReader:showMenu() method invokes :cleanCache() method which is
non-existent for CREReader object and causes a crash if you press C
after pressing Menu while viewing any of crereader-handled files (fb2,
epub, etc.)
2. Get rid of the calls to self:fillToc() from the places in the code which cannot affect TOC.
I assume the reason for these calls is that they are needed in the original CoolReader application
(because there the TOC displays the virtual "page numbers") and were brought over to our crengine.lua
during the port.
if the file with zip-extention is not valid zip or it contains the improper entry (not crengine-related files), function CREReader:open(filename) return false, "the error description"
1. Improved the method to restore position in document after rescaling font face, size, weight, interline spacing, etc.
2. Fixed rotation functions inherited from unireader.lua
3. Removed hotkey for the function of manual cropping inherited from unireader.lua; reason: not crengine-related
4. Added fast navigation functions via Shift+fiveway: jump to previous / next TOC-entry; scroll 10 pages backwards / forward
when in CREngine mode, the current font can be made the default
document font by pressing Shift-F
in order to store this setting, the reader_settings variable was
promoted to the declared global G_reader_settings
close#184
- zip files don't require double extensions any more
- filechooser has 'H' shortcut to display keys
- new function for files and folders (^ == shift)
^N - new folder
Del - delete document/folder
^C - copy file into clipboard
^X - cut (move) file to clipboard
^V - paste files from clipboard
^R - rename file
- configurable keyboard for input box
- long lines (filenames in 'Document Info') are now splitted in more
human-readable way (by spaces, dots, slashes or some other characters
- see screenshot)
- the selection of fonts in filemanager (key 'F' or 'Aa') looks now more
user-friendly
- fixed too long strings in most menues (TOC, Bookmarks, Fonts...) and
in the popup with the reading progress (called by key 'Menu')
- the position inside the cr-documents (epub, mobi...) now remain nearly
the same after rescaling the document (i.e. changing the font face,
size, boldface and interline distance)
- when you open TOC-menu or Fonts Menu, it highlights the current item
(i.e. current chapter and current fontface).
- i've a bit changed the way to read the battery level values, it might
now work even without Amazon Kindle framework.
+ fixed: too long strings in _drawReadingInfo() (called by key 'Menu')
+ fixed: floating the text when the font (face, size or boldface) and/or interline spacing modify the document height