Skip to content

定製思路

ksqsf edited this page Sep 12, 2024 · 14 revisions

⚠️ 若修改了下面提及的文件,請在更新方案時注意備份個人定製。也可以參考文末的 Git 方案。

自定義簡快碼或首選

  1. 按個人需求定製 moran_fixed.dict.yaml 即可。這種方法走簡快碼輸入邏輯,具有閃電圖標,只在「魔然」方案中生效,在「魔然·整句」方案中無效。
  2. 使用自定義短語功能 moran_custom.txt。這種方法在 3 種模式下均有效,不受碼長限制,但不具有閃電圖標。

用飛鍵提升手感

自然碼雙拼中有一定空碼空間,這些空間可以被利用用於規避不好打的雙拼組合。下面是一個例子:

# moran.yaml
algebra:
  user_sentence_top:
    - derive/^wz/ww/  # ei
    - derive/^xx/xo/  # ie
    - derive/^qx/qo/
    - derive/^xw/xk/  # ia
    - derive/^my/ms/  # ing
    # 其他已有規則

僅可用於「魔然」和「魔然·整句」方案。

恢復老自然碼的 jv qv xv 打法

老自然碼的中 ju qu xu 使用 jv qv xv 鍵入,而當代大多數人可能更習慣於 ju qu xu 的與全拼相同的打法(魔然方案也使用 ju qu xu 打法)。若想要恢復,同樣可以使用 algebra 實現:

# moran.yaml
algbera:
  user_sentence_top:
    - derive/^ju/jv/
    - derive/^qu/qv/
    - derive/^xu/xv/
    # 其他已有規則

僅可用於「魔然」和「魔然·整句」方案。


如何使用 Git 維護私人修改

用 git 維護多分支修改是非常方便的。下面以 macOS 爲例:

首先直接把本方案倉庫 clone 到用戶目錄下:

# 先移走已有的用戶目錄
mv ~/Library/Rime{,.bak}

git clone https://github.com/ksqsf/rime-moran ~/Library/Rime --depth=1

同步方案更新

git pull

做本地修改:直接修改相應文件,然後 commit 本地修改(不需要 push)。例如,修改 moran_fixed.dict.yaml 後:

git add .
git commit -m "本地修改"

這樣就記錄了本地修改。以後 git pull --rebase 時,會自動將本地修改合併到倉庫修改裏。這樣做,可以大大減少跟隨上游更新的難度。如果不幸遇到了衝突,則需要手動修改對應文件到自己期望的狀態,再 git add . git commit -m 本地修改 來記錄更新。

手機定製·「倉輸入法」

倉輸入法是 iOS 上的 Rime 輸入法,現已支持自定義鍵盤。

十九鍵定製方法

一共兩步:

  1. 導入19鍵鍵盤佈局,使鍵盤輸出模糊編碼
  2. 修改 moran.yaml,使方案可以識別模糊編碼

將如下文件保存爲 moran19.yaml,放到 iCloud 的 Hamster 目錄下。在進入「設置 → 鍵盤設置 → 鍵盤佈局」,點擊右上角 + 號,選擇 moran19.yaml,顯示「導入成功」後,選擇「魔然19鍵」佈局。注:該文件是一個示例,你可能想要參考官方文檔進一步定製。

這個鍵盤的基本思想是把合併的鍵映射到一個數字鍵上,如 we 映射到 1、rt 映射到 2。之後讓方案可以識別該模糊編碼即可。

keyboards:
  - name: 魔然19键
    rows:
      - keys:
          - action: { character: { char: "q" } }
            width: input
            swipe:
              - direction: up
                action: { character: { char: "`" } }
                processByRIME: true
              - direction: down
                action: { character: { char: "~" } }
                processByRIME: true
          - action: { character: { char: 1 } }
            width: input
            label: we
            swipe:
              - action: { character: { char: "e" } }
                display: true
                processByRIME: true
                direction: right
              - action: { character: { char: "w" } }
                display: true
                processByRIME: true
                direction: left
          - action: { character: { char: 2 } }
            width: input
            label: rt
            swipe:
              - action: { character: { char: "t" } }
                display: true
                processByRIME: true
                direction: right
              - action: { character: { char: "r" } }
                display: true
                processByRIME: true
                direction: left
          - action: { character: { char: "y" } }
            width: input
          - action: { character: { char: "u" } }
            width: input
          - action: { character: { char: "i" } }
            width: input
          - action: { character: { char: 3 } }
            width: input
            label: op
            swipe:
              - action: { character: { char: "o" } }
                display: true
                processByRIME: true
                direction: left
              - action: { character: { char: "p" } }
                display: true
                processByRIME: true
                direction: right
              - action: { character: { char: "p" } }
                display: false
                processByRIME: true
                direction: down
      - keys:
          - action: { character: { char: "a" } }
            width: input
            swipe:
              - action: { symbol: { char: "@" } }
                display: true
                direction: up
          - action: { character: { char: "s" } }
            width: input
          - action: { character: { char: "d" } }
            width: input
          - action: { character: { char: 4 } }
            label: fg
            width: input
            swipe:
              - direction: left
                action: { character: { char: "f" } }
                processByRIME: true
              - direction: right
                action: { character: { char: "g" } }
                processByRIME: true
          - action: { character: { char: "h" } }
            width: input
          - action: { character: { char: 5 } }
            width: input
            label: jk
            swipe:
              - action: { character: { char: "j" } }
                display: true
                processByRIME: true
                direction: left
              - action: { character: { char: "k" } }
                display: true
                processByRIME: true
                direction: right
          - action: { character: { char: "l" } }
            width: input
      - keys:
          - action: shift
            width: input
          - action: { character: { char: "z" } }
            width: input
          - action: { character: { char: 6 } }
            width: input
            label: xc
            swipe:
              - action: { character: { char: "x" } }
                display: true
                processByRIME: true
                direction: left
              - action: { character: { char: "c" } }
                display: true
                processByRIME: true
                direction: right
          - action: { character: { char: "v" } }
            width: input
          - action: { character: { char: 7 } }
            width: input
            label: bn
            swipe:
              - action: { character: { char: "b" } }
                display: true
                processByRIME: true
                direction: left
              - action: { character: { char: "n" } }
                display: true
                processByRIME: true
                direction: right
          - action: { character: { char: "m" } }
            width: input
          - action: backspace
            width: input
      - keys:
          - action: { keyboardType: "numericNineGrid" }
            width: input
            swipe:
              - direction: up
                action: { shortcutCommand: "#RimeSwitcher" }
          - action: { keyboardType: "emojis" }
            width: input
          - action: space
            width: available
            swipe:
              - direction: up
                action: { character: { char: ";" } }
                processByRIME: true
              - direction: left
                action: { shortcutCommand: { sendKeys: { keys: "Shift+tab" } } }
                processByRIME: true
              - direction: right
                action: { shortcutCommand: { sendKeys: { keys: "tab" } } }
                processByRIME: true
          - action: { symbol: { char: "," } }
            width: input
            swipe:
              - action: { symbol: { char: "。" } }
                display: true
                direction: up
          - action: { keyboardType: alphabetic }
            width: input
            label: 
          - action: enter
            width: input

然後修改 moran.yaml

algebra:
  user_force_bottom:
    - 'derive/[we]/1/'
    - 'derive/[rt]/2/'
    - 'derive/[op]/3/'
    - 'derive/[fg]/4/'
    - 'derive/[jk]/5/'
    - 'derive/[xc]/6/'
    - 'derive/[bn]/7/'

然後在 moran.schema.yaml moran_fixed.schema.yaml moran_sentence.schema.yamlspellertranslator 做如下配置:

speller:
  alphabet: 'abcdefghijklmnopqrstuvwxyz1234567'    # ← 修改alphabet增加數字鍵

translator:
  # 其他配置不要改動
  preedit_format:
    - 'xform/1/[WE]/'
    - 'xform/2/[RT]/'
    - 'xform/3/[OP]/'
    - 'xform/4/[FG]/'
    - 'xform/5/[JK]/'
    - 'xform/6/[XC]/'
    - 'xform/7/[BN]/'
    # 其他配置不要改動

配置效果:

b048a4bc4e91f19614a25a3276d2f7e6