mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
add defaults.lua
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
--[[
|
||||
Inheritable abstraction for cache items
|
||||
]]--
|
||||
--]]
|
||||
|
||||
require "defaults"
|
||||
|
||||
|
||||
CacheItem = {
|
||||
size = 64, -- some reasonable default for simple Lua values / small tables
|
||||
}
|
||||
@@ -20,7 +24,7 @@ A global LRU cache
|
||||
]]--
|
||||
Cache = {
|
||||
-- cache configuration:
|
||||
max_memsize = 1024*1024*10, -- 10MB cache size
|
||||
max_memsize = DGLOBAL_CACHE_SIZE,
|
||||
-- cache state:
|
||||
current_memsize = 0,
|
||||
-- associative cache
|
||||
|
||||
95
frontend/defaults.lua
Normal file
95
frontend/defaults.lua
Normal file
@@ -0,0 +1,95 @@
|
||||
-- number of page turns between full screen refresh
|
||||
-- default to full refresh on every page turn
|
||||
DRCOUNTMAX = 6
|
||||
|
||||
-- default gamma setting:
|
||||
DGLOBALGAMMA = 1.0
|
||||
|
||||
-- DjVu page rendering mode (used in djvu.c:drawPage())
|
||||
-- See comments in djvureader.lua:DJVUReader:select_render_mode()
|
||||
DRENDER_MODE = 0 -- 0 is COLOUR
|
||||
|
||||
DGLOBAL_CACHE_SIZE = 1024*1024*10
|
||||
|
||||
-- background colour in non scroll mode: 8 = gray, 0 = white, 15 = black
|
||||
DBACKGROUND_COLOR = 0
|
||||
|
||||
-- outer page colour in scroll mode: 8 = gray, 0 = white, 15 = black
|
||||
DOUTER_PAGE_COLOR = 0
|
||||
|
||||
-- supported view mode includes: "scroll" and "page"
|
||||
DCREREADER_VIEW_MODE = "page"
|
||||
|
||||
-- koptreader config defaults
|
||||
DKOPTREADER_CONFIG_FONT_SIZE = 1.0 -- range from 0.1 to 3.0
|
||||
DKOPTREADER_CONFIG_TEXT_WRAP = 0 -- 1 = on, 0 = off
|
||||
DKOPTREADER_CONFIG_TRIM_PAGE = 1 -- 1 = auto, 0 = manual
|
||||
DKOPTREADER_CONFIG_DETECT_INDENT = 1 -- 1 = enable, 0 = disable
|
||||
DKOPTREADER_CONFIG_DEFECT_SIZE = 1.0 -- range from 0.0 to 3.0
|
||||
DKOPTREADER_CONFIG_PAGE_MARGIN = 0.10 -- range from 0.0 to 1.0
|
||||
DKOPTREADER_CONFIG_LINE_SPACING = 1.2 -- range from 0.5 to 2.0
|
||||
DKOPTREADER_CONFIG_WORD_SAPCING = 0.15 -- range from 0.05 to 0.5
|
||||
DKOPTREADER_CONFIG_RENDER_QUALITY = 0.8 -- range from 0.5 to 1.0
|
||||
DKOPTREADER_CONFIG_AUTO_STRAIGHTEN = 0 -- range from 0 to 10
|
||||
DKOPTREADER_CONFIG_JUSTIFICATION = -1 -- -1 = auto, 0 = left, 1 = center, 2 = right, 3 = full
|
||||
DKOPTREADER_CONFIG_MAX_COLUMNS = 2 -- range from 1 to 4
|
||||
DKOPTREADER_CONFIG_CONTRAST = 1.0 -- range from 0.2 to 2.0
|
||||
|
||||
|
||||
-- ####################################################################
|
||||
-- following features are not supported right now
|
||||
-- ####################################################################
|
||||
|
||||
-- set panning distance
|
||||
--DSHIFT_X = 100
|
||||
--DSHIFT_Y = 50
|
||||
|
||||
-- step to change zoom manually, default = 16%
|
||||
--DSTEP_MANUAL_ZOOM = 16
|
||||
--DPAN_BY_PAGE = false -- using shift_[xy] or width/height
|
||||
--DPAN_MARGIN = 5 -- horizontal margin for two-column zoom (in pixels)
|
||||
--DPAN_OVERLAP_VERTICAL = 30
|
||||
|
||||
-- tile cache configuration:
|
||||
--DCACHE_MAX_MEMSIZE = 1024*1024*5 -- 5MB tile cache
|
||||
--DCACHE_MAX_TTL = 20 -- time to live
|
||||
|
||||
-- renderer cache size
|
||||
--DCACHE_DOCUMENT_SIZE = 1024*1024*8 -- FIXME random, needs testing
|
||||
|
||||
-- default value for battery level logging
|
||||
--DBATTERY_LOGGING = false
|
||||
|
||||
|
||||
-- delay for info messages in ms
|
||||
--DINFO_NODELAY=0
|
||||
--DINFO_DELAY=1500
|
||||
|
||||
-- toggle defaults
|
||||
--DUNIREADER_SHOW_OVERLAP_ENABLE = true
|
||||
--DUNIREADER_SHOW_LINKS_ENABLE = true
|
||||
--DUNIREADER_COMICS_MODE_ENABLE = true
|
||||
--DUNIREADER_RTL_MODE_ENABLE = false
|
||||
--DUNIREADER_PAGE_MODE_ENABLE = false
|
||||
|
||||
--DDJVUREADER_SHOW_OVERLAP_ENABLE = true
|
||||
--DDJVUREADER_SHOW_LINKS_ENABLE = false
|
||||
--DDJVUREADER_COMICS_MODE_ENABLE = true
|
||||
--DDJVUREADER_RTL_MODE_ENABLE = false
|
||||
--DDJVUREADER_PAGE_MODE_ENABLE = false
|
||||
|
||||
--DKOPTREADER_SHOW_OVERLAP_ENABLE = true
|
||||
--DKOPTREADER_SHOW_LINKS_ENABLE = false
|
||||
--DKOPTREADER_COMICS_MODE_ENABLE = false
|
||||
--DKOPTREADER_RTL_MODE_ENABLE = false
|
||||
--DKOPTREADER_PAGE_MODE_ENABLE = false
|
||||
|
||||
--DPICVIEWER_SHOW_OVERLAP_ENABLE = false
|
||||
--DPICVIEWER_SHOW_LINKS_ENABLE = false
|
||||
--DPICVIEWER_COMICS_MODE_ENABLE = true
|
||||
--DPICVIEWER_RTL_MODE_ENABLE = false
|
||||
--DPICVIEWER_PAGE_MODE_ENABLE = false
|
||||
|
||||
|
||||
--DKOPTREADER_CONFIG_MULTI_THREADS = 1 -- 1 = on, 0 = off
|
||||
--DKOPTREADER_CONFIG_SCREEN_ROTATION = 0 -- 0, 90, 180, 270 degrees
|
||||
@@ -196,7 +196,7 @@ end
|
||||
|
||||
--[[
|
||||
get cached koptcontext for centain page. if context doesn't exist in cache make
|
||||
new context and reflow the src page immediatly, or wait background thread for
|
||||
new context and reflow the src page immediatly, or wait background thread for
|
||||
reflowed context.
|
||||
--]]
|
||||
function KoptInterface:getCachedContext(doc, pageno)
|
||||
@@ -272,10 +272,10 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode
|
||||
end
|
||||
|
||||
--[[
|
||||
inherited from common document interface
|
||||
render reflowed page into cache in background thread. this method returns immediatly
|
||||
leaving the precache flag on in context. subsequent usage of this context should
|
||||
wait for the precache flag off by calling self:waitForContext(kctx)
|
||||
inherited from common document interface render reflowed page into cache in
|
||||
background thread. this method returns immediatly leaving the precache flag on
|
||||
in context. subsequent usage of this context should wait for the precache flag
|
||||
off by calling self:waitForContext(kctx)
|
||||
--]]
|
||||
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, render_mode)
|
||||
local bbox = doc:getPageBBox(pageno)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require "ui/screen"
|
||||
require "ui/data/strings"
|
||||
require "defaults"
|
||||
|
||||
KoptOptions = {
|
||||
prefix = 'kopt',
|
||||
@@ -26,7 +27,7 @@ KoptOptions = {
|
||||
toggle = {AUTO_STR, MANUAL_STR},
|
||||
alternate = false,
|
||||
values = {1, 0},
|
||||
default_value = 1,
|
||||
default_value = DKOPTREADER_CONFIG_TRIM_PAGE,
|
||||
event = "PageCrop",
|
||||
args = {"auto", "manual"},
|
||||
}
|
||||
@@ -58,7 +59,7 @@ KoptOptions = {
|
||||
name_text = PAGE_MARGIN_STR,
|
||||
toggle = {SMALL_STR, MEDIUM_STR, LARGE_STR},
|
||||
values = {0.05, 0.10, 0.15},
|
||||
default_value = 0.10,
|
||||
default_value = DKOPTREADER_CONFIG_PAGE_MARGIN,
|
||||
event = "MarginUpdate",
|
||||
},
|
||||
{
|
||||
@@ -66,7 +67,7 @@ KoptOptions = {
|
||||
name_text = LINE_SPACING_STR,
|
||||
toggle = {SMALL_STR, MEDIUM_STR, LARGE_STR},
|
||||
values = {1.0, 1.2, 1.4},
|
||||
default_value = 1.2,
|
||||
default_value = DKOPTREADER_CONFIG_LINE_SPACING,
|
||||
},
|
||||
{
|
||||
name = "max_columns",
|
||||
@@ -77,7 +78,7 @@ KoptOptions = {
|
||||
"resources/icons/appbar.column.three.png",
|
||||
},
|
||||
values = {1,2,3},
|
||||
default_value = 2,
|
||||
default_value = DKOPTREADER_CONFIG_MAX_COLUMNS,
|
||||
},
|
||||
{
|
||||
name = "justification",
|
||||
@@ -90,7 +91,7 @@ KoptOptions = {
|
||||
"resources/icons/appbar.align.justify.png",
|
||||
},
|
||||
values = {-1,0,1,2,3},
|
||||
default_value = -1,
|
||||
default_value = DKOPTREADER_CONFIG_JUSTIFICATION,
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -105,7 +106,7 @@ KoptOptions = {
|
||||
height = 60,
|
||||
item_font_size = {22,24,28,32,34,36,38,42,46,50},
|
||||
values = {0.1, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0, 4.0},
|
||||
default_value = 1.0,
|
||||
default_value = DKOPTREADER_CONFIG_FONT_SIZE,
|
||||
event = "FontSizeUpdate",
|
||||
},
|
||||
{
|
||||
@@ -132,7 +133,7 @@ KoptOptions = {
|
||||
item_font_size = 18,
|
||||
item_align_center = 0.8,
|
||||
values = {2.0, 1.5, 1.0, 0.5, 0.2},
|
||||
default_value = 1.0,
|
||||
default_value = DKOPTREADER_CONFIG_CONTRAST,
|
||||
event = "GammaUpdate",
|
||||
args = {0.5, 0.8, 1.0, 2.0, 4.0},
|
||||
}
|
||||
@@ -146,7 +147,7 @@ KoptOptions = {
|
||||
name_text = _("Reflow"),
|
||||
toggle = {ON_STR, OFF_STR},
|
||||
values = {1, 0},
|
||||
default_value = 0,
|
||||
default_value = DKOPTREADER_CONFIG_TEXT_WRAP,
|
||||
events = {
|
||||
{
|
||||
event = "RedrawCurrentPage",
|
||||
@@ -171,14 +172,14 @@ KoptOptions = {
|
||||
name_text = WORD_GAP_STR,
|
||||
toggle = {SMALL_STR, MEDIUM_STR, LARGE_STR},
|
||||
values = {0.05, 0.15, 0.375},
|
||||
default_value = 0.15,
|
||||
default_value = DKOPTREADER_CONFIG_WORD_SAPCING,
|
||||
},
|
||||
{
|
||||
name = "defect_size",
|
||||
name_text = DEFECT_SIZE_STR,
|
||||
toggle = {SMALL_STR, MEDIUM_STR, LARGE_STR},
|
||||
values = {1.0, 8.0, 15.0},
|
||||
default_value = 1.0,
|
||||
default_value = DKOPTREADER_CONFIG_DEFECT_SIZE,
|
||||
event = "DefectSizeUpdate",
|
||||
},
|
||||
{
|
||||
@@ -186,21 +187,21 @@ KoptOptions = {
|
||||
name_text = RENDER_QUALITY_STR,
|
||||
toggle = {LOW_STR, DEFAULT_STR, HIGH_STR},
|
||||
values={0.5, 1.0, 1.5},
|
||||
default_value = 0.8,
|
||||
default_value = DKOPTREADER_CONFIG_RENDER_QUALITY,
|
||||
},
|
||||
{
|
||||
name = "auto_straighten",
|
||||
name_text = AUTO_STRAIGHTEN_STR,
|
||||
toggle = {ZERO_DEG_STR, FIVE_DEG_STR, TEN_DEG_STR},
|
||||
values = {0, 5, 10},
|
||||
default_value = 0,
|
||||
default_value = DKOPTREADER_CONFIG_AUTO_STRAIGHTEN,
|
||||
},
|
||||
{
|
||||
name = "detect_indent",
|
||||
name_text = INDENTATION_STR,
|
||||
toggle = {ON_STR, OFF_STR},
|
||||
values = {1, 0},
|
||||
default_value = 1,
|
||||
default_value = DKOPTREADER_CONFIG_DETECT_INDENT,
|
||||
show = false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require "ui/reader/readerflip"
|
||||
require "ui/reader/readerfooter"
|
||||
require "ui/reader/readerdogear"
|
||||
require "defaults"
|
||||
|
||||
ReaderView = OverlapGroup:new{
|
||||
document = nil,
|
||||
@@ -15,7 +16,7 @@ ReaderView = OverlapGroup:new{
|
||||
offset = nil,
|
||||
bbox = nil,
|
||||
},
|
||||
outer_page_color = 0,
|
||||
outer_page_color = DOUTER_PAGE_COLOR,
|
||||
-- hightlight
|
||||
highlight = {
|
||||
lighten_color = 0.2, -- color range [0.0, 1.0]
|
||||
@@ -27,7 +28,7 @@ ReaderView = OverlapGroup:new{
|
||||
highlight_visible = true,
|
||||
-- PDF/DjVu continuous paging
|
||||
page_scroll = nil,
|
||||
page_bgcolor = 0,
|
||||
page_bgcolor = DBACKGROUND_COLOR,
|
||||
page_states = {},
|
||||
scroll_mode = "vertical",
|
||||
page_gap = {
|
||||
@@ -36,9 +37,9 @@ ReaderView = OverlapGroup:new{
|
||||
color = 8,
|
||||
},
|
||||
-- DjVu page rendering mode (used in djvu.c:drawPage())
|
||||
render_mode = 0, -- default to COLOR
|
||||
render_mode = DRENDER_MODE, -- default to COLOR
|
||||
-- Crengine view mode
|
||||
view_mode = "page", -- default to page mode
|
||||
view_mode = DCREREADER_VIEW_MODE, -- default to page mode
|
||||
hinting = true,
|
||||
|
||||
-- visible area within current viewing page
|
||||
@@ -105,17 +106,14 @@ function ReaderView:paintTo(bb, x, y)
|
||||
self.dim_area.w, self.dim_area.h
|
||||
)
|
||||
end
|
||||
|
||||
-- draw saved highlight
|
||||
if self.highlight_visible then
|
||||
self:drawSavedHighlight(bb, x, y)
|
||||
end
|
||||
|
||||
-- draw temporary highlight
|
||||
if self.highlight.temp then
|
||||
self:drawTempHighlight(bb, x, y)
|
||||
end
|
||||
|
||||
-- paint dogear
|
||||
if self.dogear_visible then
|
||||
self.dogear:paintTo(bb, x, y)
|
||||
@@ -478,7 +476,7 @@ function ReaderView:onReadSettings(config)
|
||||
table.insert(self.ui.postInitCallback, function()
|
||||
self:onSetScreenMode(screen_mode) end)
|
||||
end
|
||||
self.state.gamma = config:readSetting("gamma") or 1.0
|
||||
self.state.gamma = config:readSetting("gamma") or DGLOBALGAMMA
|
||||
local full_screen = config:readSetting("kopt_full_screen")
|
||||
if full_screen == nil then
|
||||
full_screen = self.document.configurable.full_screen
|
||||
|
||||
@@ -4,6 +4,7 @@ require "ui/inputevent"
|
||||
require "ui/screen"
|
||||
require "debug"
|
||||
require "gettext"
|
||||
require "defaults"
|
||||
|
||||
-- initialize output module, this must be initialized before Input
|
||||
Screen:init()
|
||||
@@ -23,7 +24,7 @@ UIManager = {
|
||||
-- after each ui loop
|
||||
full_refresh = false,
|
||||
-- trigger a full refresh when counter reaches FULL_REFRESH_COUNT
|
||||
FULL_REFRESH_COUNT = 6,
|
||||
FULL_REFRESH_COUNT = DRCOUNTMAX,
|
||||
refresh_count = 0,
|
||||
|
||||
_running = true,
|
||||
|
||||
Reference in New Issue
Block a user