mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
implement case-insensitive sort, make default and configurable
This will convert any file name to lowercase before doing the comparison. Note that this will only work for ASCII character range, a full Unicode aware solution will be much more complicated. And in the end, file names are byte arrays, not character strings ;-) fixes #1183.
This commit is contained in:
@@ -155,6 +155,12 @@ DDICT_FONT_SIZE = 20
|
||||
-- e.g. 2 changes the sensitivity by 1/2, 3 by 1/3 etc.
|
||||
FRONTLIGHT_SENSITIVITY_DECREASE = 2
|
||||
|
||||
-- Normally, Koreader will present file lists sorted in case insensitive manner
|
||||
-- when presenting an alphatically sorted list. So the Order is "A, b, C, d".
|
||||
-- You can switch to a case sensitive sort ("A", "C", "b", "d") by disabling
|
||||
-- insensitive sort
|
||||
DALPHA_SORT_CASE_INSENSITIVE = true
|
||||
|
||||
-- Set a path to a folder that is filled by Calibre (must contain the file metadata.calibre)
|
||||
-- e.g.
|
||||
-- "/mnt/sd/.hidden" for Kobo with files in ".hidden" on the SD card
|
||||
|
||||
@@ -73,8 +73,14 @@ function FileChooser:genItemTableFromPath(path)
|
||||
local sorting = nil
|
||||
local reverse = self.reverse_collate
|
||||
if self.collate == "strcoll" then
|
||||
sorting = function(a, b)
|
||||
return self.strcoll(a.name, b.name) == not reverse
|
||||
if DALPHA_SORT_CASE_INSENSITIVE then
|
||||
sorting = function(a, b)
|
||||
return self.strcoll(string.lower(a.name), string.lower(b.name)) == not reverse
|
||||
end
|
||||
else
|
||||
sorting = function(a, b)
|
||||
return self.strcoll(a.name, b.name) == not reverse
|
||||
end
|
||||
end
|
||||
elseif self.collate == "access" then
|
||||
sorting = function(a, b)
|
||||
|
||||
Reference in New Issue
Block a user