Skip to content

Commit 47ba71a

Browse files
committed
Merge pull request koreader#9 from NuPogodi/master
Hyphenation methods
2 parents 6c89c8b + 200c40d commit 47ba71a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cre.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ static int setGammaIndex(lua_State *L) {
7979
return 0;
8080
}
8181

82+
static int getHyphDictList(lua_State *L) {
83+
lua_newtable(L);
84+
HyphDictionaryList *list = HyphMan::getDictList();
85+
for(int i = 0; i < list->length(); i++) {
86+
lua_pushnumber(L, i+1);
87+
lua_pushstring(L, UnicodeToLocal(list->get(i)->getId()).c_str());
88+
lua_settable(L, -3);
89+
}
90+
return 1;
91+
}
92+
93+
static int getSelectedHyphDict(lua_State *L) {
94+
lua_pushstring(L, UnicodeToLocal(HyphMan::getSelectedDictionary()->getId()).c_str());
95+
return 1;
96+
}
97+
98+
static int setHyphDictionary(lua_State *L) {
99+
const char *id = luaL_checkstring(L, 1);
100+
HyphMan::getDictList()->activate((lString16)id);
101+
return 0;
102+
}
103+
82104
static int loadDocument(lua_State *L) {
83105
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
84106
const char *file_name = luaL_checkstring(L, 2);
@@ -657,6 +679,9 @@ static const struct luaL_Reg cre_func[] = {
657679
{"getGammaIndex", getGammaIndex},
658680
{"setGammaIndex", setGammaIndex},
659681
{"registerFont", registerFont},
682+
{"getHyphDictList", getHyphDictList},
683+
{"getSelectedHyphDict", getSelectedHyphDict},
684+
{"setHyphDictionary", setHyphDictionary},
660685
{NULL, NULL}
661686
};
662687

0 commit comments

Comments
 (0)