Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

fix tar c on macOS 15; patch rime switch im behavior #43

Merged
merged 1 commit into from
Sep 11, 2024
Merged
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
4 changes: 2 additions & 2 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ f5m_split_data() {
f5m_make_tarball() {
cd $DESTDIR$INSTALL_PREFIX
python3 $ROOT/generate-descriptor.py "$@"
tar cjvf ../../../$name-$ARCH.tar.bz2 *
tar cjvf ../../../$name-$ARCH.tar.bz2 --no-xattrs *

cd ../data
tar cjvf ../../../$name-any.tar.bz2 *
tar cjvf ../../../$name-any.tar.bz2 --no-xattrs *
}

set -x
Expand Down
2 changes: 1 addition & 1 deletion fcitx5-chinese-addons
2 changes: 1 addition & 1 deletion fcitx5-rime
Submodule fcitx5-rime updated 2 files
+11 −10 po/zh_CN.po
+15 −14 po/zh_TW.po
2 changes: 1 addition & 1 deletion package-table-extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ def ensure(command: str):
os.chdir(f"{plugin}/tmp/fcitx5")
ensure(f"python {build_dir}/../generate-descriptor.py {ims[0]}")
os.chdir("../data")
ensure(f"tar cjvf {build_dir}/{plugin}-any.tar.bz2 *")
ensure(f"tar cjvf {build_dir}/{plugin}-any.tar.bz2 --no-xattrs *")
os.chdir(build_dir)
125 changes: 123 additions & 2 deletions patches/rime.patch
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,88 @@ index 6c96898..a52b87a 100644
bool hasAction(const CandidateWord &candidate) const override;
std::vector<CandidateAction>
candidateActions(const CandidateWord &candidate) const override;
diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp
index 68c2044..090ee37 100644
--- a/src/rimeengine.cpp
+++ b/src/rimeengine.cpp
@@ -482,11 +482,22 @@ void RimeEngine::activate(const InputMethodEntry & /*entry*/,

void RimeEngine::deactivate(const InputMethodEntry &entry,
InputContextEvent &event) {
- if (event.type() == EventType::InputContextSwitchInputMethod &&
- *config_.commitWhenDeactivate) {
+ if (event.type() == EventType::InputContextSwitchInputMethod) {
auto *inputContext = event.inputContext();
auto *state = this->state(inputContext);
- state->commitPreedit(inputContext);
+ switch (*config_.switchInputMethodBehavior) {
+ case SwitchInputMethodBehavior::Clear:
+ break;
+ case SwitchInputMethodBehavior::CommitRawInput:
+ state->commitInput(inputContext);
+ break;
+ case SwitchInputMethodBehavior::CommitComposingText:
+ state->commitComposing(inputContext);
+ break;
+ case SwitchInputMethodBehavior::CommitCommitPreview:
+ state->commitPreedit(inputContext);
+ break;
+ }
}
reset(entry, event);
}
diff --git a/src/rimeengine.h b/src/rimeengine.h
index 3ecc012..6bec003 100644
--- a/src/rimeengine.h
+++ b/src/rimeengine.h
@@ -63,6 +63,18 @@ enum class PreeditMode { No, ComposingText, CommitPreview };
FCITX_CONFIG_ENUM_NAME_WITH_I18N(PreeditMode, N_("Do not show"),
N_("Composing text"), N_("Commit preview"))

+enum class SwitchInputMethodBehavior {
+ Clear,
+ CommitRawInput,
+ CommitComposingText,
+ CommitCommitPreview
+};
+
+FCITX_CONFIG_ENUM_NAME_WITH_I18N(SwitchInputMethodBehavior, N_("Clear"),
+ N_("Commit raw input"),
+ N_("Commit composing text"),
+ N_("Commit commit preview"))
+
FCITX_CONFIGURATION(
RimeEngineConfig,
OptionWithAnnotation<PreeditMode, PreeditModeI18NAnnotation> preeditMode{
@@ -78,9 +90,12 @@ FCITX_CONFIGURATION(
this, "PreeditCursorPositionAtBeginning",
_("Fix embedded preedit cursor at the beginning of the preedit"),
!isAndroid() && !isApple()};
- Option<bool> commitWhenDeactivate{
- this, "Commit when deactivate",
- _("Commit current text when deactivating"), true};
+ OptionWithAnnotation<SwitchInputMethodBehavior,
+ SwitchInputMethodBehaviorI18NAnnotation>
+ switchInputMethodBehavior{
+ this, "SwitchInputMethodBehavior",
+ _("Action when switching input method"),
+ SwitchInputMethodBehavior::CommitCommitPreview};
ExternalOption userDataDir{
this, "UserDataDir", _("User data dir"),
stringutils::concat(
diff --git a/src/rimestate.cpp b/src/rimestate.cpp
index a8fe4b9..c54100c 100644
index a8fe4b9..5dbc18f 100644
--- a/src/rimestate.cpp
+++ b/src/rimestate.cpp
@@ -79,7 +79,12 @@ void RimeState::clear() {
@@ -11,6 +11,7 @@
#include "rimesession.h"
#include <algorithm>
#include <cstdint>
+#include <cstring>
#include <fcitx-utils/capabilityflags.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/key.h>
@@ -79,7 +80,12 @@ void RimeState::clear() {
}
}

Expand All @@ -96,3 +173,47 @@ index a8fe4b9..c54100c 100644

std::string RimeState::subMode() {
std::string result;
@@ -440,6 +446,30 @@ void RimeState::updateUI(InputContext *ic, bool keyRelease) {

void RimeState::release() { session_.reset(); }

+void RimeState::commitInput(InputContext *ic) {
+ if (auto *api = engine_->api()) {
+ if (auto input = api->get_input(this->session())) {
+ if (std::strlen(input) > 0) {
+ ic->commitString(input);
+ }
+ }
+ }
+}
+
+void RimeState::commitComposing(InputContext *ic) {
+ if (auto *api = engine_->api()) {
+ RIME_STRUCT(RimeContext, context);
+ auto session = this->session();
+ if (!api->get_context(session, &context)) {
+ return;
+ }
+ if (context.composition.length > 0) {
+ ic->commitString(context.composition.preedit);
+ }
+ api->free_context(&context);
+ }
+}
+
void RimeState::commitPreedit(InputContext *ic) {
if (auto *api = engine_->api()) {
RIME_STRUCT(RimeContext, context);
diff --git a/src/rimestate.h b/src/rimestate.h
index 07a73e1..6b2a1dc 100644
--- a/src/rimestate.h
+++ b/src/rimestate.h
@@ -43,6 +43,8 @@ public:
void updatePreedit(InputContext *ic, const RimeContext &context);
void updateUI(InputContext *ic, bool keyRelease);
void release();
+ void commitInput(InputContext *ic);
+ void commitComposing(InputContext *ic);
void commitPreedit(InputContext *ic);
std::string subMode();
std::string subModeLabel();