mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
6
Makefile
6
Makefile
@@ -154,9 +154,9 @@ clean:
|
||||
-rm -f *.o kpdfview slider_watcher
|
||||
|
||||
cleanthirdparty:
|
||||
make -C $(LUADIR) clean
|
||||
make -C $(MUPDFDIR) clean
|
||||
#make -C $(CRENGINEDIR)/thirdparty/antiword clean
|
||||
-make -C $(LUADIR) clean
|
||||
-make -C $(MUPDFDIR) clean
|
||||
-make -C $(CRENGINEDIR)/thirdparty/antiword clean
|
||||
test -d $(CRENGINEDIR)/thirdparty/chmlib && make -C $(CRENGINEDIR)/thirdparty/chmlib clean || echo warn: chmlib folder not found
|
||||
test -d $(CRENGINEDIR)/thirdparty/libpng && (make -C $(CRENGINEDIR)/thirdparty/libpng clean) || echo warn: chmlib folder not found
|
||||
test -d $(CRENGINEDIR)/crengine && (make -C $(CRENGINEDIR)/crengine clean) || echo warn: chmlib folder not found
|
||||
|
||||
32
cre.cpp
32
cre.cpp
@@ -117,6 +117,22 @@ static int getPageFromXPointer(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getPosFromXPointer(lua_State *L) {
|
||||
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
|
||||
const char *xpointer_str = luaL_checkstring(L, 2);
|
||||
|
||||
int pos = 0;
|
||||
ldomXPointer xp = doc->dom_doc->createXPointer(lString16(xpointer_str));
|
||||
|
||||
lvPoint pt = xp.toPoint();
|
||||
if (pt.y > 0) {
|
||||
pos = pt.y;
|
||||
}
|
||||
lua_pushinteger(L, pos);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getCurrentPos(lua_State *L) {
|
||||
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
|
||||
|
||||
@@ -125,21 +141,6 @@ static int getCurrentPos(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//static int getPosFromXPointer(lua_State *L) {
|
||||
//CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
|
||||
//const char *xpointer_str = luaL_checkstring(L, 2);
|
||||
|
||||
//lvRect rc;
|
||||
//int pos;
|
||||
|
||||
//ldomXPointer *xp = NULL;
|
||||
//xp = doc->dom_doc->createXPointer(lString16(xpointer_str));
|
||||
//getCursorDocRect(*xp, rc);
|
||||
//pos =
|
||||
|
||||
//return 1;
|
||||
//}
|
||||
|
||||
static int getCurrentPercent(lua_State *L) {
|
||||
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
|
||||
|
||||
@@ -437,6 +438,7 @@ static const struct luaL_Reg credocument_meth[] = {
|
||||
{"getPages", getNumberOfPages},
|
||||
{"getCurrentPage", getCurrentPage},
|
||||
{"getPageFromXPointer", getPageFromXPointer},
|
||||
{"getPosFromXPointer", getPosFromXPointer},
|
||||
{"getCurrentPos", getCurrentPos},
|
||||
{"getCurrentPercent", getCurrentPercent},
|
||||
{"getXPointer", getXPointer},
|
||||
|
||||
@@ -271,6 +271,32 @@ end
|
||||
----------------------------------------------------
|
||||
-- bookmarks related methods
|
||||
----------------------------------------------------
|
||||
function CREReader:isBookmarkInSequence(a, b)
|
||||
return self.doc:getPosFromXPointer(a.page) < self.doc:getPosFromXPointer(b.page)
|
||||
end
|
||||
|
||||
function CREReader:nextBookMarkedPage()
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if self.pos < self.doc:getPosFromXPointer(v.page) then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function CREReader:prevBookMarkedPage()
|
||||
local pre_item = nil
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if self.pos <= self.doc:getPosFromXPointer(v) then
|
||||
if self.doc:getPosFromXPointer(pre_item) < self.pos then
|
||||
return pre_item
|
||||
end
|
||||
end
|
||||
pre_item = v
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function CREReader:showBookMarks()
|
||||
local menu_items = {}
|
||||
-- build menu items
|
||||
|
||||
Submodule kpvcrlib/crengine updated: 9988213449...b62d054cca
@@ -1447,6 +1447,10 @@ function UniReader:delJump(pageno)
|
||||
end
|
||||
end
|
||||
|
||||
function UniReader:isBookmarkInSequence(a, b)
|
||||
return a.page < b.page
|
||||
end
|
||||
|
||||
-- return nil if page already marked
|
||||
-- otherwise, return true
|
||||
function UniReader:addBookmark(pageno)
|
||||
@@ -1466,6 +1470,9 @@ function UniReader:addBookmark(pageno)
|
||||
notes = notes,
|
||||
}
|
||||
table.insert(self.bookmarks, mark_item)
|
||||
table.sort(self.bookmarks, function(a,b)
|
||||
return self:isBookmarkInSequence(a, b)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1730,6 +1737,28 @@ function UniReader:showBookMarks()
|
||||
end
|
||||
end
|
||||
|
||||
function UniReader:nextBookMarkedPage()
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if self.pageno < v.page then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function UniReader:prevBookMarkedPage()
|
||||
local pre_item = nil
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if self.pageno <= v.page then
|
||||
if pre_item.page < self.pageno then
|
||||
return pre_item
|
||||
end
|
||||
end
|
||||
pre_item = v
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function UniReader:showHighLight()
|
||||
local menu_items = {}
|
||||
local highlight_dict = {}
|
||||
|
||||
Reference in New Issue
Block a user