-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1ac800
commit 3d4bbda
Showing
14 changed files
with
201 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_library(harmonyfrontend STATIC harmonyfrontend.cpp) | ||
target_link_libraries(harmonyfrontend Fcitx5::Core) | ||
|
||
configure_file(harmonyfrontend.conf.in.in harmonyfrontend.conf.in @ONLY) | ||
fcitx5_translate_desktop_file(${CMAKE_CURRENT_BINARY_DIR}/harmonyfrontend.conf.in harmonyfrontend.conf) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/harmonyfrontend.conf DESTINATION "${CMAKE_INSTALL_PREFIX}/share/fcitx5/addon" COMPONENT config) |
7 changes: 7 additions & 0 deletions
7
entry/src/main/cpp/harmonyfrontend/harmonyfrontend.conf.in.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Addon] | ||
Name=Harmony Frontend | ||
Type=StaticLibrary | ||
Library=libharmonyfrontend | ||
Category=Frontend | ||
Version=@PROJECT_VERSION@ | ||
Configurable=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "harmonyfrontend.h" | ||
|
||
namespace fcitx { | ||
HarmonyFrontend::HarmonyFrontend(Instance *instance) | ||
: instance_(instance), focusGroup_("harmony", instance->inputContextManager()) { | ||
createInputContext(); | ||
} | ||
|
||
void HarmonyFrontend::createInputContext() { | ||
ic_ = new HarmonyInputContext(this, instance_->inputContextManager()); | ||
ic_->setFocusGroup(&focusGroup_); | ||
} | ||
|
||
bool HarmonyFrontend::keyEvent(const Key &key, bool isRelease) { | ||
KeyEvent event(ic_, key, isRelease); | ||
ic_->keyEvent(event); | ||
return event.accepted(); | ||
} | ||
|
||
void HarmonyFrontend::focusIn() { ic_->focusIn(); } | ||
|
||
void HarmonyFrontend::focusOut() { ic_->focusOut(); } | ||
|
||
HarmonyInputContext::HarmonyInputContext(HarmonyFrontend *frontend, InputContextManager &inputContextManager) | ||
: InputContext(inputContextManager, ""), frontend_(frontend) { | ||
CapabilityFlags flags = CapabilityFlag::Preedit; | ||
setCapabilityFlags(flags); | ||
created(); | ||
} | ||
|
||
HarmonyInputContext::~HarmonyInputContext() { destroy(); } | ||
|
||
void HarmonyInputContext::commitStringImpl(const std::string &text) { FCITX_ERROR() << "commit " << text; } | ||
|
||
void HarmonyInputContext::updatePreeditImpl() { | ||
auto preedit = frontend_->instance()->outputFilter(this, inputPanel().clientPreedit()); | ||
FCITX_ERROR() << "setPreedit " << preedit.toString() << preedit.cursor(); | ||
} | ||
} // namespace fcitx | ||
|
||
FCITX_ADDON_FACTORY_V2(harmonyfrontend, fcitx::HarmonyFrontendFactory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <fcitx-config/configuration.h> | ||
#include <fcitx/addonfactory.h> | ||
#include <fcitx/addoninstance.h> | ||
#include <fcitx/addonmanager.h> | ||
#include <fcitx/focusgroup.h> | ||
#include <fcitx/instance.h> | ||
|
||
namespace fcitx { | ||
class HarmonyInputContext; | ||
|
||
class HarmonyFrontend : public AddonInstance { | ||
public: | ||
HarmonyFrontend(Instance *instance); | ||
Instance *instance() { return instance_; } | ||
|
||
void reloadConfig() override {} | ||
void save() override {} | ||
const Configuration *getConfig() const override { return nullptr; } | ||
void setConfig(const RawConfig &config) override {} | ||
|
||
void createInputContext(); | ||
bool keyEvent(const Key &key, bool isRelease); | ||
void focusIn(); | ||
void focusOut(); | ||
|
||
private: | ||
Instance *instance_; | ||
FocusGroup focusGroup_; | ||
HarmonyInputContext *ic_; | ||
}; | ||
|
||
class HarmonyFrontendFactory : public AddonFactory { | ||
public: | ||
AddonInstance *create(AddonManager *manager) override { return new HarmonyFrontend(manager->instance()); } | ||
}; | ||
|
||
class HarmonyInputContext : public InputContext { | ||
public: | ||
HarmonyInputContext(HarmonyFrontend *frontend, InputContextManager &inputContextManager); | ||
~HarmonyInputContext(); | ||
|
||
const char *frontend() const override { return "harmony"; } | ||
void commitStringImpl(const std::string &text) override; | ||
void deleteSurroundingTextImpl(int offset, unsigned int size) override {} | ||
void forwardKeyImpl(const ForwardKeyEvent &key) override {} | ||
void updatePreeditImpl() override; | ||
|
||
private: | ||
HarmonyFrontend *frontend_; | ||
}; | ||
} // namespace fcitx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
add_library(fcitx STATIC | ||
add_library(fcitx SHARED | ||
fcitx.cpp | ||
) | ||
target_link_libraries(fcitx Fcitx5::Core) | ||
target_link_libraries(fcitx Fcitx5::Core libhilog_ndk.z.so) | ||
|
||
fcitx5_import_addons(fcitx | ||
REGISTRY_VARNAME getStaticAddon | ||
ADDONS harmonyfrontend | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#include <string> | ||
|
||
namespace fcitx { | ||
void init(); | ||
void init(const std::string &bundle, const std::string &resfile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const add: (a: number, b: number) => number; | ||
export const init: (bundle: string, resfile: string) => void; |
4 changes: 4 additions & 0 deletions
4
entry/src/main/ets/InputMethodExtensionAbility/FcitxInputMethodService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { spawnSync } from 'child_process' | ||
import path from 'path' | ||
|
||
const [destDir, buildDir] = process.argv.slice(2) | ||
|
||
const env = { ...process.env, DESTDIR: path.resolve(destDir) } | ||
const result = spawnSync('cmake', ['--install', buildDir, '--component', 'config'], { | ||
env, | ||
stdio: 'inherit', | ||
shell: true | ||
}) | ||
|
||
if (result.error || result.status !== 0) { | ||
exit(1) | ||
} |