diff --git a/flypy_xhfast.custom.yaml b/flypy_xhfast.custom.yaml index 0f38b0b..d924d83 100644 --- a/flypy_xhfast.custom.yaml +++ b/flypy_xhfast.custom.yaml @@ -60,16 +60,16 @@ patch: expand_abbr_py: "Control+0" # 展开超级简拼 remove_user_word: "Control+q" # 删除用户词典里的单字 / 二三字词 easydict_translate: "Control+y" # 调用 Easydict 翻译高亮候选字词 - # select_first_character: "minus" # `-` 以词定字(第一个字) - # select_last_character: "equal" # `=` 以词定字(最后一个字) + # select_first_character: "minus" # `-` 以词定字(第一个字) + # select_last_character: "equal" # `=` 以词定字(最后一个字) select_first_character: "bracketleft" # `[` 以词定字(第一个字) select_last_character: "bracketright" # `]` 以词定字(最后一个字) bindings/+: - - {when: composing, accept: grave, send: "`"} # `键 逐字追加辅码 - - {when: has_menu, accept: semicolon, send: 2} # 分号用于第2候选 - - {when: has_menu, accept: apostrophe, send: 3} # 单引号用于第3候选 - - {when: paging, accept: comma, send: Page_Up} # 逗号, 返回上一页 - - {when: has_menu, accept: period, send: Page_Down} # 句号. 下一页 + - {when: composing, accept: grave, send: "`"} # `键 逐字追加辅码 + - {when: has_menu, accept: semicolon, send: 2} # 分号用于第2候选 + - {when: has_menu, accept: apostrophe, send: 3} # 单引号用于第3候选 + - {when: paging, accept: comma, send: Page_Up} # 逗号, 返回上一页 + - {when: has_menu, accept: period, send: Page_Down} # 句号. 下一页 # - {when: paging, accept: minus, send: Page_Up} # 减号- 返回上一页 # - {when: has_menu, accept: equal, send: Page_Down} # 等号= 下一页 - {when: has_menu, accept: Tab, send: Control+Right} @@ -93,8 +93,8 @@ patch: shortcuts: "^/fj[a-z]*$" # 快捷指令 LaTeX: "^/lt(.*)$" # LaTeX 公式 calculator: "^/vs(.*)$" # 简易计算器 - radical_lookup: "~[a-z]+$" # ~ 部件拆字 - easy_en: "^/oe[a-zA-Z]*$" # 英文输入方案 + radical_lookup: "~[a-z]+'?$" # ~ 部件拆字 + easy_en: "/oe[a-zA-Z]*'?$" # 英文输入方案 flypy_help: "^/(oh|help)$" # 本方案帮助菜单 flypy_key_help: "^/ok[a-z]*$" # 小鹤双拼键位帮助 switch_options: "^(/so|sopt)$" # 快速切换配置选项 diff --git a/flypy_xhfast.schema.yaml b/flypy_xhfast.schema.yaml index 76bd536..97df37c 100644 --- a/flypy_xhfast.schema.yaml +++ b/flypy_xhfast.schema.yaml @@ -38,6 +38,7 @@ engine: processors: - lua_processor@*select_char - lua_processor@*pair_symbols + - lua_processor@*smart_apostrophe - lua_processor@*idiom_abbr_expand - lua_processor@*easy_en*processor - lua_processor@*pin_word*processor @@ -258,7 +259,7 @@ ecdict_reverse_lookup: recognizer: import_preset: default patterns: - make_sentence: "^`?[a-z]+[`][a-z`]*$" # ` 引导精准造词 + make_sentence: "`?[a-z]+[`][a-z`]*'?$" # ` 引导精准造词 punct: "^(/([0-9]0?|[A-Za-z]+))|(;[A-Za-z]+)$" url: "^(www[.]|https?:|ftp[.:]|mailto:|file:).*$" @@ -272,8 +273,8 @@ punctuator: ",": {commit: ","} ".": {commit: "。"} ";": {commit: ";"} - "<": [《, "<", ‹, 〈, «, ⟨, ˂, ˱] - ">": [》, ">", ›, 〉, », ⟩, ˃, ˲] + "<": ["<", 《, 〈, «, ⟨, ˂, ˱] + ">": [">", 》, 〉, », ⟩, ˃, ˲] "/": ["/", /, ÷] "|": ["|", ·, ・, |, "§", "¦", "‖", ︴] "`": ["`", "```", ‵, ‶, ‷, ′, ″, ‴, ⁗] @@ -302,6 +303,7 @@ key_binder: - {when: always, accept: "Control+period", toggle: ascii_punct} - {when: always, accept: "Control+slash", toggle: simplification} - {when: always, accept: "Control+backslash", toggle: full_shape} + - {when: always, accept: Control+Shift+semicolon, select: easy_en} # - { when: always, accept: Control+1, send_sequence: 'HelloWorld' } # 拼写设定 diff --git a/lua/smart_apostrophe.lua b/lua/smart_apostrophe.lua new file mode 100644 index 0000000..812c5ea --- /dev/null +++ b/lua/smart_apostrophe.lua @@ -0,0 +1,35 @@ + +-- local kReject = 0 +local kAccepted = 1 +local kNoop = 2 + +local function processor(key_event, env) + local context = env.engine.context + + if (key_event:repr() ~= 'apostrophe') or key_event:release() then + return kNoop + end + + local composition = context.composition + if composition:empty() then return kNoop end + + local segment = composition:back() + local menu = segment.menu + + if menu:candidate_count() < 3 then + env.engine:process_key(KeyEvent("'")) + return kAccepted + end + + local page_size = env.engine.schema.page_size + local selected_index = segment.selected_index + if selected_index >= page_size then + env.engine:process_key(KeyEvent("3")) + return kAccepted + end + + env.engine:process_key(KeyEvent("3")) + return kAccepted +end + +return processor