mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #776 from WS64/master
Add full unichar support for search and chapter markers in mini bar
This commit is contained in:
@@ -127,6 +127,8 @@ DMINIBAR_PAGES = true
|
||||
DMINIBAR_NEXT_CHAPTER = true
|
||||
DMINIBAR_BATTERY = true
|
||||
|
||||
DMINIBAR_PROGRESS_MARKER = true
|
||||
|
||||
-- gesture detector defaults
|
||||
DGESDETECT_DISABLE_DOUBLE_TAP = true
|
||||
|
||||
@@ -142,9 +144,9 @@ FRONTLIGHT_SENSITIVITY_DECREASE = 2
|
||||
|
||||
-- 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
|
||||
-- /mnt/onboard/MyPath for Kobo with files in "MyPath" on the device itself
|
||||
-- /mnt/us/documents/ for Kindle files in folder "documents"
|
||||
-- "/mnt/sd/.hidden" for Kobo with files in ".hidden" on the SD card
|
||||
-- "/mnt/onboard/MyPath" for Kobo with files in "MyPath" on the device itself
|
||||
-- "/mnt/us/documents/" for Kindle files in folder "documents"
|
||||
LIBRARY_PATH = nil
|
||||
|
||||
-- Search parameters
|
||||
|
||||
@@ -20,6 +20,25 @@ local Search = InputContainer:new{
|
||||
results = {},
|
||||
}
|
||||
|
||||
local function unichar (value)
|
||||
local floor = math.floor
|
||||
local strchar = string.char
|
||||
if value < 0 then
|
||||
return nil
|
||||
elseif value <= 0x007f then
|
||||
return string.char (value)
|
||||
elseif value <= 0x07ff then
|
||||
return string.char (0xc0 + floor(value/0x40),0x80 + (floor(value) % 0x40))
|
||||
elseif value <= 0xffff then
|
||||
return string.char (0xe0 + floor(value/0x1000), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40))
|
||||
elseif value <= 0x10ffff then
|
||||
return string.char (0xf0 + floor(value/0x40000), 0x80 + (floor(value/0x1000) % 0x40), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40))
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function findcalibre(root)
|
||||
local t=nil
|
||||
for entity in lfs.dir(root) do
|
||||
@@ -130,43 +149,7 @@ function Search:find()
|
||||
s=string.sub(s,n,string.len(s)-3)
|
||||
end
|
||||
|
||||
-- todo: identify \uXXXX values and enter. Better solution: Find a better way how to replace hex-unicodes with \XXX\XXX constructs
|
||||
-- s=string.gsub(s,"\\","\195\160") -- à
|
||||
-- s=string.gsub(s,"\\","\195\178") -- ò
|
||||
-- s=string.gsub(s,"\\","\195\168") -- è
|
||||
-- s=string.gsub(s,"\\","\195\172") -- ì
|
||||
-- s=string.gsub(s,"\\","\195\185") -- ù
|
||||
-- s=string.gsub(s,"\\","\195\161") -- á
|
||||
-- s=string.gsub(s,"\\","\195\179") -- ó
|
||||
--
|
||||
-- s=string.gsub(s,"\\","\195\173") -- í
|
||||
-- s=string.gsub(s,"\\","\195\186") -- ú
|
||||
-- s=string.gsub(s,"\\","\195\162") -- â
|
||||
-- s=string.gsub(s,"\\","\195\180") -- ô
|
||||
-- s=string.gsub(s,"\\","\195\170") -- ê
|
||||
-- s=string.gsub(s,"\\","\195\174") -- î
|
||||
-- s=string.gsub(s,"\\","\195\187") -- û
|
||||
-- s=string.gsub(s,"\\","\195\163") -- ã
|
||||
-- s=string.gsub(s,"\\","\195\181") -- õ
|
||||
-- s=string.gsub(s,"\\","\195\171") -- ë
|
||||
-- s=string.gsub(s,"\\","\195\175") -- ï
|
||||
-- s=string.gsub(s,"\\","\195\166") -- æ
|
||||
-- s=string.gsub(s,"\\","\195\184") -- ø
|
||||
-- s=string.gsub(s,"\\","\195\167") -- ç
|
||||
-- s=string.gsub(s,"\\","\195\177") -- ñ
|
||||
|
||||
s=string.gsub(s,"\\u00e9","\195\169") -- é
|
||||
|
||||
s=string.gsub(s,"\\u00c4","\195\132") -- Ä
|
||||
s=string.gsub(s,"\\u00d6","\195\150") -- Ö
|
||||
s=string.gsub(s,"\\u00dc","\195\156") -- Ü
|
||||
|
||||
s=string.gsub(s,"\\u00e4","\195\164") -- ä
|
||||
s=string.gsub(s,"\\u00fc","\195\188") -- ü
|
||||
s=string.gsub(s,"\\u00f6","\195\182") -- ö
|
||||
|
||||
s=string.gsub(s,"\\u00df","\195\159") -- ß
|
||||
s=string.gsub(s,"\\u2019","'") -- '
|
||||
s=string.gsub(s,"\\u([a-f0-9][a-f0-9][a-f0-9][a-f0-9])",function(w) return unichar(tonumber(w, 16)) end) -- '
|
||||
|
||||
return s
|
||||
end
|
||||
|
||||
@@ -65,6 +65,8 @@ function ReaderFooter:init()
|
||||
width = math.floor(Screen:getWidth() - text_width - self.padding),
|
||||
height = self.bar_height,
|
||||
percentage = self.progress_percentage,
|
||||
TOC = self.ui.document:getToc(),
|
||||
last = self.pages,
|
||||
}
|
||||
local horizontal_group = HorizontalGroup:new{}
|
||||
local bar_container = RightContainer:new{
|
||||
|
||||
@@ -15,6 +15,8 @@ local ProgressWidget = Widget:new{
|
||||
bgcolor = 0,
|
||||
rectcolor = 10,
|
||||
percentage = nil,
|
||||
TOC = {},
|
||||
last = nil,
|
||||
}
|
||||
|
||||
function ProgressWidget:getSize()
|
||||
@@ -34,6 +36,15 @@ function ProgressWidget:paintTo(bb, x, y)
|
||||
bb:paintRect(x+self.margin_h, y+self.margin_v+self.bordersize,
|
||||
(my_size.w-2*self.margin_h)*self.percentage,
|
||||
(my_size.h-2*(self.margin_v+self.bordersize)), self.rectcolor)
|
||||
if DMINIBAR_PROGRESS_MARKER then
|
||||
if #self.TOC > 0 then
|
||||
for i=1, #self.TOC do
|
||||
v = self.TOC[i]
|
||||
bb:paintRect(x+(my_size.w-2*self.margin_h)*(v.page/self.last), y+self.margin_v+self.bordersize,
|
||||
2,(my_size.h-2*(self.margin_v+self.bordersize)), self.bordercolor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ProgressWidget:setPercentage(percentage)
|
||||
|
||||
Reference in New Issue
Block a user