mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
mod: load css in crereader
This commit is contained in:
11
cre.cpp
11
cre.cpp
@@ -36,19 +36,26 @@ typedef struct CreDocument {
|
||||
static int openDocument(lua_State *L) {
|
||||
const char *file_name = luaL_checkstring(L, 1);
|
||||
const char *style_sheet = luaL_checkstring(L, 2);
|
||||
|
||||
int width = luaL_checkint(L, 3);
|
||||
int height = luaL_checkint(L, 4);
|
||||
lString8 css;
|
||||
|
||||
CreDocument *doc = (CreDocument*) lua_newuserdata(L, sizeof(CreDocument));
|
||||
luaL_getmetatable(L, "credocument");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
doc->text_view = new LVDocView();
|
||||
doc->text_view->setStyleSheet(lString8(style_sheet));
|
||||
doc->text_view->setBackgroundColor(0x000000);
|
||||
doc->text_view->LoadDocument(file_name);
|
||||
if (LVLoadStylesheetFile(lString16(style_sheet), css)){
|
||||
if (!css.empty()){
|
||||
doc->text_view->setStyleSheet(css);
|
||||
}
|
||||
}
|
||||
doc->text_view->setViewMode(DVM_SCROLL, -1);
|
||||
doc->text_view->Resize(width, height);
|
||||
|
||||
doc->text_view->LoadDocument(file_name);
|
||||
doc->text_view->Render();
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user