mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
6
Makefile
6
Makefile
@@ -38,8 +38,8 @@ UBUNTUTOUCH_SDL_DIR:=$(UBUNTUTOUCH_DIR)/ubuntu-touch-sdl
|
||||
WIN32_DIR=$(PLATFORM_DIR)/win32
|
||||
|
||||
# files to link from main directory
|
||||
INSTALL_FILES=reader.lua frontend resources defaults.lua datastorage.lua l10n tools \
|
||||
README.md COPYING
|
||||
INSTALL_FILES=reader.lua setupkoenv.lua frontend resources defaults.lua datastorage.lua \
|
||||
l10n tools README.md COPYING
|
||||
|
||||
# for gettext
|
||||
DOMAIN=koreader
|
||||
@@ -359,7 +359,7 @@ po:
|
||||
|
||||
static-check:
|
||||
@if which luacheck > /dev/null; then \
|
||||
luacheck -q frontend plugins; \
|
||||
luacheck -q {reader,setupkoenv,datastorage}.lua frontend plugins; \
|
||||
else \
|
||||
echo "[!] luacheck not found. "\
|
||||
"you can install it with 'luarocks install luacheck'"; \
|
||||
|
||||
@@ -34,13 +34,12 @@ function DataStorage:getSettingsDir()
|
||||
end
|
||||
|
||||
local function initDataDir()
|
||||
local data_dir = DataStorage:getDataDir()
|
||||
local sub_data_dirs = {
|
||||
"cache", "clipboard", "data", "history",
|
||||
"ota", "screenshots", "settings",
|
||||
}
|
||||
for _, dir in ipairs(sub_data_dirs) do
|
||||
local sub_data_dir = data_dir .. "/" .. dir
|
||||
local sub_data_dir = DataStorage:getDataDir() .. "/" .. dir
|
||||
if lfs.attributes(sub_data_dir, "mode") ~= "directory" then
|
||||
lfs.mkdir(sub_data_dir)
|
||||
end
|
||||
|
||||
@@ -27,7 +27,6 @@ local Blitbuffer = require("ffi/blitbuffer")
|
||||
Display quick lookup word definition
|
||||
]]
|
||||
local DictQuickLookup = InputContainer:new{
|
||||
wikipedia_button = true,
|
||||
results = nil,
|
||||
lookupword = nil,
|
||||
dictionary = nil,
|
||||
@@ -187,7 +186,7 @@ function DictQuickLookup:update()
|
||||
{
|
||||
{
|
||||
text = _("Wikipedia"),
|
||||
enabled = self:isWikipediaActive(),
|
||||
enabled = not self.wiki,
|
||||
callback = function()
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self:lookupWikipedia()
|
||||
@@ -273,7 +272,6 @@ function DictQuickLookup:update()
|
||||
self.dict_frame,
|
||||
}
|
||||
}
|
||||
self:nextWikipediaStatus()
|
||||
UIManager:setDirty("all", function()
|
||||
local update_region = self.dict_frame.dimen:combine(orig_dimen)
|
||||
DEBUG("update dict region", update_region)
|
||||
@@ -311,18 +309,6 @@ function DictQuickLookup:getHighlightText()
|
||||
end
|
||||
end
|
||||
|
||||
function DictQuickLookup:nextWikipediaStatus()
|
||||
if self.wikipedia_button then
|
||||
DictQuickLookup.wikipedia_button = false
|
||||
else
|
||||
DictQuickLookup.wikipedia_button = true
|
||||
end
|
||||
end
|
||||
|
||||
function DictQuickLookup:isWikipediaActive()
|
||||
return self.wikipedia_button
|
||||
end
|
||||
|
||||
function DictQuickLookup:isPrevDictAvaiable()
|
||||
return self.dict_index > 1
|
||||
end
|
||||
@@ -396,7 +382,6 @@ function DictQuickLookup:onTapCloseDict(arg, ges_ev)
|
||||
end
|
||||
|
||||
function DictQuickLookup:onClose()
|
||||
self:nextWikipediaStatus()
|
||||
UIManager:close(self)
|
||||
for i = #self.window_list, 1, -1 do
|
||||
local window = self.window_list[i]
|
||||
|
||||
6
kodev
6
kodev
@@ -379,6 +379,12 @@ case $1 in
|
||||
shift 1; kodev-run "$@" ;;
|
||||
test)
|
||||
shift 1; kodev-test "$@" ;;
|
||||
prompt)
|
||||
kodev-build
|
||||
pushd "${EMU_DIR}"
|
||||
./luajit -i setupkoenv.lua
|
||||
popd
|
||||
;;
|
||||
log)
|
||||
shift 1; kodev-log "$@" ;;
|
||||
--help | -h)
|
||||
|
||||
24
reader.lua
24
reader.lua
@@ -14,37 +14,19 @@ io.stdout:flush()
|
||||
|
||||
|
||||
-- load default settings
|
||||
require "defaults"
|
||||
require("defaults")
|
||||
local DataStorage = require("datastorage")
|
||||
pcall(dofile, DataStorage:getDataDir() .. "/defaults.persistent.lua")
|
||||
|
||||
-- set search path for 'require()'
|
||||
package.path =
|
||||
"common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" ..
|
||||
package.path
|
||||
package.cpath =
|
||||
"common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" ..
|
||||
package.cpath
|
||||
require("setupkoenv")
|
||||
|
||||
-- set search path for 'ffi.load()'
|
||||
local ffi = require("ffi")
|
||||
local util = require("ffi/util")
|
||||
ffi.cdef[[
|
||||
char *getenv(const char *name);
|
||||
int putenv(const char *envvar);
|
||||
int _putenv(const char *envvar);
|
||||
]]
|
||||
if ffi.os == "Windows" then
|
||||
ffi.C._putenv("PATH=libs;common;")
|
||||
end
|
||||
|
||||
local _ = require("gettext")
|
||||
-- read settings and check for language override
|
||||
-- has to be done before requiring other files because
|
||||
-- they might call gettext on load
|
||||
G_reader_settings = require("luasettings"):open(
|
||||
DataStorage:getDataDir().."/settings.reader.lua")
|
||||
local lang_locale = G_reader_settings:readSetting("language")
|
||||
local _ = require("gettext")
|
||||
if lang_locale then
|
||||
_.changeLang(lang_locale)
|
||||
end
|
||||
|
||||
31
setupkoenv.lua
Normal file
31
setupkoenv.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- set search path for 'require()'
|
||||
package.path =
|
||||
"common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" ..
|
||||
package.path
|
||||
package.cpath =
|
||||
"common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" ..
|
||||
package.cpath
|
||||
|
||||
-- set search path for 'ffi.load()'
|
||||
local ffi = require("ffi")
|
||||
ffi.cdef[[
|
||||
char *getenv(const char *name);
|
||||
int putenv(const char *envvar);
|
||||
int _putenv(const char *envvar);
|
||||
]]
|
||||
if ffi.os == "Windows" then
|
||||
ffi.C._putenv("PATH=libs;common;")
|
||||
end
|
||||
local ffi_load = ffi.load
|
||||
-- patch ffi.load for thirdparty luajit libraries
|
||||
ffi.load = function(lib)
|
||||
local loaded, re = pcall(ffi_load, lib)
|
||||
if loaded then return re end
|
||||
|
||||
local lib_path = package.searchpath(lib, "./lib?.so;./libs/lib?.so")
|
||||
if not lib_path then
|
||||
error('Not able to load dynamic library: ' .. lib)
|
||||
else
|
||||
return ffi_load(lib_path)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user