Skip to content

Commit e688d50

Browse files
authored
render preedit on virtual keyboard (#48)
1 parent 2b4a5ad commit e688d50

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

entry/src/main/cpp/harmonyfrontend/harmonyfrontend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void HarmonyInputContext::commitStringAsync() {
8888

8989
void HarmonyInputContext::updatePreeditAsync() {
9090
auto state = state_;
91-
auto j = json{{"type", "PREEDIT"}, {"data", {{"preedit", state.preedit}, {"cursorPos", state.cursorPos}}}};
91+
auto j = json{{"type", "CLIENT_PREEDIT"}, {"data", {{"preedit", state.preedit}, {"cursorPos", state.cursorPos}}}};
9292
notify_main_async(j.dump());
9393
}
9494

entry/src/main/cpp/webkeyboard/webkeyboard.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ void WebKeyboard::update(UserInterfaceComponent component, InputContext *inputCo
3131
int highlighted = -1;
3232
std::vector<Candidate> candidates;
3333
const InputPanel &inputPanel = inputContext->inputPanel();
34+
auto auxUp = instance_->outputFilter(inputContext, inputPanel.auxUp()).toString();
35+
auto preedit = instance_->outputFilter(inputContext, inputPanel.preedit()).toString();
36+
notify_main_async(json{{"type", "PREEDIT"}, {"data", {{"auxUp", auxUp}, {"preedit", preedit}}}}.dump());
3437
if (const auto &list = inputPanel.candidateList()) {
3538
int size = list->size();
3639
candidates.reserve(size);
@@ -42,7 +45,7 @@ void WebKeyboard::update(UserInterfaceComponent component, InputContext *inputCo
4245
}
4346
highlighted = list->cursorIndex();
4447
}
45-
if (candidates.empty()) {
48+
if (auxUp.empty() && preedit.empty() && candidates.empty()) {
4649
notify_main_async(R"JSON({"type":"CLEAR"})JSON");
4750
} else {
4851
setCandidatesAsync(candidates, highlighted);

entry/src/main/ets/InputMethodExtensionAbility/model/FcitxEvent.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface PreeditData {
99
}
1010

1111
interface PreeditEvent {
12-
type: 'PREEDIT'
12+
type: 'CLIENT_PREEDIT'
1313
data: PreeditData
1414
}
1515

entry/src/main/ets/InputMethodExtensionAbility/model/KeyboardController.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class KeyboardController {
7878
this.commitString(event.data)
7979
}
8080
break
81-
case 'PREEDIT':
81+
case 'CLIENT_PREEDIT':
8282
this.updatePreviewText(event.data.preedit, event.data.cursorPos)
8383
break
8484
default:

0 commit comments

Comments
 (0)