Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
CvCn committed Aug 18, 2024
1 parent 7ce26c9 commit f122c77
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 9 deletions.
36 changes: 36 additions & 0 deletions InputInput/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ local function UpdateFontStringPosition(editBox, displayFontString, msg)
displayFontString:Show()
end

local function getLastUTF8Char(s)
-- 初始化起始位置
local lastCharStart = nil

-- 遍历字符串,找到最后一个字符的起始位置
for i = 1, #s do
local c = string.byte(s, i)
if c >= 128 then
-- 多字节字符的处理
if c >= 240 then
lastCharStart = i
i = i + 3
elseif c >= 224 then
lastCharStart = i
i = i + 2
elseif c >= 192 then
lastCharStart = i
i = i + 1
end
else
-- 单字节字符的处理
lastCharStart = i
end
end

-- 返回最后一个字符
return s:sub(lastCharStart)
end

local function FindHis(his, patt)
if not his or #his <= 0 or not patt or #patt <= 0 then return '' end
Expand Down Expand Up @@ -149,6 +177,11 @@ local function FindHis(his, patt)
end
end
end
-- 如果分词匹配不到,使用输入的最后一个字符匹配
local start, _end = strfind(h, getLastUTF8Char(patt), 1, true)
if start and start > 0 then
return strsub(h, _end + 1)
end
end
end
return ''
Expand Down Expand Up @@ -1056,6 +1089,7 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
elseif event == 'ADDON_LOADED' then
local addOnName, containsBindings = ...
if addOnName == "InputInput_Libraries_zh" then
LOG:Debug("---加载词库0%---")
W.dict1 = LibStub("inputinput-dict1").dict
W.dict2 = LibStub("inputinput-dict2").dict
W.dict3 = LibStub("inputinput-dict3").dict
Expand Down Expand Up @@ -1085,7 +1119,9 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
for i, v in pairs(W.dict6) do
W.dict6[i] = math.log(v) - logtotal
end
LOG:Debug("---加载词库100%---")
U:InitWordCache(messageHistory)

end
else
if (C_AddOns_IsAddOnLoaded("ElvUI") or ElvUI == nil) and
Expand Down
2 changes: 1 addition & 1 deletion InputInput_Libraries_zh/InputInput_Libraries_zh.toc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
Expand Down
2 changes: 1 addition & 1 deletion InputInput_Libraries_zh/InputInput_Libraries_zh_Cata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
Expand Down
3 changes: 1 addition & 2 deletions InputInput_Libraries_zh/InputInput_Libraries_zh_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
dict4.lua
dict5.lua
dict6.lua

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
Expand Down
3 changes: 1 addition & 2 deletions InputInput_Libraries_zh/InputInput_Libraries_zh_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
dict4.lua
dict5.lua
dict6.lua

4 changes: 2 additions & 2 deletions InputInput_Libraries_zh/InputInput_Libraries_zh_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

## SavedVariables: InputInput_DB

Libraries\LibStub.lua
Libs\LibStub.lua
dict1.lua
dict2.lua
dict3.lua
dict4.lua
dict5.lua
dict6.lua
dict6.lua
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions pkgmeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore:
- .gitignore
- .github
- README.md
- */README.md

move-folders:
InputInput/InputInput: InputInput
Expand Down

0 comments on commit f122c77

Please sign in to comment.