mirror of
https://github.com/iDvel/rime-ice.git
synced 2026-02-02 02:56:45 +00:00
fix(cold_word_drop): 写入记录的文件夹名称和兼容性修复 (#1138)
* fix(cold_word_drop): 写入记录的文件夹名称错误 * 保证 processor.lua 旧版的兼容性
This commit is contained in:
@@ -2,19 +2,23 @@
|
||||
-- 在 engine/processors 增加 - lua_processor@cold_word_drop.processor
|
||||
-- 在 engine/filters 增加 - lua_filter@cold_word_drop.filter
|
||||
-- 在 key_binder 增加快捷键:
|
||||
-- turn_down_cand: "Control+j" # 匹配当前输入码后隐藏指定的候选字词 或候选词条放到第四候选位置
|
||||
-- reduce_freq_cand: "Control+j" # 匹配当前输入码后隐藏指定的候选字词 或候选词条放到第四候选位置
|
||||
-- drop_cand: "Control+d" # 强制删词, 无视输入的编码
|
||||
-- get_record_filername() 函数中仅支持了 Windows、macOS、Linux
|
||||
|
||||
local filter = {}
|
||||
|
||||
function filter.init(env)
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
env.word_reduce_idx = config:get_int("cold_word_reduce/idx") or 4
|
||||
env.drop_words = require("cold_word_drop.drop_words") or {}
|
||||
env.hide_words = require("cold_word_drop.hide_words") or {}
|
||||
env.reduce_freq_words = require("cold_word_drop.reduce_freq_words") or {}
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
local _sd, drop_words = pcall(require, "cold_word_drop/drop_words")
|
||||
local _sh, hide_words = pcall(require, "cold_word_drop/hide_words")
|
||||
local _st, turn_down_words = pcall(require, "cold_word_drop/turn_down_words")
|
||||
local _sr, reduce_freq_words = pcall(require, "cold_word_drop/reduce_freq_words")
|
||||
env.word_reduce_idx = config:get_int("cold_word_reduce/idx") or 4
|
||||
env.drop_words = _sd and drop_words or {}
|
||||
env.hide_words = _sh and hide_words or {}
|
||||
env.reduce_freq_words = (_st and turn_down_words) or (_sr and reduce_freq_words) or {}
|
||||
end
|
||||
|
||||
function filter.func(input, env)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
-- 在 engine/processors 增加 - lua_processor@cold_word_drop.processor
|
||||
-- 在 engine/filters 增加 - lua_filter@cold_word_drop.filter
|
||||
-- 在 key_binder 增加快捷键:
|
||||
-- turn_down_cand: "Control+j" # 匹配当前输入码后隐藏指定的候选字词 或候选词条放到第四候选位置
|
||||
-- drop_cand: "Control+d" # 强制删词, 无视输入的编码
|
||||
-- reduce_freq_cand: "Control+j" # 匹配当前输入码后隐藏指定的候选字词 或候选词条放到第四候选位置
|
||||
-- drop_cand: "Control+d" # 强制删词, 无视输入的编码
|
||||
-- get_record_filername() 函数中仅支持了 Windows、macOS、Linux
|
||||
|
||||
require("cold_word_drop.string")
|
||||
@@ -16,12 +16,12 @@ local function get_record_filername(record_type)
|
||||
local user_distribute_name = rime_api:get_distribution_code_name()
|
||||
if user_distribute_name:lower():match("weasel") then path_sep = [[\]] end
|
||||
if user_distribute_name:lower():match("ibus") then
|
||||
return string.format("%s/rime/lua/cold_word_records/%s_words.lua",
|
||||
return string.format("%s/rime/lua/cold_word_drop/%s_words.lua",
|
||||
os.getenv("HOME") .. "/.config/ibus",
|
||||
record_type
|
||||
)
|
||||
else
|
||||
local file_path = string.format("%s/lua/cold_word_records/%s_words.lua", user_data_dir, record_type)
|
||||
local file_path = string.format("%s/lua/cold_word_drop/%s_words.lua", user_data_dir, record_type)
|
||||
return file_path:gsub("/", path_sep)
|
||||
end
|
||||
end
|
||||
@@ -74,15 +74,20 @@ local function append_word_to_droplist(env, ctx, action_type)
|
||||
end
|
||||
|
||||
function processor.init(env)
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
env.drop_cand_key = config:get_string("key_binder/drop_cand") or "Control+d"
|
||||
env.hide_cand_key = config:get_string("key_binder/hide_cand") or "Control+x"
|
||||
env.reduce_cand_key = config:get_string("key_binder/reduce_freq_cand") or "Control+j"
|
||||
env.drop_words = require("cold_word_drop.drop_words") or {}
|
||||
env.hide_words = require("cold_word_drop.hide_words") or {}
|
||||
env.reduce_freq_words = require("cold_word_drop.reduce_freq_words") or {}
|
||||
env.tbls = {
|
||||
local engine = env.engine
|
||||
local config = engine.schema.config
|
||||
local _sd, drop_words = pcall(require, "cold_word_drop/drop_words")
|
||||
local _sh, hide_words = pcall(require, "cold_word_drop/hide_words")
|
||||
local _st, turn_down_words = pcall(require, "cold_word_drop/turn_down_words")
|
||||
local _sr, reduce_freq_words = pcall(require, "cold_word_drop/reduce_freq_words")
|
||||
env.drop_words = _sd and drop_words or {}
|
||||
env.hide_words = _sh and hide_words or {}
|
||||
env.reduce_freq_words = (_st and turn_down_words) or (_sr and reduce_freq_words) or {}
|
||||
env.drop_cand_key = config:get_string("key_binder/drop_cand") or "Control+d"
|
||||
env.hide_cand_key = config:get_string("key_binder/hide_cand") or "Control+x"
|
||||
env.turn_down_cand_key = config:get_string("key_binder/turn_down_cand") or nil
|
||||
env.reduce_cand_key = env.turn_down_cand_key or config:get_string("key_binder/reduce_freq_cand") or "Control+j"
|
||||
env.tbls = {
|
||||
["drop_list"] = env.drop_words,
|
||||
["hide_list"] = env.hide_words,
|
||||
["reduce_freq_list"] = env.reduce_freq_words,
|
||||
|
||||
Reference in New Issue
Block a user