diff --git a/data/minimal/default.yaml b/data/minimal/default.yaml index d10c253b5..186665c29 100644 --- a/data/minimal/default.yaml +++ b/data/minimal/default.yaml @@ -1,8 +1,7 @@ # Rime default settings -# vim: set sw=2 sts=2 et: # encoding: utf-8 -config_version: "0.15.minimal" +config_version: "0.16.minimal" schema_list: - schema: luna_pinyin @@ -118,6 +117,8 @@ key_binder: - { when: has_menu, accept: equal, send: Page_Down } - { when: paging, accept: comma, send: Page_Up } - { when: has_menu, accept: period, send: Page_Down } + - { when: predicting, accept: comma, send: comma } + - { when: predicting, accept: period, send: period } # hotkey switch - { when: always, accept: Control+Shift+1, select: .next } - { when: always, accept: Control+Shift+2, toggle: ascii_mode } diff --git a/src/rime/gear/key_binder.cc b/src/rime/gear/key_binder.cc index 818e85cde..0d8e2f1a6 100644 --- a/src/rime/gear/key_binder.cc +++ b/src/rime/gear/key_binder.cc @@ -22,16 +22,18 @@ namespace rime { enum KeyBindingCondition { kNever, - kWhenPaging, // user has changed page - kWhenHasMenu, // at least one candidate - kWhenComposing, // input string is not empty + kWhenPredicting, // showing prediction candidates + kWhenPaging, // user has changed page + kWhenHasMenu, // at least one candidate + kWhenComposing, // input string is not empty kAlways, }; static struct KeyBindingConditionDef { KeyBindingCondition condition; const char* name; -} condition_definitions[] = {{kWhenPaging, "paging"}, +} condition_definitions[] = {{kWhenPredicting, "predicting"}, + {kWhenPaging, "paging"}, {kWhenHasMenu, "has_menu"}, {kWhenComposing, "composing"}, {kAlways, "always"}, @@ -242,8 +244,14 @@ KeyBindingConditions::KeyBindingConditions(Context* ctx) { } Composition& comp = ctx->composition(); - if (!comp.empty() && comp.back().HasTag("paging")) { - insert(kWhenPaging); + if (!comp.empty()) { + const Segment& last_seg = comp.back(); + if (last_seg.HasTag("paging")) { + insert(kWhenPaging); + } + if (last_seg.HasTag("prediction")) { + insert(kWhenPredicting); + } } }