librime icon indicating copy to clipboard operation
librime copied to clipboard

希望中文模式下,紧跟数字的逗号也自动转换成半角

Open SogaSuga opened this issue 2 years ago • 4 comments

目前紧跟数字的句号和冒号会自动变半角,我希望逗号也能这样 因为很多时候输入长数字,需要输入千位、万位分隔符 比如1,000,000或者10,0000,0000.00 还有些地区的分隔符和小数点是相反的,即小数点是逗号,分隔符是句点 如果数字后的逗号也能自动变半角就会方便很多,现在每次输入长数字还要切换英文模式,有点麻烦。 谢谢!

SogaSuga avatar Sep 14 '23 04:09 SogaSuga

already implemented in #672

groverlynn avatar Sep 14 '23 12:09 groverlynn

先用 librime-lua 止渴

-- digital.lua # 存入 user_dir/lua
-- lua_processor@*digital # 插入 engine/processors/ascii_compose 後
 -- 
 local P={}
 function P.init(env)
 end
 function P.fini(env)
 end
 function P.func(key,env)
  local context = env.engine.context
  if context:is_composing() then return 2 end
  if key:ctrl() or key:alt() or key:super() then return 2 end

  if key.keycode < 0x7f then
    local ascii_str= string.char(key.keycode)
    local last_ch= context.commit_history:back()
    if last_ch and last_ch.text:match("%d$") and ascii_str:match("[.,]") then
      return 0
    end
  end
  return 2
end
 return P

shewer avatar Sep 16 '23 13:09 shewer

是不是還有後續,有高手做成能在方案裏配置的?

lotem avatar Feb 06 '24 03:02 lotem

放在那 ascii_composer?

shewer avatar Feb 06 '24 04:02 shewer

#672是硬编码,且只能随后输入的字符变成半角,不能识别输入符前面的文字,不能识别方向键等已移动位置。 网友需求:https://github.com/rime/home/issues/834 英文字母或数字后的标点自动变为英文标点

应该非硬编码且可配置的。 如果可能,配置功能强一些,例如正则检测出前面是C,那么输入:变成:,其他标点不变;前面是http,输入://都是半角;甚至检测前面的换行、中文等。但性能也要可行。 源码中已有的GetPrecedingText不知是否有用。

yfdyh000 avatar Dec 15 '24 17:12 yfdyh000

例如正则检测出前面是C,那么输入:变成:,其他标点不变;前面是http,输入://都是半角

可以模式匹配。

默認配置已經支持識別網址。

lotem avatar Dec 16 '24 06:12 lotem

例如正则检测出前面是C,那么输入:变成:,其他标点不变;前面是http,输入://都是半角

可以模式匹配。

默認配置已經支持識別網址。

谢谢。https://github.com/Mintimate/oh-my-rime/blob/main/double_pinyin_flypy.schema.yaml 覆盖了url的模式,不清楚用意,用rime默认的好一些。 recognizer/patterns/disk: "^[CDEF]:"可以输入C:,但之后输入时按/或\键很容易变成顿号和导致候选上屏,暂未弄懂。以及结尾$的作用。"^[A-Z]:.*$"可以输入\,但中文就不能混输了。

recognizer与上面预期的仍有一些差异,如果能在输入框而非候选框中感知已输入内容,就更智能。候选框输入和改错相对麻烦,比如容易误触ESC取消、似乎不支持鼠标来移动插入符。

yfdyh000 avatar Dec 16 '24 13:12 yfdyh000