Version 1.1.4
- typos in descriptions - ambiguous variable definitions - bumped version for all versions of WoW (Classic Era, WotLK, Retail) - added TOCs for all versions of WoW, removed release script
This commit is contained in:
+54
-28
@@ -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, isLetter, isUpper, isLower, toUpper, toLower, capitalize, bytes2Char, 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.isLetter, Grichelde.F.isUpper, Grichelde.F.isLower, Grichelde.F.toUpper, Grichelde.F.toLower, Grichelde.F.capitalize, Grichelde.F.bytes2Char, Grichelde.F.trim, Grichelde.F.length, Grichelde.F.lengthUtf8
|
||||
local IsAddOnLoaded, assert, nilOrEmpty, pairs, ipairs, spairs, tContains, tFilter, tInsert, tIsEmpty, find, sub, gsub, getNextCharUtf8, isUtf8MultiByte, getUtf8Sequence, isUpper, isLower, toUpper, toLower, bytes2Char, 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.tIsEmpty,
|
||||
Grichelde.F.find, Grichelde.F.sub, Grichelde.F.gsub, Grichelde.F.getNextCharUtf8, Grichelde.F.isUtf8MultiByte, Grichelde.F.getUtf8Sequence, Grichelde.F.isUpper, Grichelde.F.isLower, Grichelde.F.toUpper, Grichelde.F.toLower, Grichelde.F.bytes2Char, 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
|
||||
@@ -58,7 +58,6 @@ function Grichelde:SplitText(text)
|
||||
-- must not enforce UTF-8 support here, as the positions are used
|
||||
while ((length(newText) > 0) and (escape < Grichelde.ENDLESS_LOOP_LIMIT)) do
|
||||
escape = escape + 1
|
||||
local previousChar = currentChar
|
||||
local first, textAhead = getNextCharUtf8(newText)
|
||||
currentChar = first
|
||||
self:DebugPrint("SplitText : currentChar, escape: %s, %s", currentChar, escape)
|
||||
@@ -154,6 +153,24 @@ function Grichelde:SendChunkifiedChatMessage(message, ...)
|
||||
end
|
||||
|
||||
function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, replacedTexts)
|
||||
local function convertToCaseInsensitivePatternGroup(p)
|
||||
local upperP, lowerP = toUpper(p), toLower(p)
|
||||
--[[
|
||||
if (isUtf8MultiByte(p)) then
|
||||
local sequence = nil
|
||||
for _, byteSequence in spairs(getUtf8Table(upperP)) do
|
||||
sequence = sequence .. byteSequence
|
||||
end
|
||||
else
|
||||
]]
|
||||
if (upperP ~= lowerP) then
|
||||
return upperP .. lowerP
|
||||
else
|
||||
return p
|
||||
end
|
||||
--end
|
||||
end
|
||||
|
||||
local function convertToCaseInsensitivePattern(pattern)
|
||||
local ciPattern = ""
|
||||
local ignored = {'^', '$', '(', ')', '.'}
|
||||
@@ -184,18 +201,13 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
|
||||
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
|
||||
ciPattern = ciPattern .. convertToCaseInsensitivePatternGroup(p)
|
||||
end
|
||||
p, patRest = getNextCharUtf8(patRest)
|
||||
end
|
||||
ciPattern = ciPattern .. "]"
|
||||
else
|
||||
ciPattern = ciPattern .. "[" .. Grichelde.F.toUpper(p) .. Grichelde.F.toLower(p) .. "]"
|
||||
ciPattern = ciPattern .. "[" .. convertToCaseInsensitivePatternGroup(p) .. "]"
|
||||
end
|
||||
|
||||
p, patRest = getNextCharUtf8(patRest)
|
||||
@@ -204,9 +216,9 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
|
||||
return ciPattern
|
||||
end
|
||||
|
||||
local function replaceCaptures(text, replaceText, captures)
|
||||
local function replaceCaptures(txt, replaceText, captures)
|
||||
local replText = replaceText
|
||||
self:TracePrint("replaceCaptures : text: %s, #captures: %d", text, #captures)
|
||||
self:TracePrint("replaceCaptures : txt: %s, #captures: %d", txt, #captures)
|
||||
|
||||
if (#captures > 0) then
|
||||
for i, cap in ipairs(captures) do
|
||||
@@ -285,9 +297,6 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
|
||||
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)
|
||||
while (pos1 ~= nil) and (pos2 ~= nil) and (pos1 <= pos2) do
|
||||
-- continue from that position later
|
||||
pos = pos2 + 1
|
||||
|
||||
if doStopOnMatch then
|
||||
stopOnMatch = true
|
||||
end
|
||||
@@ -297,6 +306,24 @@ function Grichelde:ReplaceCharacters(text, replName, replTable, consolidate, rep
|
||||
local post = sub(result, pos2 + 1)
|
||||
local wordStart = sub(pre, -1, -1)
|
||||
local wordEnd = sub(post, 1, 1)
|
||||
self:TracePrint("ReplaceCharacters : result: %s", result)
|
||||
self:TracePrint("ReplaceCharacters : pre: %s, match: %s, post: %s, wordStart: %s, wordEnd: %s", pre, match, post, wordStart, wordEnd)
|
||||
|
||||
--[[
|
||||
self:TracePrint("ReplaceCharacters : pos2: %d, isChar: %s", pos2, isChar(match))
|
||||
while (not isChar(match) and pos2 < length(result)) do
|
||||
pos2 = pos2 + 1
|
||||
pre = sub(result, 1, pos1 - 1)
|
||||
match = sub(result, pos1, pos2)
|
||||
post = sub(result, pos2 + 1)
|
||||
wordStart = sub(pre, -1, -1)
|
||||
wordEnd = sub(post, 1, 1)
|
||||
self:TracePrint("ReplaceCharacters : pos2: %d, isChar: %s", pos2, isChar(match))
|
||||
end
|
||||
]]
|
||||
|
||||
-- continue from that position later
|
||||
pos = pos2 + 1
|
||||
|
||||
-- additional checks for word boundaries
|
||||
local doesMatchWhen = false
|
||||
@@ -441,8 +468,8 @@ end
|
||||
-- @param text string
|
||||
-- @param replacements table of mappings
|
||||
-- @return string
|
||||
function Grichelde:ReplaceAndConsolidate(text, replacements)
|
||||
local replacements = replacements or self.db.profile.replacements or {}
|
||||
function Grichelde:ReplaceAndConsolidate(text, _replacements)
|
||||
local replacements = _replacements or self.db.profile.replacements or {}
|
||||
self:TracePrint("ReplaceAndConsolidate : replacements")
|
||||
self:TracePrint(replacements)
|
||||
|
||||
@@ -531,7 +558,6 @@ function Grichelde:CheckForLink(text, currentChar)
|
||||
for _, pattern in ipairs(Grichelde.IGNORE_PATTERNS.LINKS) do
|
||||
local pos1, pos2 = find(text, "^" .. pattern)
|
||||
if (pos1 == 1) and (pos2 ~= nil) then
|
||||
local match = sub(text, pos1, pos2)
|
||||
self:DebugPrint("CheckForLink : Found link or texture pattern \"%s\" at (%d, %d)", pattern, pos1, pos2)
|
||||
return pos2
|
||||
end
|
||||
@@ -590,10 +616,10 @@ function Grichelde:CheckForRaidTargetMarkers(text, currentChar)
|
||||
local translation = toLower(self.L["IgnorePattern_" .. localizedRT])
|
||||
local localizedPattern = "^{" .. translation .. "}"
|
||||
self:TracePrint("CheckForPreversableText : localizedPattern:", localizedPattern)
|
||||
local pos1, pos2 = find(lowerText, localizedPattern)
|
||||
if (pos1 == 1) and (pos2 ~= nil) then
|
||||
self:DebugPrint("CheckForPreversableText : Found localized raid target marker \"%s\" at (%d, %d)", localizedPattern, pos1, pos2)
|
||||
return pos2
|
||||
local p1, p2 = find(lowerText, localizedPattern)
|
||||
if (p1 == 1) and (p2 ~= nil) then
|
||||
self:DebugPrint("CheckForPreversableText : Found localized raid target marker \"%s\" at (%d, %d)", localizedPattern, p1, p2)
|
||||
return p2
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -636,9 +662,9 @@ end
|
||||
-- @param previousChar string(1) previous character of the text, otherwise unreachable
|
||||
-- @param preserveEmotes boolean ignore replacements for emotes, for testing purposes
|
||||
-- @return number
|
||||
function Grichelde:CheckForPreversableText(text, currentChar, previousChar, replaceEmotes)
|
||||
function Grichelde:CheckForPreversableText(text, currentChar, previousChar, _replaceEmotes)
|
||||
self:DebugPrint("CheckForPreversableText : text:", text)
|
||||
local replaceEmotes = replaceEmotes or self.db.profile.channels.emote or false
|
||||
local replaceEmotes = _replaceEmotes or self.db.profile.channels.emote or false
|
||||
|
||||
local linkPos = self:CheckForLink(text, currentChar)
|
||||
if (linkPos ~= nil) then
|
||||
@@ -679,11 +705,11 @@ end
|
||||
-- @param text string the text to apply the mappings on
|
||||
-- @param preserveEmotes boolean ignore replacements for emotes, for testing purposes
|
||||
-- @return string
|
||||
function Grichelde:ReplaceText(text, replacements, replaceEmotes)
|
||||
function Grichelde:ReplaceText(text, _replacements, _replaceEmotes)
|
||||
local lookAheads = { '|', '*', '<', '%', '{', '(', 'o' }
|
||||
local newText = text
|
||||
local preserveEmotes = replaceEmotes or self.db.profile.channels.emote or false
|
||||
local replacements = replacements or self.db.profile.replacements or {}
|
||||
local preserveEmotes = _replaceEmotes or self.db.profile.channels.emote or false
|
||||
local replacements = _replacements or self.db.profile.replacements or {}
|
||||
local finalText, replaceText = "", ""
|
||||
local currentChar
|
||||
local escape = 0
|
||||
|
||||
Reference in New Issue
Block a user