Skip to content

Commit

Permalink
bump crengine: support for a user hyphenation dictionary (#1374)
Browse files Browse the repository at this point in the history
Includes:
- Hyphenation: support for user dictionary
- User hyphenation dict: some memory cleanup fixes
  • Loading branch information
zwim committed May 30, 2021
1 parent 2d90d50 commit 502bba0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,6 +3495,29 @@ static int getImageDataFromPosition(lua_State *L) {
return 0;
}

static int setUserHyphenationDict(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *filename = luaL_checkstring(L, 2);
bool reload = lua_toboolean(L, 3);
lua_pushinteger(L, UserHyphDict::init(filename, reload));
return 1;
}

static int getHyphenationForWord(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *word = luaL_checkstring(L, 2);
lString32 hyphenation = UserHyphDict::getHyphenation(word);
lua_pushstring(L, UnicodeToLocal(hyphenation).c_str());
return 1;
}

static int getLowercasedWord(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *word = luaL_checkstring(L, 2);
lString32 word_str(word);
lua_pushstring(L, UnicodeToLocal(word_str.lowercase()).c_str());
return 1;
}

static const struct luaL_Reg cre_func[] = {
{"initCache", initCache},
Expand Down Expand Up @@ -3623,6 +3646,9 @@ static const struct luaL_Reg credocument_meth[] = {
{"getPageMapXPointerPageLabel", getPageMapXPointerPageLabel},
{"getPageMapVisiblePageLabels", getPageMapVisiblePageLabels},
{"hasNonLinearFlows", hasNonLinearFlows},
{"setUserHyphenationDict", setUserHyphenationDict},
{"getHyphenationForWord", getHyphenationForWord},
{"getLowercasedWord", getLowercasedWord},
{"readDefaults", readDefaults},
{"saveDefaults", saveDefaults},
{"close", closeDocument},
Expand Down

0 comments on commit 502bba0

Please sign in to comment.