From 9dd3994dd8dde2f4826ca4c96e82cd54e8313fec Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Wed, 14 Mar 2012 17:20:48 +0800 Subject: [PATCH 1/6] fix: handle LPGBCK and LPGFWD in selectmenu --- selectmenu.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selectmenu.lua b/selectmenu.lua index fd8116dc0..3572a5c99 100644 --- a/selectmenu.lua +++ b/selectmenu.lua @@ -195,7 +195,7 @@ function SelectMenu:choose(ypos, height) prevItem() elseif ev.code == KEY_FW_DOWN then nextItem() - elseif ev.code == KEY_PGFWD then + elseif ev.code == KEY_PGFWD or ev.code == KEY_LPGFWD then if self.page < (self.items / perpage) then if self.current + self.page*perpage > self.items then self.current = self.items - self.page*perpage @@ -206,7 +206,7 @@ function SelectMenu:choose(ypos, height) self.current = self.items - (self.page-1)*perpage markerdirty = true end - elseif ev.code == KEY_PGBCK then + elseif ev.code == KEY_PGBCK or ev.code == KEY_LPGBCK then if self.page > 1 then self.page = self.page - 1 pagedirty = true From c8f87d5661208896a0529b020dae3448b53b85a9 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 16 Mar 2012 12:27:27 +0800 Subject: [PATCH 2/6] fix: remove page number checking in displaying TOC Former showTOC() method checks the page number in each entry and only display entry whose page number is greater than the previous one. However, I think this is too "clever", we should better leave the TOC untouched to keep consistent with other pdf readers. --- pdf.c | 5 +++-- unireader.lua | 10 +++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pdf.c b/pdf.c index e079c54b6..1091ecc6a 100644 --- a/pdf.c +++ b/pdf.c @@ -101,16 +101,17 @@ static int walkTableOfContent(lua_State *L, fz_outline* ol, int *count, int dept lua_pushstring(L, "page"); lua_pushnumber(L, ol->dest.ld.gotor.page + 1); lua_settable(L, -3); + lua_pushstring(L, "depth"); lua_pushnumber(L, depth); lua_settable(L, -3); - lua_pushstring(L, "title"); + lua_pushstring(L, "title"); lua_pushstring(L, ol->title); lua_settable(L, -3); - lua_settable(L, -3); + lua_settable(L, -3); (*count)++; if (ol->down) { walkTableOfContent(L, ol->down, count, depth); diff --git a/unireader.lua b/unireader.lua index 61fd3e26a..c81262b89 100644 --- a/unireader.lua +++ b/unireader.lua @@ -678,15 +678,11 @@ function UniReader:showTOC() end local menu_items = {} local filtered_toc = {} - local curr_page = -1 -- build menu items for _k,_v in ipairs(self.toc) do - if(_v.page >= curr_page) then - table.insert(menu_items, - (" "):rep(_v.depth-1)..self:cleanUpTOCTitle(_v.title)) - table.insert(filtered_toc,_v.page) - curr_page = _v.page - end + table.insert(menu_items, + (" "):rep(_v.depth-1)..self:cleanUpTOCTitle(_v.title)) + table.insert(filtered_toc,_v.page) end toc_menu = SelectMenu:new{ menu_title = "Table of Contents", From 7b120b0ee026790f4b73548fa5b1c9119e04b896 Mon Sep 17 00:00:00 2001 From: HW Date: Sun, 18 Mar 2012 11:48:26 +0100 Subject: [PATCH 3/6] allow easier customization of toolchain for libdjvu --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7a1e19509..1556b31b0 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ LFSDIR=luafilesystem CC:=arm-unknown-linux-gnueabi-gcc CXX:=arm-unknown-linux-gnueabi-g++ +HOST:=arm-unknown-linux-gnueabi ifdef SBOX_UNAME_MACHINE CC:=gcc CXX:=g++ @@ -133,7 +134,7 @@ $(DJVULIBS): ifdef EMULATE_READER cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static else - cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=arm-kindle-linux-gnueabi + cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST) endif make -C $(DJVUDIR)/build From 929ea1e703d7f6636837a59c141eba91d506a13e Mon Sep 17 00:00:00 2001 From: HW Date: Mon, 19 Mar 2012 18:24:43 +0100 Subject: [PATCH 4/6] removed obsolete page rotation handling, closes #70 --- pdf.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pdf.c b/pdf.c index 1091ecc6a..038a354aa 100644 --- a/pdf.c +++ b/pdf.c @@ -240,15 +240,15 @@ static int openPage(lua_State *L) { static int getPageSize(lua_State *L) { fz_matrix ctm; + fz_rect bounds; fz_rect bbox; PdfPage *page = (PdfPage*) luaL_checkudata(L, 1, "pdfpage"); DrawContext *dc = (DrawContext*) luaL_checkudata(L, 2, "drawcontext"); - ctm = fz_translate(0, -page->page->mediabox.y1); - ctm = fz_concat(ctm, fz_scale(dc->zoom, -dc->zoom)); - ctm = fz_concat(ctm, fz_rotate(page->page->rotate)); + bounds = fz_bound_page(page->doc->xref, page->page); + ctm = fz_scale(dc->zoom, dc->zoom) ; ctm = fz_concat(ctm, fz_rotate(dc->rotate)); - bbox = fz_transform_rect(ctm, page->page->mediabox); + bbox = fz_transform_rect(ctm, bounds); lua_pushnumber(L, bbox.x1-bbox.x0); lua_pushnumber(L, bbox.y1-bbox.y0); @@ -264,7 +264,6 @@ static int getUsedBBox(lua_State *L) { /* returned BBox is in centi-point (n * 0.01 pt) */ ctm = fz_scale(100, 100); - ctm = fz_concat(ctm, fz_rotate(page->page->rotate)); fz_try(page->doc->context) { dev = fz_new_bbox_device(page->doc->context, &result); @@ -312,7 +311,6 @@ static int drawPage(lua_State *L) { fz_clear_pixmap_with_value(page->doc->context, pix, 0xff); ctm = fz_scale(dc->zoom, dc->zoom); - ctm = fz_concat(ctm, fz_rotate(page->page->rotate)); ctm = fz_concat(ctm, fz_rotate(dc->rotate)); ctm = fz_concat(ctm, fz_translate(dc->offset_x, dc->offset_y)); dev = fz_new_draw_device(page->doc->context, pix); From 9ee7afa86d6e18ad67c2203f21c8a69847ad35d8 Mon Sep 17 00:00:00 2001 From: HW Date: Mon, 19 Mar 2012 18:59:36 +0100 Subject: [PATCH 5/6] separate DC out of pdf.c and djvu.c (cleanup) --- djvu.c | 100 +----------------------------------------- djvureader.lua | 11 +---- drawcontext.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ drawcontext.h | 35 +++++++++++++++ kpdfview.c | 2 + pdf.c | 98 +---------------------------------------- pdfreader.lua | 11 +---- unireader.lua | 8 +--- 8 files changed, 160 insertions(+), 222 deletions(-) create mode 100644 drawcontext.c create mode 100644 drawcontext.h diff --git a/djvu.c b/djvu.c index d2b804662..76617399a 100644 --- a/djvu.c +++ b/djvu.c @@ -20,6 +20,7 @@ #include "string.h" #include "blitbuffer.h" +#include "drawcontext.h" #include "djvu.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -40,14 +41,6 @@ typedef struct DjvuPage { DjvuDocument *doc; } DjvuPage; -typedef struct DrawContext { - int rotate; - double zoom; - double gamma; - int offset_x; - int offset_y; -} DrawContext; - static int handle(lua_State *L, ddjvu_context_t *ctx, int wait) { @@ -177,77 +170,6 @@ static int getTableOfContent(lua_State *L) { return 1; } -static int newDrawContext(lua_State *L) { - int rotate = luaL_optint(L, 1, 0); - double zoom = luaL_optnumber(L, 2, (double) 1.0); - int offset_x = luaL_optint(L, 3, 0); - int offset_y = luaL_optint(L, 4, 0); - double gamma = luaL_optnumber(L, 5, (double) -1.0); - - DrawContext *dc = (DrawContext*) lua_newuserdata(L, sizeof(DrawContext)); - dc->rotate = rotate; - dc->zoom = zoom; - dc->offset_x = offset_x; - dc->offset_y = offset_y; - dc->gamma = gamma; - - - luaL_getmetatable(L, "drawcontext"); - lua_setmetatable(L, -2); - - return 1; -} - -static int dcSetOffset(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->offset_x = luaL_checkint(L, 2); - dc->offset_y = luaL_checkint(L, 3); - return 0; -} - -static int dcGetOffset(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushinteger(L, dc->offset_x); - lua_pushinteger(L, dc->offset_y); - return 2; -} - -static int dcSetRotate(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->rotate = luaL_checkint(L, 2); - return 0; -} - -static int dcSetZoom(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->zoom = luaL_checknumber(L, 2); - return 0; -} - -static int dcGetRotate(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushinteger(L, dc->rotate); - return 1; -} - -static int dcGetZoom(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushnumber(L, dc->zoom); - return 1; -} - -static int dcSetGamma(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->gamma = luaL_checknumber(L, 2); - return 0; -} - -static int dcGetGamma(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushnumber(L, dc->gamma); - return 1; -} - static int openPage(lua_State *L) { ddjvu_status_t r; DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument"); @@ -407,7 +329,6 @@ static int drawPage(lua_State *L) { static const struct luaL_reg djvu_func[] = { {"openDocument", openDocument}, - {"newDC", newDrawContext}, {NULL, NULL} }; @@ -429,18 +350,6 @@ static const struct luaL_reg djvupage_meth[] = { {NULL, NULL} }; -static const struct luaL_reg drawcontext_meth[] = { - {"setRotate", dcSetRotate}, - {"getRotate", dcGetRotate}, - {"setZoom", dcSetZoom}, - {"getZoom", dcGetZoom}, - {"setOffset", dcSetOffset}, - {"getOffset", dcGetOffset}, - {"setGamma", dcSetGamma}, - {"getGamma", dcGetGamma}, - {NULL, NULL} -}; - int luaopen_djvu(lua_State *L) { luaL_newmetatable(L, "djvudocument"); lua_pushstring(L, "__index"); @@ -456,13 +365,6 @@ int luaopen_djvu(lua_State *L) { luaL_register(L, NULL, djvupage_meth); lua_pop(L, 1); - luaL_newmetatable(L, "drawcontext"); - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); - lua_settable(L, -3); - luaL_register(L, NULL, drawcontext_meth); - lua_pop(L, 1); - luaL_register(L, "djvu", djvu_func); return 1; } diff --git a/djvureader.lua b/djvureader.lua index e929f765d..1b4b37697 100644 --- a/djvureader.lua +++ b/djvureader.lua @@ -1,15 +1,6 @@ require "unireader" -DJVUReader = UniReader:new{ - newDC = function() - print("djvu.newDC") - return djvu.newDC() - end, -} - -function DJVUReader:init() - self.nulldc = self.newDC() -end +DJVUReader = UniReader:new{} -- open a DJVU file and its settings store -- DJVU does not support password yet diff --git a/drawcontext.c b/drawcontext.c new file mode 100644 index 000000000..1dacb1298 --- /dev/null +++ b/drawcontext.c @@ -0,0 +1,117 @@ +/* + KindlePDFViewer: a DC abstraction + Copyright (C) 2012 Hans-Werner Hilse + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "drawcontext.h" + +static int newDrawContext(lua_State *L) { + int rotate = luaL_optint(L, 1, 0); + double zoom = luaL_optnumber(L, 2, (double) 1.0); + int offset_x = luaL_optint(L, 3, 0); + int offset_y = luaL_optint(L, 4, 0); + double gamma = luaL_optnumber(L, 5, (double) -1.0); + + DrawContext *dc = (DrawContext*) lua_newuserdata(L, sizeof(DrawContext)); + dc->rotate = rotate; + dc->zoom = zoom; + dc->offset_x = offset_x; + dc->offset_y = offset_y; + dc->gamma = gamma; + + luaL_getmetatable(L, "drawcontext"); + lua_setmetatable(L, -2); + + return 1; +} + +static int dcSetOffset(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + dc->offset_x = luaL_checkint(L, 2); + dc->offset_y = luaL_checkint(L, 3); + return 0; +} + +static int dcGetOffset(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + lua_pushinteger(L, dc->offset_x); + lua_pushinteger(L, dc->offset_y); + return 2; +} + +static int dcSetRotate(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + dc->rotate = luaL_checkint(L, 2); + return 0; +} + +static int dcSetZoom(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + dc->zoom = luaL_checknumber(L, 2); + return 0; +} + +static int dcGetRotate(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + lua_pushinteger(L, dc->rotate); + return 1; +} + +static int dcGetZoom(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + lua_pushnumber(L, dc->zoom); + return 1; +} + +static int dcSetGamma(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + dc->gamma = luaL_checknumber(L, 2); + return 0; +} + +static int dcGetGamma(lua_State *L) { + DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); + lua_pushnumber(L, dc->gamma); + return 1; +} + +static const struct luaL_reg drawcontext_meth[] = { + {"setRotate", dcSetRotate}, + {"getRotate", dcGetRotate}, + {"setZoom", dcSetZoom}, + {"getZoom", dcGetZoom}, + {"setOffset", dcSetOffset}, + {"getOffset", dcGetOffset}, + {"setGamma", dcSetGamma}, + {"getGamma", dcGetGamma}, + {NULL, NULL} +}; + +static const struct luaL_reg drawcontext_func[] = { + {"new", newDrawContext}, + {NULL, NULL} +}; + +int luaopen_drawcontext(lua_State *L) { + luaL_newmetatable(L, "drawcontext"); + lua_pushstring(L, "__index"); + lua_pushvalue(L, -2); + lua_settable(L, -3); + luaL_register(L, NULL, drawcontext_meth); + lua_pop(L, 1); + luaL_register(L, "DrawContext", drawcontext_func); + return 1; +} diff --git a/drawcontext.h b/drawcontext.h new file mode 100644 index 000000000..c8440afb5 --- /dev/null +++ b/drawcontext.h @@ -0,0 +1,35 @@ +/* + KindlePDFViewer: a DC abstraction + Copyright (C) 2012 Hans-Werner Hilse + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#ifndef _DRAWCONTEXT_H +#define _DRAWCONTEXT_H + +#include +#include +#include + +typedef struct DrawContext { + int rotate; + double zoom; + double gamma; + int offset_x; + int offset_y; +} DrawContext; + +int luaopen_drawcontext(lua_State *L); +#endif + diff --git a/kpdfview.c b/kpdfview.c index 9ce45652c..d14a38053 100644 --- a/kpdfview.c +++ b/kpdfview.c @@ -24,6 +24,7 @@ #include #include "blitbuffer.h" +#include "drawcontext.h" #include "pdf.h" #include "einkfb.h" #include "input.h" @@ -48,6 +49,7 @@ int main(int argc, char **argv) { luaL_openlibs(L); luaopen_blitbuffer(L); + luaopen_drawcontext(L); luaopen_einkfb(L); luaopen_pdf(L); luaopen_djvu(L); diff --git a/pdf.c b/pdf.c index 038a354aa..5644300fc 100644 --- a/pdf.c +++ b/pdf.c @@ -19,6 +19,7 @@ #include #include "blitbuffer.h" +#include "drawcontext.h" #include "pdf.h" typedef struct PdfDocument { @@ -36,14 +37,6 @@ typedef struct PdfPage { PdfDocument *doc; } PdfPage; -typedef struct DrawContext { - int rotate; - double zoom; - double gamma; - int offset_x; - int offset_y; -} DrawContext; - static int openDocument(lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *password = luaL_checkstring(L, 2); @@ -140,76 +133,6 @@ static int getTableOfContent(lua_State *L) { return 1; } -static int newDrawContext(lua_State *L) { - int rotate = luaL_optint(L, 1, 0); - double zoom = luaL_optnumber(L, 2, (double) 1.0); - int offset_x = luaL_optint(L, 3, 0); - int offset_y = luaL_optint(L, 4, 0); - double gamma = luaL_optnumber(L, 5, (double) -1.0); - - DrawContext *dc = (DrawContext*) lua_newuserdata(L, sizeof(DrawContext)); - dc->rotate = rotate; - dc->zoom = zoom; - dc->offset_x = offset_x; - dc->offset_y = offset_y; - dc->gamma = gamma; - - luaL_getmetatable(L, "drawcontext"); - lua_setmetatable(L, -2); - - return 1; -} - -static int dcSetOffset(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->offset_x = luaL_checkint(L, 2); - dc->offset_y = luaL_checkint(L, 3); - return 0; -} - -static int dcGetOffset(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushinteger(L, dc->offset_x); - lua_pushinteger(L, dc->offset_y); - return 2; -} - -static int dcSetRotate(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->rotate = luaL_checkint(L, 2); - return 0; -} - -static int dcSetZoom(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->zoom = luaL_checknumber(L, 2); - return 0; -} - -static int dcGetRotate(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushinteger(L, dc->rotate); - return 1; -} - -static int dcGetZoom(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushnumber(L, dc->zoom); - return 1; -} - -static int dcSetGamma(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - dc->gamma = luaL_checknumber(L, 2); - return 0; -} - -static int dcGetGamma(lua_State *L) { - DrawContext *dc = (DrawContext*) luaL_checkudata(L, 1, "drawcontext"); - lua_pushnumber(L, dc->gamma); - return 1; -} - static int openPage(lua_State *L) { fz_device *dev; @@ -353,7 +276,6 @@ static int drawPage(lua_State *L) { static const struct luaL_reg pdf_func[] = { {"openDocument", openDocument}, - {"newDC", newDrawContext}, {NULL, NULL} }; @@ -375,18 +297,6 @@ static const struct luaL_reg pdfpage_meth[] = { {NULL, NULL} }; -static const struct luaL_reg drawcontext_meth[] = { - {"setRotate", dcSetRotate}, - {"getRotate", dcGetRotate}, - {"setZoom", dcSetZoom}, - {"getZoom", dcGetZoom}, - {"setOffset", dcSetOffset}, - {"getOffset", dcGetOffset}, - {"setGamma", dcSetGamma}, - {"getGamma", dcGetGamma}, - {NULL, NULL} -}; - int luaopen_pdf(lua_State *L) { luaL_newmetatable(L, "pdfdocument"); lua_pushstring(L, "__index"); @@ -400,12 +310,6 @@ int luaopen_pdf(lua_State *L) { lua_settable(L, -3); luaL_register(L, NULL, pdfpage_meth); lua_pop(L, 1); - luaL_newmetatable(L, "drawcontext"); - lua_pushstring(L, "__index"); - lua_pushvalue(L, -2); - lua_settable(L, -3); - luaL_register(L, NULL, drawcontext_meth); - lua_pop(L, 1); luaL_register(L, "pdf", pdf_func); return 1; } diff --git a/pdfreader.lua b/pdfreader.lua index 5bd12aa73..2af16f1cb 100644 --- a/pdfreader.lua +++ b/pdfreader.lua @@ -1,15 +1,6 @@ require "unireader" -PDFReader = UniReader:new{ - newDC = function() - print("pdf.newDC") - return pdf.newDC() - end, -} - -function PDFReader:init() - self.nulldc = self.newDC(); -end +PDFReader = UniReader:new{} -- open a PDF file and its settings store function PDFReader:open(filename, password) diff --git a/unireader.lua b/unireader.lua index c81262b89..27251a486 100644 --- a/unireader.lua +++ b/unireader.lua @@ -55,10 +55,8 @@ UniReader = { -- the document's setting store: settings = nil, - -- you have to initialize newDC, nulldc in specific reader - newDC = function() return nil end, -- we will use this one often, so keep it "static": - nulldc = nil, + nulldc = DrawContext.new(), -- tile cache configuration: cache_max_memsize = 1024*1024*5, -- 5MB tile cache @@ -87,13 +85,11 @@ end For a new specific reader, you must always overwrite following two methods: - * self:init() * self:open() overwrite other methods if needed. --]] function UniReader:init() - print("empty initialization method!") end -- open a file and its settings store @@ -286,7 +282,7 @@ end -- set viewer state according to zoom state function UniReader:setzoom(page) - local dc = self.newDC() + local dc = DrawContext.new() local pwidth, pheight = page:getSize(self.nulldc) print("# page::getSize "..pwidth.."*"..pheight); local x0, y0, x1, y1 = page:getUsedBBox() From 8869c52c31331e3b38125f3d72fb760d03c2c212 Mon Sep 17 00:00:00 2001 From: HW Date: Mon, 19 Mar 2012 19:11:32 +0100 Subject: [PATCH 6/6] fix a Lua 5.0 syntax that was deprecated in 5.1 luaL_reg is now renamed to luaL_Reg. Lua 5.2 does not know about the old name anymore, Lua 5.1.x had backward compatibility. --- blitbuffer.c | 4 ++-- djvu.c | 6 +++--- drawcontext.c | 4 ++-- einkfb.c | 4 ++-- ft.c | 4 ++-- input.c | 2 +- pdf.c | 6 +++--- util.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/blitbuffer.c b/blitbuffer.c index c8a51de7f..93642fd61 100644 --- a/blitbuffer.c +++ b/blitbuffer.c @@ -366,12 +366,12 @@ static int paintRect(lua_State *L) { return 0; } -static const struct luaL_reg blitbuffer_func[] = { +static const struct luaL_Reg blitbuffer_func[] = { {"new", newBlitBuffer}, {NULL, NULL} }; -static const struct luaL_reg blitbuffer_meth[] = { +static const struct luaL_Reg blitbuffer_meth[] = { {"getWidth", getWidth}, {"getHeight", getHeight}, {"blitFrom", blitToBuffer}, diff --git a/djvu.c b/djvu.c index 76617399a..43ed4d28c 100644 --- a/djvu.c +++ b/djvu.c @@ -327,12 +327,12 @@ static int drawPage(lua_State *L) { return 0; } -static const struct luaL_reg djvu_func[] = { +static const struct luaL_Reg djvu_func[] = { {"openDocument", openDocument}, {NULL, NULL} }; -static const struct luaL_reg djvudocument_meth[] = { +static const struct luaL_Reg djvudocument_meth[] = { {"openPage", openPage}, {"getPages", getNumberOfPages}, {"getTOC", getTableOfContent}, @@ -341,7 +341,7 @@ static const struct luaL_reg djvudocument_meth[] = { {NULL, NULL} }; -static const struct luaL_reg djvupage_meth[] = { +static const struct luaL_Reg djvupage_meth[] = { {"getSize", getPageSize}, {"getUsedBBox", getUsedBBox}, {"close", closePage}, diff --git a/drawcontext.c b/drawcontext.c index 1dacb1298..9a4ac5d5f 100644 --- a/drawcontext.c +++ b/drawcontext.c @@ -88,7 +88,7 @@ static int dcGetGamma(lua_State *L) { return 1; } -static const struct luaL_reg drawcontext_meth[] = { +static const struct luaL_Reg drawcontext_meth[] = { {"setRotate", dcSetRotate}, {"getRotate", dcGetRotate}, {"setZoom", dcSetZoom}, @@ -100,7 +100,7 @@ static const struct luaL_reg drawcontext_meth[] = { {NULL, NULL} }; -static const struct luaL_reg drawcontext_func[] = { +static const struct luaL_Reg drawcontext_func[] = { {"new", newDrawContext}, {NULL, NULL} }; diff --git a/einkfb.c b/einkfb.c index 4abb81b23..a1f7054f9 100644 --- a/einkfb.c +++ b/einkfb.c @@ -203,12 +203,12 @@ static int einkSetOrientation(lua_State *L) { } -static const struct luaL_reg einkfb_func[] = { +static const struct luaL_Reg einkfb_func[] = { {"open", openFrameBuffer}, {NULL, NULL} }; -static const struct luaL_reg einkfb_meth[] = { +static const struct luaL_Reg einkfb_meth[] = { {"close", closeFrameBuffer}, {"__gc", closeFrameBuffer}, {"refresh", einkUpdate}, diff --git a/ft.c b/ft.c index 5cfc9b69b..151ba4c48 100644 --- a/ft.c +++ b/ft.c @@ -181,7 +181,7 @@ static int doneFace(lua_State *L) { return 0; } -static const struct luaL_reg ft_face_meth[] = { +static const struct luaL_Reg ft_face_meth[] = { {"renderGlyph", renderGlyph}, {"hasKerning", hasKerning}, {"getKerning", getKerning}, @@ -190,7 +190,7 @@ static const struct luaL_reg ft_face_meth[] = { {NULL, NULL} }; -static const struct luaL_reg ft_func[] = { +static const struct luaL_Reg ft_func[] = { {"newFace", newFace}, {"newBuiltinFace", newBuiltinFace}, {NULL, NULL} diff --git a/input.c b/input.c index bca89fc4b..05eedaa49 100644 --- a/input.c +++ b/input.c @@ -144,7 +144,7 @@ static int waitForInput(lua_State *L) { #endif } -static const struct luaL_reg input_func[] = { +static const struct luaL_Reg input_func[] = { {"open", openInputDevice}, {"closeAll", closeInputDevices}, {"waitForEvent", waitForInput}, diff --git a/pdf.c b/pdf.c index 5644300fc..33c8b0720 100644 --- a/pdf.c +++ b/pdf.c @@ -274,12 +274,12 @@ static int drawPage(lua_State *L) { return 0; } -static const struct luaL_reg pdf_func[] = { +static const struct luaL_Reg pdf_func[] = { {"openDocument", openDocument}, {NULL, NULL} }; -static const struct luaL_reg pdfdocument_meth[] = { +static const struct luaL_Reg pdfdocument_meth[] = { {"openPage", openPage}, {"getPages", getNumberOfPages}, {"getTOC", getTableOfContent}, @@ -288,7 +288,7 @@ static const struct luaL_reg pdfdocument_meth[] = { {NULL, NULL} }; -static const struct luaL_reg pdfpage_meth[] = { +static const struct luaL_Reg pdfpage_meth[] = { {"getSize", getPageSize}, {"getUsedBBox", getUsedBBox}, {"close", closePage}, diff --git a/util.c b/util.c index 7da912fc0..571792bf4 100644 --- a/util.c +++ b/util.c @@ -46,7 +46,7 @@ static int utf8charcode(lua_State *L) { return 1; } -static const struct luaL_reg util_func[] = { +static const struct luaL_Reg util_func[] = { {"gettime", gettime}, {"utf8charcode", utf8charcode}, {NULL, NULL}