Commit Graph

35 Commits (master)

Author SHA1 Message Date
hius07 2ed2c2c23d
md5: centralize and deduplicate (#11003)
Document partial md5 hash is calculated by util.partialMD5() and stored in doc_settings as "partial_md5_checksum" on the first document opening.
7 months ago
zwim 192a243b4d Add datetime.lua
Move date and time related functions from util.lua
(and the statistics plugin) to a new datetime.lua.
1 year ago
zwim e9ba854ff0
DeviceMenu: Colons and more information (#8435)
Add information to device menu entries
2 years ago
Frans de Jonge db45881183
[chore] Spaces for indendation, not tabs (#8364)
Overlooked in #8312.
3 years ago
Aleksa Sarai 6f1b70e5eb util.utf8: improve CJK character detection
Previously the CJK character detection defined only characters in the
range U+4000..U+AFFF as "CJK characters". This excludes an incredibly
large number of CJK characters within the BMP, let alone the whole two
planes dedicated to rarer CJK characters (the SIP and TIP). As a result,
a very large number of Chinese, Japanese, and Korean characters were not
detected as being CJK characters.

While slightly less elegant-looking, it is far more accurate to compute
the codepoint from the utf8 character and then see if it falls within
one of the defined CJK blocks. This is not future-proof against future
CJK ideograph extensions in future Unicode versions, but there is no
real way to accurately predict such changes so this is the best we can
do without accidentally treating characters explicitily defined as being
non-CJK in Unicode as CJK.

While we're at it, copy Lua 5.3's utf8.charpattern constant definition
so that we can more easily write utf8 iterators with string.gmatch (at
least in the interim until there is a rework of utf8 handling in
KOReader and everything is rebuilt on top of utf8proc).

Some unit tests are added for Korean and Japanese text, and the existing
unit tests needed a minor adjustment to handle the fact that
isSplittable now correctly detects CJK punctuation as a character to
compare against the forbidden split rules.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
3 years ago
yparitcher 8c29b71e45
Tests: emptydir switch from data/dict to history (#8296)
So this test doesn't fail when one has dictionaries locally
(history folder is deprecated and should be empty).
3 years ago
Brian Hughes ba65dc155b
Adds time left for chapter and document to the screensaver message options (#7897) 3 years ago
Frans de Jonge 5c9dc850e8
Address assorted Weblate comments (#7154)
* Fix typo in dropbox

Reported by @lescheck

* Rephrase text justification explanation more elegantly

* CoverBrowser: fix up some plurals

* Statistics: remove random use of template function

* Use ngettext for minute/minutes and second/seconds

* Change KB/MB/GB to kB/MB/GB SI units
3 years ago
NiLuJe ec3ec8dc21
Show full ToC entry on hold (#6729)
Fix #6728
4 years ago
poire-z f488eb2bb3 util.getFriendlySize(): add option to right align
Left align by default, but allow right alignment by
padding left with spaces.
4 years ago
Robert 2161a76ea8 fix util.secondsToHClock when hmsFormat is true (#5640) 5 years ago
NiLuJe d8e0b1759b
Other minor frontend.util cleanups (#5629)
* Resync fixUtf8 w/ upstream
* Fix lastIndexOf desc
* Drop unichar usage, it's a crappier unicodeCodepointToUtf8 ;).
5 years ago
Robert 5da3312869 More footer options, default to use icons as prefixes (#5203)
- show icons or letters as prefix of items
- various footer separators
- progress percentage format with decimal digits
- time in 12/24 format
- two duration formats (1:30, 1h30')
- move some options into Settings submenu
5 years ago
Frans de Jonge 9300a59a89
[fix] util.getSafeFilename() maximum extension length (#5067)
Strip HTML and do some semi-intelligent detection of faux extensions (i.e., more than 10 characters probably isn't one).

Fixes #5049.
5 years ago
Robert 9e67c5a614 CloudStorage: Allow use reserved characters in FTP username and FTP password (#3924)
Depends on RFC 3986 compliant util.urlEncode() and adds unit tests for the new functions.
6 years ago
Frans de Jonge 90059221db
[spec] util_spec: tests for util.getFriendlySize() (#3650) 6 years ago
Robert 605df50fbd [fix] util.secondsToClock 00:60 should be 01:00 (#3371) 7 years ago
Frans de Jonge 0fa090ee47 [chore] Rework util spec, rework util.secondsToClock: round seconds to minutes in 00:00 mode + spec
Most of the tests in util_spec were the wrong way around.
It's `assert(expected, given)`.
7 years ago
Frans de Jonge 7277059176 add unit test 7 years ago
Frans de Jonge e3c17aa6d0 Travis: run luacheck on unit tests (#3059)
* Travis: run luacheck on unit tests
7 years ago
poire-z 17656778b1 Book information: refactored and additional features
- Factored out duplicate code from filemanager.lua and filemanagerhistory.lua
to new filemanagerbookinfo.lua (and other common code to filemanagerutil.lua).
- Uses sidecar files' new doc_props and doc_pages settings, or fallback to
old 'stats' settings, or to opening document.
- Shows filename, filetype and directory.
- Shows description (Hold to see whole truncated text), keywords, and
cover image (tap to extract image from document and display it if available).
- Book information now available from reader menu, to display info about
the currently opened book.
- Convert possibly HTML description to plain text via added
util.htmlToPlainTextIfHtml() (for simple HTML conversion).
7 years ago
Frans de Jonge ed0ba6737e test: add optmath spec stub (#2950)
* test: add optmath spec stub
7 years ago
Hzj_jie 999898fa69 Merge various information into systemstat (#2764)
* Merge various information to systemstat
7 years ago
Frans de Jonge e9df73f6dc Developer documentation improvements
* Fixed up all of util and added when absent
* Updated widget examples to new coding style
7 years ago
Robert a3c4254809 Added util.fixUtf8 (#2704)
* Remove invalid UTF-8 chars from OPDS
* add unit tests
7 years ago
Hzj_jie 529d1b3d33 evernote: ReadHistory integration and text file output (#2498) 7 years ago
poire-z a8dd8c6f30 textboxwidget: even better text wrapping
util.isSplitable() accepts now also the previous char to help
decide if a space can be used to split a line.
TextBoxWidget:_splitCharWidthList() : simplified logic
7 years ago
poire-z 5040bfe4c5 textboxwidget and scrolltextwidget enhancements (#2393)
util: made isSplitable() accept an optional next_char
for wiser decision

textboxwidget: speed up rendering, enhanced text wrapping,
allow selection of multiple words with Hold.

scrolltextwidget: allow scrolling with Tap.

Details in #2393
8 years ago
Hzj_jie 9efc723388 PR #2356 breaks CJK character splitting 8 years ago
robert00s fc5ba9b862 Fix hyphenation words with unicode character in texboxwidget (#2356) 8 years ago
chrox 71bf9efc7c split accient greek words with spacing character
This should fix #1705.
8 years ago
Qingping Hou 301925e34a textboxwidget(fix): handle onHoldWord event 8 years ago
Frans de Jonge 5638819f25 Removed a bunch of "successfully", replaced an ellipsis, and some deviant spellings of KOReader. 8 years ago
Qingping Hou eb37d9b8b6 kobo: fix screen probe for touch 8 years ago
chrox 932df2a2f9 Refactor out string.gsplit to util.gsplit 9 years ago