added cleanCache bound to C key in menu #80

pull/2/merge
Dobrica Pavlinusic 12 years ago
parent 91bd1277d7
commit 60b7ccb3cb

@ -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}
};

@ -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

Loading…
Cancel
Save