Skip to content

feat: eat backspace, if it's held from the time when composing #1641#1644

Closed
fxliang wants to merge 1 commit intorime:masterfrom
fxliang:eatbs
Closed

feat: eat backspace, if it's held from the time when composing #1641#1644
fxliang wants to merge 1 commit intorime:masterfrom
fxliang:eatbs

Conversation

@fxliang
Copy link
Contributor

@fxliang fxliang commented Jul 2, 2025

close #1641

not worked for Edge, chrome/firefox not tested yet.

@fxliang fxliang force-pushed the eatbs branch 2 times, most recently from e064df1 to 058e995 Compare July 2, 2025 14:03
@lotem
Copy link
Member

lotem commented Aug 19, 2025

代码复杂,看不懂。
这个按键逻辑适合在 librime 里做啊。

@fxliang
Copy link
Contributor Author

fxliang commented Aug 19, 2025

代码复杂,看不懂。 这个按键逻辑适合在 librime 里做啊。

如果可以更好啊

@fxliang
Copy link
Contributor Author

fxliang commented Aug 20, 2025

简单点用librime-lua插件实现算了,在前端上实现有点硬编了

local function init(env)
  env.held_backspace_when_composing = false
  env.XK_BackSpace = 0xff08
end

local function processor(key, env)
	local ctx = env.engine.context
  if key.keycode == env.XK_BackSpace then
    if key:release() then -- 按键释放
      env.held_backspace_when_composing = false
    elseif key.modifier == 0 then -- 无组合键
      if ctx:is_composing() then env.held_backspace_when_composing = true
      elseif env.held_backspace_when_composing then return 1 -- 返回 kAccepted
      end
    end
  end
  return 2 -- 返回 kNoop
end

return {init = init, func = processor}

在方案中添加processor, 具体准确的位置自行根据需要调整

  'engine/processors/@before 2': lua_processor@*backspace

@fxliang fxliang closed this Aug 20, 2025
@fxliang fxliang deleted the eatbs branch December 19, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

建议反馈:长按回退键不要清除已经输入的字符

2 participants