8000 [Feature request] 在预编辑区内移动光标时,使光标不要循环移动 · Issue #993 · rime/librime · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature request] 在预编辑区内移动光标时,使光标不要循环移动 #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
EdiTurn opened this issue Mar 19, 2025 · 6 comments

Comments

@EdiTurn
Copy link
EdiTurn commented Mar 19, 2025

Is your feature request related to a problem? Please describe.
目前,当预编辑区内光标处于最右侧时,再按下右方向键,光标会移动到最左侧,反之亦然。
但是,这个机制在手机上会造成一些麻烦,因为不存在方向键及 HOME、END,手机输入法一般会采用滑动空格键的方式来移动光标。因此,当修改句中拼音后,难以快速将光标移回预编辑区的最右侧。

Describe the solution you'd like
修改默认机制或增加一个选项,禁用光标的循环移动。

Describe alternatives you've considered
如能实现 #876 中描述的功能,也能解决我目前遇到的困境。

@shewer
Copy link
Contributor
shewer commented Mar 21, 2025

trime 可以綁定 空白 左右滑動 == 方向鍵吧

@EdiTurn
Copy link
Author
EdiTurn commented Mar 21, 2025

trime 可以綁定 空白 左右滑動 == 方向鍵吧

是这样,但由于光标会循环移动,很难快速把光标移回末尾,一不小心就移过头了。

@jimmy54
Copy link
Contributor
jimmy54 commented Apr 28, 2025

前端 8000 以控制,或者写一下lua拦截。

@shewer
Copy link
Contributor
shewer commented Apr 28, 2025
-- lua/navigator.lua
-- 替換   engine/processors/lnavigator   --> lua_processor@*navigator  


local M = {}
function M.init(env)
  local ctx = env.engine.context
  if ctx:get_option("_horizontal") then
    -- 候選橫排   
    env.left = KeyEvent("Up")
    env.right= KeyEvent("Down")
  else
    --候選直排
    env.left = KeyEvent("Left")
    env.right= KeyEvent("Right")
  end
  env.processor = Component.Processor(env.engine, "processor", "navigator") -- <--   這行
end
function M.fini(env)
end

function M.func(key, env)
  local ctx = env.engine.context
  if ctx:is_composing() then
    if ( key:eq(env.left) and ctx.caret_pos == 0 ) or 
       (key:eq(env.right) and ctx.caret_pos == #ctx.input) then
      return 1 -- accepted   (   最左  最右  不再移動)
    end
    return env.processor:process_key_event(key)  -- <-- 這行
  end
  return 2 -- Noop
end

return M

@shewer
Copy link
Contributor
shewer commented Apr 28, 2025

另一個script是移除 env.processor
把 lua_processor@*navigator 放在 navigator 前面

@EdiTurn
Copy link
Author
EdiTurn commented Apr 28, 2025

另一個script是移除 env.processor 把 lua_processor@*navigator 放在 navigator 前面

感谢你提供的脚本。
我的配置基于雾凇拼音,在 lua/ 下新建包含上述代码的 navigator.lua,并在我使用的小鹤双拼配置文件中插入以下内容后,已实现了所需功能。
请问我这么修改正确吗?另外,“移除 env.processor”需要如何做出改动?

engine/processors:
    - lua_processor@*select_character  # 以词定字
    - ascii_composer
    - recognizer
    - key_binder
    - speller
    - punctuator
    - selector
    - lua_processor@*navigator
    - navigator
    - express_editor
5A43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0