Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/addonloader/luaaddonstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ LuaAddonState::LuaAddonState(Library *luaLibrary, const std::string &name,
{"removeQuickPhraseHandler",
&LuaAddonState::removeQuickPhraseHandler},
{"commitString", &LuaAddonState::commitString},
{"forwardKey", &LuaAddonState::forwardKey},
{"standardPathLocate", &LuaAddonState::standardPathLocate},
{"UTF16ToUTF8", &LuaAddonState::UTF16ToUTF8},
{"UTF8ToUTF16", &LuaAddonState::UTF8ToUTF16},
Expand Down Expand Up @@ -378,6 +379,15 @@ std::tuple<> LuaAddonState::commitStringImpl(const char *str) {
return {};
}

std::tuple<> LuaAddonState::forwardKeyImpl(int keySym, int keyStates, bool release) {
if (auto *ic = inputContext_.get()) {
Key key(static_cast<KeySym>(keySym), static_cast<KeyStates>(keyStates));
ic->forwardKey(key, release);
}
return {};
}


bool LuaAddonState::handleQuickPhrase(
InputContext *ic, const std::string &input,
const QuickPhraseAddCandidateCallback &callback) {
Expand Down
8 changes: 8 additions & 0 deletions src/addonloader/luaaddonstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ class LuaAddonState {
// @function commitString
// @string str string to be commit to input context.
DEFINE_LUA_FUNCTION(commitString);
/// Send a key event to client.
// @function forwardKey
// @int keySym A keySym of the key event.
// @int keyStates A modifier states of the key event.
// @boolean release Whether this is a key release event.
DEFINE_LUA_FUNCTION(forwardKey);
/// Locate all files with given path and suffix.
// @function standardPathLocate
// @int type
Expand Down Expand Up @@ -230,6 +236,8 @@ class LuaAddonState {
standardPathLocateImpl(int type, const char *path, const char *suffix);

std::tuple<> commitStringImpl(const char *str);
std::tuple<> forwardKeyImpl(int keySym, int keyStates, bool release);

FCITX_ADDON_DEPENDENCY_LOADER(quickphrase, instance_->addonManager());

bool handleQuickPhrase(InputContext *ic, const std::string &input,
Expand Down