Skip to content

Commit

Permalink
feat: '后缀参与结束反查或滤字
Browse files Browse the repository at this point in the history
  • Loading branch information
boomker committed Sep 20, 2024
1 parent 74ca2dd commit c56fc24
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
18 changes: 9 additions & 9 deletions flypy_xhfast.custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)$" # 快速切换配置选项
Expand Down
8 changes: 5 additions & 3 deletions flypy_xhfast.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:).*$"

Expand All @@ -272,8 +273,8 @@ punctuator:
",": {commit: ","}
".": {commit: "。"}
";": {commit: ";"}
"<": [《, "<", , 〈, «, ⟨, ˂, ˱]
">": [》, ">", , 〉, », ⟩, ˃, ˲]
"<": ["<", , 〈, «, ⟨, ˂, ˱]
">": [">", , 〉, », ⟩, ˃, ˲]
"/": ["/", /, ÷]
"|": ["|", ·, ・, |, "§", "¦", "‖", ︴]
"`": ["`", "```", ‵, ‶, ‷, ′, ″, ‴, ⁗]
Expand Down Expand Up @@ -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' }

# 拼写设定
Expand Down
35 changes: 35 additions & 0 deletions lua/smart_apostrophe.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c56fc24

Please sign in to comment.