Skip to content

Commit

Permalink
修行列30
Browse files Browse the repository at this point in the history
  • Loading branch information
oniondelta committed Oct 15, 2024
1 parent e600cf4 commit 2e68b12
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 42 deletions.
31 changes: 16 additions & 15 deletions allfiles/lua/f_components/keys_table/hot_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,17 @@ local function hotkeys(n)
, { " [space]消除未上屏輸入(清空)(空碼時)", "➀➄" }
, { " [BackSpace]刪除一個輸入碼", "➀➅" }
, { " • 選字單翻頁", "➀➆" }
, { " [ right / left ]翻頁(選字時)", "➀➇" }
, { " [shift]+[ up / down ]翻頁(打字時)", "➀➈" }
, { " [shift]+[ tab / space ]翻頁(打字時)", "➁🄋" }
, { " • 選字", "➁➀" }
, { " [ 1234567890 ]選字", "➁➁" }
, { " [control]+[ 1234567890 ]選字?!", "➁➂" }
, { " (↑ Mac 會鍵位衝突)", "➁➃" }
, { " ──────────── ", "➁➄" }
, { " ※ [Enter]於 Mac 名稱為[return]", "➁➅" }
, { " ※ [BackSpace]於 Mac 名稱為[delete]", "➁➆" }
, { " [tab]翻下頁(打字時)", "➀➇" }
, { " [ right / left ]翻頁(選字時)", "➀➈" }
, { " [shift]+[ up / down ]翻頁(打字時)", "➁🄋" }
, { " [shift]+[ tab / space ]翻頁(打字時)", "➁➀" }
, { " • 選字", "➁➁" }
, { " [ 1234567890 ]選字", "➁➂" }
, { " [control]+[ 1234567890 ]選字?!", "➁➃" }
, { " (↑ Mac 會鍵位衝突)", "➁➄" }
, { " ──────────── ", "➁➅" }
, { " ※ [Enter]於 Mac 名稱為[return]", "➁➆" }
, { " ※ [BackSpace]於 Mac 名稱為[delete]", "➁➇" }
}

k2_table = {
Expand All @@ -256,7 +257,7 @@ local function hotkeys(n)
, { " [control]+[shift]+[ 6 ]變換中文字符範圍", "➊➊" }
, { " [control]+[shift]+[ 7 ]變換編碼標注有無", "➊➋" }
, { " [control]+[shift]+[ 8 ]變換上屏簡碼(多個)為直上或香草", "➊➌" }
, { " [control]+[shift]+[ 9 ]變換 w 符號 space 為翻頁或上屏", "➊➍" }
, { " [control]+[shift]+[ 9 ]變換 w 符號 space 為上屏或翻頁", "➊➍" }
, { " [control]+[shift]+[ 0 ]變換 Enter 上屏中文或原始輸入", "➊➎" }
, { " (↑ Win 會鍵位衝突)", "➊➏" }
, { "『 快捷鍵(下排/指定)』(初始設定 +[shift])", "➊➐" }
Expand All @@ -267,8 +268,8 @@ local function hotkeys(n)
, { " [control]+[ ; ]切換簡體轉換", "➋➋" }
, { " [control]+[ ' ]切換中文字符範圍為完整(增廣),不精簡", "➋➌" }
, { " [control]+[ [ ]切換編碼標注為無", "➋➍" }
, { " [control]+[ ] ]切換上屏簡碼(多個)為香草模式", "➋➎" }
, { " [control]+[ - ]切換 w 符號 space 為翻頁", "➋➏" }
, { " [control]+[ ] ]切換上屏簡碼(多個)為直上", "➋➎" }
, { " [control]+[ - ]切換 w 符號 space 為上屏", "➋➏" }
, { " [control]+[ = ]切換 Enter 上屏中文", "➋➐" }
, { " • 初始設定", "➋➑" }
, { " [control]+[shift]+[ , ]切換中文", "➋➒" }
Expand All @@ -277,8 +278,8 @@ local function hotkeys(n)
, { " [control]+[shift]+[ ; ]切換不轉換簡體", "➌➋" }
, { " [control]+[shift]+[ ' ]切換中文其字符範圍為精簡(CJK)", "➌➌" }
, { " [control]+[shift]+[ [ ]切換編碼標注為有", "➌➍" }
, { " [control]+[shift]+[ ] ]切換上屏簡碼(多個)為直上", "➌➎" }
, { " [control]+[shift]+[ - ]切換 w 符號 space 為上屏", "➌➏" }
, { " [control]+[shift]+[ ] ]切換上屏簡碼(多個)為香草模式", "➌➎" }
, { " [control]+[shift]+[ - ]切換 w 符號 space 為翻頁", "➌➏" }
, { " [control]+[shift]+[ = ]切換 Enter 上屏原始輸入", "➌➐" }
, { " ──────────── ", "➌➑" }
, { " ※ 某些鍵位須用內附的 default.custom.yaml 檔", "➌➒" }
Expand Down
48 changes: 33 additions & 15 deletions allfiles/lua/filter_mix30_nil_comment_up_filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,47 @@ local function filter(inp, env)
local check_wu = string.match(c_input, "^sf $" )
local check_ji = string.match(c_input, "^lb $" )
local check_kong = string.match(c_input, "^ou $" )
local check_www = string.match(c_input, "^www[.]" ) -- 直接判別 comment 即可
-- local check_www = string.match(c_input, "^www[.]" ) -- 直接判別 comment 即可

for cand in inp:iter() do

if #c_input<3 then
if string.match(cand.text, "^⎔%d$" ) then
yield(change_preedit(array30_nil_cand, cand.preedit))
goto nil_label
else
goto normal_label
end
if string.match(cand.text, "^⎔%d$" ) then
yield(change_preedit(array30_nil_cand, cand.preedit))
goto nil_label
-- elseif check_www then
elseif #c_input>3 then
if check_www then
if cand.comment == "〔URL〕" then
yield(cand)
goto nil_label
else
goto normal_label
end
if cand.comment == "〔URL〕" then
yield(cand)
-- yield(change_comment(cand,"測試用"))
goto nil_label
else
goto normal_label
end
else
goto normal_label
end

-- ---- 以下先以輸入字數評判來處理,但在符號 w[0-9] 後接行列30字碼,"^⎔%d$"會無法作用。
-- if #c_input<3 then
-- if string.match(cand.text, "^⎔%d$" ) then
-- yield(change_preedit(array30_nil_cand, cand.preedit))
-- goto nil_label
-- else
-- goto normal_label
-- end
-- elseif #c_input>3 then
-- if check_www then
-- if cand.comment == "〔URL〕" then
-- yield(cand)
-- goto nil_label
-- else
-- goto normal_label
-- end
-- else
-- goto normal_label
-- end
-- end

-- if #c_input<3 and string.match(cand.text, "^⎔%d$" ) then
-- yield(change_preedit(array30_nil_cand, cand.preedit))
-- -- if string.match(cand.text, "^⎔%d$" ) then
Expand Down
55 changes: 51 additions & 4 deletions allfiles/lua/processor_array30up_mix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ local function init(env)
-- ["Decimal"] = ".",
-- }
-- env.set_char_bpmf = Set {"ㄅ", "ㄆ", "ㄇ", "ㄈ", "ㄉ", "ㄊ", "ㄋ", "ㄌ", "ㄍ", "ㄎ", "ㄏ", "ㄐ", "ㄑ", "ㄒ", "ㄓ", "ㄔ", "ㄕ", "ㄖ", "ㄗ", "ㄘ", "ㄙ", "ㄧ", "ㄨ", "ㄩ", "ㄚ", "ㄛ", "ㄜ", "ㄝ", "ㄞ", "ㄟ", "ㄠ", "ㄡ", "ㄢ", "ㄣ", "ㄤ", "ㄥ", "ㄦ", "ˉ", "ˊ", "ˇ", "ˋ", "˙", "ㄪ", "ㄫ", "ㄫ", "ㄬ", "ㄭ", "ㄮ", "ㄮ", "ㄯ", "ㄯ", "ㆠ", "ㆡ", "ㆢ", "ㆣ", "ㆤ", "ㆥ", "ㆦ", "ㆧ", "ㆨ", "ㆩ", "ㆪ", "ㆫ", "ㆬ", "ㆭ", "ㆭ", "ㆮ", "ㆯ", "ㆰ", "ㆰ", "ㆱ", "ㆱ", "ㆲ", "ㆲ", "ㆳ", "ㆴ", "ㆵ", "ㆶ", "ㆷ", "ㆸ", "ㆹ", "ㆺ"}
env.n = 0 -- wsymbols計數用
end

local kp_pattern = {
Expand All @@ -66,6 +67,13 @@ local kp_pattern = {
["Decimal"] = ".",
}

local k4_pattern = {
["comma"] = ",",
["period"] = ".",
["slash"] = "/",
["semicolon"] = ";",
}

-- local set_char_bpmf = Set {"ㄅ", "ㄆ", "ㄇ", "ㄈ", "ㄉ", "ㄊ", "ㄋ", "ㄌ", "ㄍ", "ㄎ", "ㄏ", "ㄐ", "ㄑ", "ㄒ", "ㄓ", "ㄔ", "ㄕ", "ㄖ", "ㄗ", "ㄘ", "ㄙ", "ㄧ", "ㄨ", "ㄩ", "ㄚ", "ㄛ", "ㄜ", "ㄝ", "ㄞ", "ㄟ", "ㄠ", "ㄡ", "ㄢ", "ㄣ", "ㄤ", "ㄥ", "ㄦ", "ˉ", "ˊ", "ˇ", "ˋ", "˙", "ㄪ", "ㄫ", "ㄫ", "ㄬ", "ㄭ", "ㄮ", "ㄮ", "ㄯ", "ㄯ", "ㆠ", "ㆡ", "ㆢ", "ㆣ", "ㆤ", "ㆥ", "ㆦ", "ㆧ", "ㆨ", "ㆩ", "ㆪ", "ㆫ", "ㆬ", "ㆭ", "ㆭ", "ㆮ", "ㆯ", "ㆰ", "ㆰ", "ㆱ", "ㆱ", "ㆲ", "ㆲ", "ㆳ", "ㆴ", "ㆵ", "ㆶ", "ㆷ", "ㆸ", "ㆹ", "ㆺ"}

-- local function array30up_mix(key, env)
Expand All @@ -82,9 +90,15 @@ local function processor(key, env)
local o_ascii_mode = context:get_option("ascii_mode")
local a_s_wp = context:get_option("array30_space_wp")
local a_r_abc = context:get_option("array30_return_abc")
local s_up = context:get_option("1_2_straight_up")
local key_num = key:repr():match("KP_([0-9])") or key:repr():match("Control%+([0-9])")

local check_i1 = string.match(c_input, "^[a-z.,/;][a-z.,/;][a-z.,/;][a-z.,/;]?i?$")
-- local key_abc = key:repr():match("^([%l])$") or k4_pattern[key:repr()]
-- local check_word_space = string.match(c_input, "^[a-z.,/;][a-z.,/;]? $")
local check_word_space = string.match(c_input, "[a-z.,/;] $") -- 符號w[0-9]後才可作用

-- local check_i1 = string.match(c_input, "^[a-z.,/;][a-z.,/;][a-z.,/;][a-z.,/;]?i?$")
local check_i1 = string.match(c_input, "[a-z.,/;][a-z.,/;][a-z.,/;][a-z.,/;]?i?$") -- 符號w[0-9]後才可作用
local check_i2 = string.match(c_input, "^==[a-z.,/;][a-z.,/;][a-z.,/;][a-z.,/;]?i?$")
-- local check_i3 = string.match(c_input, "`.+$")
-- local check_i4 = string.match(c_input, "^[a-z][-_.0-9a-z]*@.*$")
Expand Down Expand Up @@ -178,8 +192,26 @@ local function processor(key, env)

-----------------------------------------------------------------------------

--- pass not space Return KP_Enter key_num
--- 香草模式下空格後接字碼,不會變成全部英文,而是前面直接上屏中文,後面續輸入。
elseif not s_up and check_word_space and ( key:repr():match("^[%l]$") or k4_pattern[key:repr()] ) then
if (seg:has_tag("abc") or seg:has_tag("reverse3_lookup")) then
local k_r = k4_pattern[key:repr()] or key:repr()
engine:commit_text(g_c_t)
context.input = k_r
return 1
else
return 2
end
-- elseif not s_up and seg:has_tag("abc") and check_word_space and key_abc then
-- engine:commit_text(g_c_t)
-- context.input = key_abc
-- return 1

-----------------------------------------------------------------------------

--- pass not space Return KP_Enter key_num ( Shift+space ?)
elseif key:repr() ~= "space" and key:repr() ~= "Return" and key:repr() ~= "KP_Enter" and not key_num then
-- elseif key:repr() ~= "space" and key:repr() ~= "Return" and key:repr() ~= "KP_Enter" and key:repr() ~= "Shift+space" and not key_num then
return 2

-----------------------------------------------------------------------------
Expand Down Expand Up @@ -290,9 +322,24 @@ KeyEvent 函數在舊版 librime-lua 中不支持。

elseif seg:has_tag("wsymbols") then
if a_s_wp then
-- if key:repr() == "space" or key:repr() == "Shift+space" then
if key:repr() == "space" then
engine:process_key(KeyEvent("Page_Down"))
return 1 -- kAccepted
--- 以下可循環翻頁!
local loaded_candidate_count = seg.menu:candidate_count() -- 獲得(已加載)候選詞數量
-- local page_n = 10 * (seg.selected_index // 10) -- 先確定在第幾頁,「//」為整除運算符。
-- engine:commit_text(loaded_candidate_count) -- 測試用
if env.n == loaded_candidate_count and env.n > 10 then
context:refresh_non_confirmed_composition()
return 1 -- kAccepted
else
env.n = loaded_candidate_count
engine:process_key(KeyEvent("Page_Down"))
return 1 -- kAccepted
end
-- elseif key:repr() == "Shift+space" then
-- env.n = 0
-- engine:process_key(KeyEvent("Page_Up"))
-- return 1 -- kAccepted
--- 修正 w[0-9] 空白鍵 設翻頁時,無上屏鍵問題。
--- 搭配前面「空白鍵同某些行列 30 一樣為翻頁」,並且用 custom 檔設「return 上屏候選字」,校正 Return 能上屏候選項!
elseif key:repr() == "Return" or key:repr() == "KP_Enter" then
Expand Down
16 changes: 8 additions & 8 deletions allfiles/onion-array30.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ switches:
# states: [ 'Ⓝ', 'Ⓓ' ]
# states: [ 'normal', 'Debug' ]
- name: 1_2_straight_up
reset: 1
reset: 0
states: [ 香草, 直上 ]
- name: array30_space_wp
reset: 0
reset: 1
states: [ "Confirm", "Paging" ]
- name: array30_return_abc
reset: 1
Expand Down Expand Up @@ -447,8 +447,8 @@ key_binder:
- { accept: Control+slash, set_option: ascii_punct, when: always } #新增!
- { accept: Control+apostrophe, unset_option: extended_charset, when: always } #增廣常用字符過濾,新增開關
- { accept: Control+bracketleft, set_option: simplify_comment, when: always } #編碼提示開關
- { accept: Control+bracketright, unset_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+minus, set_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
- { accept: Control+bracketright, set_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+minus, unset_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+equal, unset_option: array30_return_abc, when: always } # return 上屏候選字或 abc 開關
## 初始樣態(Mac)
- { accept: Control+Shift+comma, unset_option: ascii_mode, when: always } #新增!
Expand All @@ -457,8 +457,8 @@ key_binder:
- { accept: Control+Shift+slash, unset_option: ascii_punct, when: always } #新增!
- { accept: Control+Shift+apostrophe, set_option: extended_charset, when: always } #增廣常用字符過濾,新增開關
- { accept: Control+Shift+bracketleft, unset_option: simplify_comment, when: always } #編碼提示開關
- { accept: Control+Shift+bracketright, set_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+minus, unset_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
- { accept: Control+Shift+bracketright, unset_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+minus, set_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+equal, set_option: array30_return_abc, when: always } # return 上屏候選字或 abc 開關
## 初始樣態(Win)
- { accept: Control+Shift+less, unset_option: ascii_mode, when: always } #新增!
Expand All @@ -467,8 +467,8 @@ key_binder:
- { accept: Control+Shift+question, unset_option: ascii_punct, when: always } #新增!
- { accept: Control+Shift+quotedbl, set_option: extended_charset, when: always } #增廣常用字符過濾,新增開關
- { accept: Control+Shift+braceleft, unset_option: simplify_comment, when: always } #編碼提示開關
- { accept: Control+Shift+braceright, set_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+underscore, unset_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
- { accept: Control+Shift+braceright, unset_option: 1_2_straight_up, when: always } #空白直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+underscore, set_option: array30_space_wp, when: always } #輸入w[0-9]符號,空白為翻頁或直上開關
#win易快捷鍵衝突,mac可打開# - { accept: Control+Shift+plus, set_option: array30_return_abc, when: always } # return 上屏候選字或 abc 開關
### Return/Enter鍵 ###
- {accept: Return, send: KP_Space, when: paging} #選字時 Return/Enter 鍵同空白鍵上屏中文
Expand Down

0 comments on commit 2e68b12

Please sign in to comment.