Version 0.9.1-rc

- emote detection mixed in other channels
- minimap button and dialog no longer resets active state after profile change
- default entries are no longer shown after example import
- better handling of capture groups and character sets
This commit is contained in:
2020-08-01 01:35:47 +02:00
parent bafb116bb9
commit 45099a9a3b
17 changed files with 326 additions and 163 deletions

View File

@@ -2,9 +2,9 @@
local _G = _G
local Grichelde = _G.Grichelde or {}
local IsAddOnLoaded, assert, nilOrEmpty, pairs, ipairs, spairs, tContains, tFilter, tInsert, tConcat, tSize, tIsEmpty, find, sub, gsub, gmatch, getNextCharUtf8, isUpper, isLower, toUpper, toLower, capitalize, trim, length, lengthUtf8
local IsAddOnLoaded, assert, nilOrEmpty, pairs, ipairs, spairs, tContains, tFilter, tInsert, tConcat, tSize, tIsEmpty, find, sub, gsub, gmatch, getNextCharUtf8, isLetter, isUpper, isLower, toUpper, toLower, capitalize, trim, length, lengthUtf8
= Grichelde.F.IsAddOnLoaded, Grichelde.F.assert, Grichelde.F.nilOrEmpty, Grichelde.F.pairs, Grichelde.F.ipairs, Grichelde.F.spairs, Grichelde.F.tContains, Grichelde.F.tFilter, Grichelde.F.tInsert, Grichelde.F.tConcat, Grichelde.F.tSize, Grichelde.F.tIsEmpty,
Grichelde.F.find, Grichelde.F.sub, Grichelde.F.gsub, Grichelde.F.gmatch, Grichelde.F.getNextCharUtf8, Grichelde.F.isUpper, Grichelde.F.isLower, Grichelde.F.toUpper, Grichelde.F.toLower, Grichelde.F.capitalize, Grichelde.F.trim, Grichelde.F.length, Grichelde.F.lengthUtf8
Grichelde.F.find, Grichelde.F.sub, Grichelde.F.gsub, Grichelde.F.gmatch, Grichelde.F.getNextCharUtf8, Grichelde.F.isLetter, Grichelde.F.isUpper, Grichelde.F.isLower, Grichelde.F.toUpper, Grichelde.F.toLower, Grichelde.F.capitalize, Grichelde.F.trim, Grichelde.F.length, Grichelde.F.lengthUtf8
--- Splits a long text in longest possible chunks of <= 255 length, split at last available space
-- @param text string
@@ -81,7 +81,20 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
ciPattern = ciPattern .. "["
p, patRest = getNextCharUtf8(patRest)
while ((p ~= nil) and (p ~= "]")) do
ciPattern = ciPattern .. Grichelde.F.toUpper(p) .. Grichelde.F.toLower(p)
if (p == "%") then
-- ignore capture references
p, patRest = getNextCharUtf8(patRest)
if (p ~= nil) then
ciPattern = ciPattern .. "%" .. p
end
else
local upperP, lowerP = toUpper(p), toLower(p)
if (upperP ~= lowerP) then
ciPattern = ciPattern .. upperP .. lowerP
else
ciPattern = ciPattern .. p
end
end
p, patRest = getNextCharUtf8(patRest)
end
ciPattern = ciPattern .. "]"
@@ -313,6 +326,8 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
findText = result
-- update values for next iteration
pos1, pos2, cap1, cap2, cap3, cap4, cap5, cap6, cap7, cap8, cap9 = find(findText, searchText, pos)
self:TracePrint("ReplaceCharacters : pos1: %d, pos2: %d", pos1, pos2)
self:TracePrint("ReplaceCharacters : cap1: %s, cap2: %s, cap3: %s, cap4: %s, cap5: %s, cap6: %s, cap7: %s, cap8: %s, cap9: %s", cap1, cap2, cap3, cap4, cap5, cap6, cap7, cap8, cap9)
end
if (text ~= result) then
@@ -442,11 +457,11 @@ function Grichelde:CheckForPreversableText(text, currentChar, previousChar, repl
local pos1, pos2 = find(text, "^" .. pattern)
if (pos1 == 1) and (pos2 ~= nil) then
local emote = sub(text, pos1, pos2)
if (replaceEmotes) then
self:DebugPrint("CheckForPreversableText : Found emote \"%s\" but preserved it", emote)
if (not replaceEmotes) then
self:DebugPrint("CheckForPreversableText : Found emote \"%s\" at (%d, %d), but preserved it", emote, pos1, pos2)
return pos2
else
self:DebugPrint("CheckForPreversableText : Found emote \"%s\" at (%d, %d)", emote, pos1, pos2)
self:DebugPrint("CheckForPreversableText : ignoring emote \"%s\" at (%d, %d)", emote, pos1, pos2)
end
end
end