Skip to content

Commit 3d9cb09

Browse files
committed
add config for BackSpace behavior on prediction
1 parent b5ccfc6 commit 3d9cb09

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

im/pinyin/pinyin.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,12 @@ void PinyinEngine::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
19491949
if (state->predictWords_) {
19501950
resetPredict(inputContext);
19511951
if (event.key().check(FcitxKey_Escape) ||
1952-
(isAndroid() && event.key().check(FcitxKey_BackSpace)) ||
1952+
(event.key().check(FcitxKey_BackSpace) &&
1953+
(*config_.treatBackspaceAsEscapeOnPrediction ==
1954+
TreatBackspaceAsEscapeOnPrediction::Yes ||
1955+
(*config_.treatBackspaceAsEscapeOnPrediction ==
1956+
TreatBackspaceAsEscapeOnPrediction::WithVirtualKeyboard &&
1957+
event.isVirtual()))) ||
19531958
event.key().check(FcitxKey_Delete)) {
19541959
event.filterAndAccept();
19551960
return;

im/pinyin/pinyin.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ enum class PreeditMode { No, ComposingPinyin, CommitPreview };
9898
FCITX_CONFIG_ENUM_NAME_WITH_I18N(PreeditMode, N_("Do not show"),
9999
N_("Composing pinyin"), N_("Commit preview"))
100100

101+
enum class TreatBackspaceAsEscapeOnPrediction { No, WithVirtualKeyboard, Yes };
102+
103+
FCITX_CONFIG_ENUM_NAME_WITH_I18N(TreatBackspaceAsEscapeOnPrediction, N_("No"),
104+
N_("With virtual keyboard"), N_("Yes"))
105+
101106
enum class CorrectionLayout {
102107
None,
103108
Qwerty,
@@ -188,6 +193,12 @@ FCITX_CONFIGURATION(
188193
isAndroid()};
189194
Option<int, IntConstrain> predictionSize{
190195
this, "PredictionSize", _("Prediction Size"), 49, IntConstrain(3, 100)};
196+
OptionWithAnnotation<TreatBackspaceAsEscapeOnPrediction,
197+
TreatBackspaceAsEscapeOnPredictionI18NAnnotation>
198+
treatBackspaceAsEscapeOnPrediction{
199+
this, "TreatBackspaceAsEscapeOnPrediction",
200+
_("Treat BackSpace as Escape on prediction"),
201+
TreatBackspaceAsEscapeOnPrediction::WithVirtualKeyboard};
191202
OptionWithAnnotation<SwitchInputMethodBehavior,
192203
SwitchInputMethodBehaviorI18NAnnotation>
193204
switchInputMethodBehavior{this, "SwitchInputMethodBehavior",

0 commit comments

Comments
 (0)