From 60b7ccb3cb389fe266796f7ca0a766752cf047e2 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 31 Mar 2012 13:38:33 +0200 Subject: [PATCH] added cleanCache bound to C key in menu #80 --- djvu.c | 12 ++++++++++-- unireader.lua | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/djvu.c b/djvu.c index 5f8d7935b..d60107920 100644 --- a/djvu.c +++ b/djvu.c @@ -450,7 +450,7 @@ static int drawPage(lua_State *L) { static int getCacheSize(lua_State *L) { DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument"); unsigned long size = ddjvu_cache_get_size(doc->context); - printf("ddjvu_cache_get_size = %d\n", size); + printf("## ddjvu_cache_get_size = %d\n", size); lua_pushnumber(L, size); return 1; } @@ -458,11 +458,18 @@ static int getCacheSize(lua_State *L) { static int setCacheSize(lua_State *L) { DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument"); int size = luaL_checkint(L, 2); - printf("ddjvu_cache_set_size = %d\n", size); + printf("## ddjvu_cache_set_size = %d\n", size); ddjvu_cache_set_size(doc->context, size); return 0; } +static int cleanCache(lua_State *L) { + DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument"); + printf("## ddjvu_cache_clear\n"); + ddjvu_cache_clear(doc->context); + return 0; +} + static const struct luaL_Reg djvu_func[] = { {"openDocument", openDocument}, {NULL, NULL} @@ -476,6 +483,7 @@ static const struct luaL_Reg djvudocument_meth[] = { {"close", closeDocument}, {"getCacheSize", getCacheSize}, {"setCacheSize", setCacheSize}, + {"cleanCache", cleanCache}, {"__gc", closeDocument}, {NULL, NULL} }; diff --git a/unireader.lua b/unireader.lua index 7ad8a6a6f..e23389aa4 100644 --- a/unireader.lua +++ b/unireader.lua @@ -140,6 +140,10 @@ function UniReader:setCacheSize(size) return end +function UniReader:cleanCache() + return +end + --[ following are default methods ]-- @@ -827,6 +831,8 @@ function UniReader:showMenu() if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then if ev.code == KEY_BACK or ev.code == KEY_MENU then return + elseif ev.code == KEY_C then + self.doc:cleanCache() end end end