-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added new function of SpansReg #367
Conversation
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
@ksqsf 可以请你帮忙review一下吗? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lua 部分不太熟跳过了,其余部分 LGTM。
int raw_set_vertices(lua_State *L) { | ||
C_State C; | ||
auto &spans = LuaType<Spans &>::todata(L, 1); | ||
if (lua_istable(L, 2)) { | ||
spans.Clear(); | ||
for (auto vertex : LuaType<vector<int>>::todata(L, 2, &C)) { | ||
if (vertex >=0) { | ||
spans.AddVertex(vertex); | ||
} | ||
} | ||
} | ||
else { | ||
luaL_error(L, "bad argument #2 to set_vertices (table expected, got %s)" , lua_typename(L, 2)); | ||
} | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我对 Lua API 不熟,这部分 skip 了。
inline Spans spans(const T &seg) { | ||
Spans res; | ||
if (auto phrase = As<Phrase>( | ||
Candidate::GetGenuineCandidate(seg.GetSelectedCandidate()))) { | ||
res.AddSpans(phrase->spans()); | ||
} | ||
res.AddSpan(seg.start, seg.end); | ||
return res; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和 librime Navigator 代码一致。
Co-authored-by: ksqsf <[email protected]>
擴展 Spans