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
37 changes: 23 additions & 14 deletions src/lotus-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,29 @@ namespace fcitx {
Option<bool> capitalizeMacro{this, "CapitalizeMacro", _("Capitalize Macro"), true};
OptionWithAnnotation<MacroSkipTriggerModifier, MacroSkipTriggerModifierI18NAnnotation> macroSkipTriggerModifier{
this, "MacroSkipTriggerModifier", _("Modifier to Skip Macro for Next Word"), MacroSkipTriggerModifier::Disabled};
Option<bool> autoCapitalizeAfterPunctuation{this, "AutoCapitalizeAfterPunctuation", _("Auto capitalize after sentence-ending punctuation (. ! ? Enter)"), false};
Option<bool> doubleSpaceToPeriod{this, "DoubleSpaceToPeriod", _("Double Space to Period"), false};
Option<bool> doubleHyphenToEmDash{this, "DoubleHyphenToEmDash", _("Double Hyphen to Em-Dash (--)"), false};
Option<bool> autoNonVnRestore{this, "AutoNonVnRestore", _("Auto Restore Invalid Words"), true};
Option<bool> modernStyle{this, "ModernStyle", _("Use oà, uý (Instead Of òa, úy)"), true};
Option<bool> freeMarking{this, "FreeMarking", _("Allow Type With More Freedom"), true};
Option<bool> ddFreeStyle{this, "DdFreeStyle", _("Allow dd To Produce đ When Auto Restore Invalid Words Is On"), true};
Option<bool> fixUinputWithAck{this, "FixUinputWithAck", _("Fix Uinput Mode With Ack"), false};
Option<bool> useLotusIcons{this, "UseLotusIcons", _("Use Lotus Status Icons"), false};

Option<bool> enableDictionary{this, "EnableDictionary", _("Custom Dictionary"), false};
Option<bool> enableCustomKeymap{this, "EnableCustomKeymap", _("Custom Keymap"), false};

Option<bool> showModeSmooth{this, "ShowModeSmooth", _("Show Uinput (Smooth)"), true};
Option<bool> autoCapitalizeAfterPunctuation{this, "AutoCapitalizeAfterPunctuation", _("Auto capitalize after sentence-ending punctuation (. ! ? Enter)"), false};
Option<bool> doubleSpaceToPeriod{this, "DoubleSpaceToPeriod", _("Double Space to Period"), false};
Option<bool> doubleHyphenToEmDash{this, "DoubleHyphenToEmDash", _("Double Hyphen to Em-Dash (--)"), false};
Option<bool> autoNonVnRestore{this, "AutoNonVnRestore", _("Auto Restore Invalid Words"), true};
Option<bool> modernStyle{this, "ModernStyle", _("Use oà, uý (Instead Of òa, úy)"), true};
Option<bool> freeMarking{this, "FreeMarking", _("Allow Type With More Freedom"), true};
Option<bool> ddFreeStyle{this, "DdFreeStyle", _("Allow dd To Produce đ When Auto Restore Invalid Words Is On"), true};
Option<bool> fixUinputWithAck{this, "FixUinputWithAck", _("Fix Uinput Mode With Ack"), false};
Option<bool> waitSurroundingEvent{this, "WaitSurroundingEvent", _("Experiment: after uinput backspaces, wait for the surrounding-text event instead of sleeping"), false};
Option<int> waitSurroundingTimeoutMs{this, "WaitSurroundingTimeoutMs", _("Experiment: timeout (ms) for that wait"), 50};
Option<int> waitSurroundingShortMs{this, "WaitSurroundingShortMs", _("Experiment: shorter timeout (ms) used after two consecutive timeouts without a matching event"), 40};
Option<int> waitSurroundingProbeEvery{this, "WaitSurroundingProbeEvery",
_("Experiment: when the app's snapshot is frozen during deletion, stop waiting and re-probe once every N replacements"), 4};
Option<int> waitSurroundingMinPerKeyMs{this, "WaitSurroundingMinPerKeyMs",
_("Experiment: a snapshot identical to the one at send time counts as done only after this many ms per backspace"), 8};
Option<int> surrDeleteSleepMs{this, "SurrDeleteSleepMs", _("Experiment: ms per deleted char to sleep after deleteSurroundingText"), 4};
Option<int> surrCommitSleepMs{this, "SurrCommitSleepMs", _("Experiment: ms per committed char to sleep after commitString on the surrounding-text path"), 3};
Option<bool> useLotusIcons{this, "UseLotusIcons", _("Use Lotus Status Icons"), false};

Option<bool> enableDictionary{this, "EnableDictionary", _("Custom Dictionary"), false};
Option<bool> enableCustomKeymap{this, "EnableCustomKeymap", _("Custom Keymap"), false};

Option<bool> showModeSmooth{this, "ShowModeSmooth", _("Show Uinput (Smooth)"), true};
Option<std::string> shortcutSmooth{this, "ShortcutSmooth", _("Shortcut for Uinput (Smooth)"), "1"};
Option<bool> showModeUinput{this, "ShowModeUinput", _("Show Uinput (Slow)"), true};
Option<std::string> shortcutUinput{this, "ShortcutUinput", _("Shortcut for Uinput (Slow)"), "2"};
Expand Down
25 changes: 19 additions & 6 deletions src/lotus-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,11 @@ namespace fcitx {
}

void LotusEngine::deactivate(const InputMethodEntry& /*entry*/, InputContextEvent& event) {
auto* ic = event.inputContext();
auto* state = ic->propertyFor(&factory_);
const bool surrvalid = ic->surroundingText().isValid();
const bool is_dbus = getFrontendName(ic) == "dbus";
auto* ic = event.inputContext();
auto* state = ic->propertyFor(&factory_);
const bool surrvalid = ic->surroundingText().isValid();
const bool is_dbus = getFrontendName(ic) == "dbus";
state->xaChoDangCho(); // v13: chữ còn treo thì giao vào ô CŨ trước khi rời đi
state->lastDeactivateTime_ = now_ms();
if (realMode == LotusMode::Preedit && event.type() != EventType::InputContextFocusOut) {
state->commitBuffer();
Expand All @@ -780,13 +781,25 @@ namespace fcitx {
void LotusEngine::refreshEngine() {
if (!factory_.registered())
return;
instance_->inputContextManager().foreach ([this](InputContext* ic) {
bool coCuaSoDangGo = false;
instance_->inputContextManager().foreach ([this, &coCuaSoDangGo](InputContext* ic) {
auto* state = ic->propertyFor(&factory_);
state->setEngine();
if (ic->hasFocus())
if (ic->hasFocus()) {
// Đặt lại chế độ theo ĐÚNG luật của app đang gõ. Trước đây setEngine()
// ghi thẳng mặc định chung vào realMode nên nạp lại cấu hình là mất luật
// riêng của cửa sổ đang hoạt động.
setMode(getAppRule(getProgramName(ic)), ic);
state->reset();
coCuaSoDangGo = true;
}
return true;
});
// Không có cửa sổ nào đang gõ thì không có luật riêng nào để theo; giữ mặc định
// chung như hành vi cũ. Lần focus kế tiếp activate() sẽ đặt lại cho đúng.
if (!coCuaSoDangGo) {
realMode = config_.mode.value();
}
}

void LotusEngine::refreshOption() {
Expand Down
Loading
Loading