rime/librime

keep input after switch input schema

Freed-Wu opened this issue · 8 comments

Describe the solution you'd like
For example:

Input ni:
Screenshot from 2024-07-17 22-59-38

Now press a hotkey to switch input schema from Microsoft pinyin to japanese

Actual Behaviour:

Current context and ime is cleared.

Screenshot from 2024-07-17 22-59-49

Expected behaviour:

Keep original input

Screenshot from 2024-07-17 23-00-02

You can write a lua script to remember the current input. By the way, how do you switch between languages with a hotkey? How do you assign a hotkey?

switch between languages with a hotkey? How do you assign a hotkey?

patch:
  key_binder/bindings/@before 6:
    accept: Control+backslash
    select: .next
    when: always

write a lua

Perhaps it can be a builtin feature?

Surely it can. The problem here is how to expose it as an option. I do not have good ideas though.

有點兒意思。如果是 ascii 串串,應該不難。
怕的是類似宮保拼音加了特殊字符、tag 什麼的,別的輸入方案不認識。

如果已經半選,選過的字怎麼辦?
保持轉換結果是不可能的,候選詞背後的內存映射文件應該都不在了。
而且換了輸入方案,保存用戶詞的時候language對不上。
按 BackSpace 撤銷選詞更是崩潰。

For nihao, select to get 你hao, then press BackSpace can get nihao again. if we switch input schema, perhaps we can use nihao as input, not 你hao?

保存用戶詞的時候language對不上

Do you mean user dictionary? Can we skip it?

如果是 ascii 串串,應該不難。

我覺得應該就是這個意思吧。

modified   src/rime/engine.cc
@@ -285,12 +285,14 @@ void ConcreteEngine::ApplySchema(Schema* schema) {
   if (!schema)
     return;
   schema_.reset(schema);
+  string input = context_->input();
   context_->Clear();
   context_->ClearTransientOptions();
   InitializeComponents();
   InitializeOptions();
   switcher_->SetActiveSchema(schema_->schema_id());
   message_sink_("schema", schema_->schema_id() + "/" + schema_->schema_name());
+  context_->set_input(input);
 }