home icon indicating copy to clipboard operation
home copied to clipboard

中文输入时,使用小键盘输入数字,再输入 ,.: 无法转为半角

Open sailcom opened this issue 1 month ago • 3 comments

使用主键盘上的数字输入,当输入 ,。:时,会自动转为半角格式,如下:

Image

但是当使用小键盘输入数字,再输入,。:时,无法自动转换为半角格式,如下:

Image

可否有配置方案,在使用小键盘时,也能自动转换? 谢谢!

sailcom avatar Nov 24 '25 10:11 sailcom

應該可以。沒有鍵盤,沒法測試。 通過 key_binder/bindings 將小鍵盤數字的鍵值綁定到主鍵盤的數字鍵。

lotem avatar Nov 25 '25 01:11 lotem

使用chatgpt和gemini分别帮我生成了几套patch方案,但是尝试了一下都没办法生效。

ChatGPT给出的patch方案1(不生效)

patch:
  key_binder/bindings/+:

    # 小键盘数字标记为 ASCII(用于符号半角)
    - {accept: KP_0, send: "0", set_option: kp_ascii, when: composing}
    - {accept: KP_1, send: "1", set_option: kp_ascii, when: composing}
    - {accept: KP_2, send: "2", set_option: kp_ascii, when: composing}
    - {accept: KP_3, send: "3", set_option: kp_ascii, when: composing}
    - {accept: KP_4, send: "4", set_option: kp_ascii, when: composing}
    - {accept: KP_5, send: "5", set_option: kp_ascii, when: composing}
    - {accept: KP_6, send: "6", set_option: kp_ascii, when: composing}
    - {accept: KP_7, send: "7", set_option: kp_ascii, when: composing}
    - {accept: KP_8, send: "8", set_option: kp_ascii, when: composing}
    - {accept: KP_9, send: "9", set_option: kp_ascii, when: composing}
    - {accept: KP_Decimal, send: period, set_option: kp_ascii, when: composing}

    # 小键盘运算符
    - {accept: KP_Add,      send: plus,     set_option: kp_ascii, when: composing}
    - {accept: KP_Subtract, send: minus,    set_option: kp_ascii, when: composing}
    - {accept: KP_Multiply, send: asterisk, set_option: kp_ascii, when: composing}
    - {accept: KP_Divide,   send: slash,    set_option: kp_ascii, when: composing}

    # 使用符号后,自动恢复原状态
    - {accept: comma,      reset_option: kp_ascii, when: composing}
    - {accept: period,     reset_option: kp_ascii, when: composing}
    - {accept: colon,      reset_option: kp_ascii, when: composing}
    - {accept: semicolon,  reset_option: kp_ascii, when: composing}

  punctuator/selector:
    kp_ascii: half

ChatGPT给出的patch方案2(不生效)

patch:
  key_binder/bindings/+:
    # 小键盘数字触发 ASCII 模式(半角)
    - {accept: KP_0, toggle: ascii_mode, when: composing}
    - {accept: KP_1, toggle: ascii_mode, when: composing}
    - {accept: KP_2, toggle: ascii_mode, when: composing}
    - {accept: KP_3, toggle: ascii_mode, when: composing}
    - {accept: KP_4, toggle: ascii_mode, when: composing}
    - {accept: KP_5, toggle: ascii_mode, when: composing}
    - {accept: KP_6, toggle: ascii_mode, when: composing}
    - {accept: KP_7, toggle: ascii_mode, when: composing}
    - {accept: KP_8, toggle: ascii_mode, when: composing}
    - {accept: KP_9, toggle: ascii_mode, when: composing}
    - {accept: KP_Decimal, toggle: ascii_mode, when: composing}

Gemini给出的patch方案

(输入数字不上屏,但紧接着输入句号可以变为.,在输入.之后可生效)

patch:
  key_binder/bindings/+:
  
  # 核心:将条件设为 always,无条件伪装成主键盘数字
    - {accept: KP_0, send: "0", when: always}
    - {accept: KP_1, send: "1", when: always}
    - {accept: KP_2, send: "2", when: always}
    - {accept: KP_3, send: "3", when: always}
    - {accept: KP_4, send: "4", when: always}
    - {accept: KP_5, send: "5", when: always}
    - {accept: KP_6, send: "6", when: always}
    - {accept: KP_7, send: "7", when: always}
    - {accept: KP_8, send: "8", when: always}
    - {accept: KP_9, send: "9", when: always}
    - {accept: KP_Decimal, send: period, when: always}
    
    # 加上运算符映射
    - {accept: KP_Multiply, send: asterisk, when: always}
    - {accept: KP_Add, send: plus, when: always}
    - {accept: KP_Subtract, send: minus, when: always}
    - {accept: KP_Divide, send: slash, when: always}

现在都不知道用哪个更合适了...

sailcom avatar Nov 25 '25 08:11 sailcom

確實不行。

數字小鍵盤的字符Rime只用來選字,不選字的時候Rime不做處理,也就是說會直接上屏。

按說小數點 . 也應該能直接上屏,那麼用小鍵盤打出來的 3.14 應該可以是半角字符。如果你的小鍵盤有 , 鍵,也可以出半角字符。冒號小鍵盤上沒有。

lotem avatar Nov 25 '25 09:11 lotem