code clean up for first demo

pull/2/merge
Qingping Hou 12 years ago
parent 41c46313ef
commit 2f9a44bfc6

@ -17,6 +17,7 @@
*/
#include <libdjvu/ddjvuapi.h>
#include "string.h"
#include "blitbuffer.h"
#include "djvu.h"
@ -107,6 +108,13 @@ static int closeDocument(lua_State *L) {
}
if(doc->context != NULL) {
ddjvu_context_release(doc->context);
/*@TODO fix this! 03.03 2012
* it works fine in EMU mode, but if I don't
* add this printf after context_release, kpfview
* simply exit after this function call! */
printf("remeber to fix this bug!\n");
doc->context = NULL;
}
}
@ -276,7 +284,7 @@ static int drawPage(lua_State *L) {
imagebuffer = malloc((bb->w)*(bb->h)+1);
/* fill pixel map with white color */
memset(imagebuffer, 0xFF, (bb->w)*(bb->h)+1);
memset((void *)imagebuffer, 0xFF, (bb->w)*(bb->h)+1);
pixelformat = ddjvu_format_create(DDJVU_FORMAT_GREY8, 0, NULL);
ddjvu_format_set_row_order(pixelformat, 1);

@ -337,8 +337,7 @@ function DJVUReader:inputloop()
self:goto(self.pageno + 1)
end
elseif ev.code == KEY_PGBCK or ev.code == KEY_LPGBCK then
if Keys.shiftmode then
self:setglobalzoom(self.globalzoom - 0.2)
if Keys.shiftmode then self:setglobalzoom(self.globalzoom - 0.2)
elseif Keys.altmode then
self:setglobalzoom(self.globalzoom - 0.1)
else
@ -386,7 +385,7 @@ function DJVUReader:inputloop()
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT)
end
elseif ev.code == KEY_T then
self:showTOC()
--self:showTOC()
elseif ev.code == KEY_B then
self:showJumpStack()
end

@ -46,7 +46,7 @@ function FileSearcher:readdir()
if lfs.attributes(d.."/"..f, "mode") == "directory"
and f ~= "." and f~= ".." and not string.match(f, "^%.[^.]") then
table.insert(new_dirs, d.."/"..f)
elseif string.match(f, ".+%.[pP][dD][fF]$") then
elseif string.match(f, ".+%.[pP][dD][fF]$") or string.match(f, ".+%.[dD][jJ][vV][uU]$") then
file_entry = {dir=d, name=f,}
table.insert(self.files, file_entry)
--print("file:"..d.."/"..f)
@ -261,12 +261,8 @@ function FileSearcher:choose(ypos, height, keywords)
pagedirty = true
elseif ev.code == KEY_ENTER or ev.code == KEY_FW_PRESS then
file_entry = self.result[perpage*(self.page-1)+self.current]
file_path = file_entry.dir .. "/" .. file_entry.name
if PDFReader:open(file_path,"") then -- TODO: query for password
PDFReader:goto(tonumber(PDFReader.settings:readsetting("last_page") or 1))
PDFReader:inputloop()
end
file_full_path = file_entry.dir .. "/" .. file_entry.name
openFile(file_full_path)
pagedirty = true
elseif ev.code == KEY_BACK then

@ -36,12 +36,14 @@ function openFile(filename)
local file_type = string.lower(string.match(filename, ".+%.(.+)"))
if file_type == "djvu" then
if DJVUReader:open(filename) then
DJVUReader:goto(tonumber(DJVUReader.settings:readsetting("last_page")) or 1)
page_num = DJVUReader.settings:readsetting("last_page") or 1
DJVUReader:goto(tonumber(page_num))
DJVUReader:inputloop()
end
elseif file_type == "pdf" then
if PDFReader:open(filename,"") then -- TODO: query for password
PDFReader:goto(tonumber(PDFReader.settings:readsetting("last_page") or 1))
page_num = PDFReader.settings:readsetting("last_page") or 1
PDFReader:goto(tonumber(page_num))
PDFReader:inputloop()
end
end

Loading…
Cancel
Save