mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
String functions len, sub, gsub, find replaced with utf8 versions
This commit is contained in:
parent
d34874e892
commit
cde31673a1
@ -1,6 +1,7 @@
|
|||||||
================================================
|
================================================
|
||||||
Version 11.3 - Alpha (Apr 28 - 2020)
|
Version 11.3 - Alpha (Apr 28 - 2020)
|
||||||
================================================
|
================================================
|
||||||
|
[CHANGED] String functions len, sub, gsub, find replaced with utf8 versions
|
||||||
[ADDED] New properties: skin.controls.smallfont and skin.controls.imagebuttonfont
|
[ADDED] New properties: skin.controls.smallfont and skin.controls.imagebuttonfont
|
||||||
|
|
||||||
================================================
|
================================================
|
||||||
|
@ -61,7 +61,7 @@ loveframes.collisions = {}
|
|||||||
local dir = loveframes.config["DIRECTORY"] or path
|
local dir = loveframes.config["DIRECTORY"] or path
|
||||||
|
|
||||||
-- replace all "." with "/" in the directory setting
|
-- replace all "." with "/" in the directory setting
|
||||||
dir = dir:gsub("\\", "/"):gsub("(%a)%.(%a)", "%1/%2")
|
dir = loveframes.utf8.gsub(loveframes.utf8.gsub(dir, "\\", "/"), "(%a)%.(%a)", "%1/%2")
|
||||||
loveframes.config["DIRECTORY"] = dir
|
loveframes.config["DIRECTORY"] = dir
|
||||||
|
|
||||||
-- enable key repeat
|
-- enable key repeat
|
||||||
|
@ -172,7 +172,7 @@ function loveframes.GetDirectoryContents(dir, t)
|
|||||||
table.insert(t, {
|
table.insert(t, {
|
||||||
path = dir,
|
path = dir,
|
||||||
fullpath = dir.. "/" ..v,
|
fullpath = dir.. "/" ..v,
|
||||||
requirepath = dir:gsub("/", ".") .. "." ..name,
|
requirepath = loveframes.utf8.gsub(dir, "/", ".") .. "." ..name,
|
||||||
name = name,
|
name = name,
|
||||||
extension = extension
|
extension = extension
|
||||||
})
|
})
|
||||||
@ -213,7 +213,7 @@ function loveframes.SplitString(str, pat)
|
|||||||
if pat == " " then
|
if pat == " " then
|
||||||
local fpat = "(.-)" .. pat
|
local fpat = "(.-)" .. pat
|
||||||
local last_end = 1
|
local last_end = 1
|
||||||
local s, e, cap = str:find(fpat, 1)
|
local s, e, cap = loveframes.utf8.find(str, fpat, 1)
|
||||||
while s do
|
while s do
|
||||||
if s ~= #str then
|
if s ~= #str then
|
||||||
cap = cap .. " "
|
cap = cap .. " "
|
||||||
@ -222,25 +222,25 @@ function loveframes.SplitString(str, pat)
|
|||||||
table.insert(t,cap)
|
table.insert(t,cap)
|
||||||
end
|
end
|
||||||
last_end = e+1
|
last_end = e+1
|
||||||
s, e, cap = str:find(fpat, last_end)
|
s, e, cap = loveframes.utf8.find(str, fpat, last_end)
|
||||||
end
|
end
|
||||||
if last_end <= #str then
|
if last_end <= #str then
|
||||||
cap = str:sub(last_end)
|
cap = loveframes.utf8.sub(str, last_end)
|
||||||
table.insert(t, cap)
|
table.insert(t, cap)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local fpat = "(.-)" .. pat
|
local fpat = "(.-)" .. pat
|
||||||
local last_end = 1
|
local last_end = 1
|
||||||
local s, e, cap = str:find(fpat, 1)
|
local s, e, cap = loveframes.utf8.find(str, fpat, 1)
|
||||||
while s do
|
while s do
|
||||||
if s ~= 1 or cap ~= "" then
|
if s ~= 1 or cap ~= "" then
|
||||||
table.insert(t,cap)
|
table.insert(t,cap)
|
||||||
end
|
end
|
||||||
last_end = e+1
|
last_end = e+1
|
||||||
s, e, cap = str:find(fpat, last_end)
|
s, e, cap = loveframes.utf8.find(str, fpat, last_end)
|
||||||
end
|
end
|
||||||
if last_end <= #str then
|
if last_end <= #str then
|
||||||
cap = str:sub(last_end)
|
cap = loveframes.utf8.sub(str, last_end)
|
||||||
table.insert(t, cap)
|
table.insert(t, cap)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -253,10 +253,10 @@ function newobject:SetText(t)
|
|||||||
})
|
})
|
||||||
elseif dtype == "string" then
|
elseif dtype == "string" then
|
||||||
if self.ignorenewlines then
|
if self.ignorenewlines then
|
||||||
v = v:gsub("\n", " ")
|
v = loveframes.utf8.gsub(v, "\n", " ")
|
||||||
end
|
end
|
||||||
v = v:gsub(string.char(9), " ")
|
v = loveframes.utf8.gsub(v, string.char(9), " ")
|
||||||
v = v:gsub("\n", " \n ")
|
v = loveframes.utf8.gsub(v, "\n", " \n ")
|
||||||
local parts = loveframes.SplitString(v, " ")
|
local parts = loveframes.SplitString(v, " ")
|
||||||
for i, j in ipairs(parts) do
|
for i, j in ipairs(parts) do
|
||||||
table.insert(self.formattedtext, {
|
table.insert(self.formattedtext, {
|
||||||
@ -280,10 +280,10 @@ function newobject:SetText(t)
|
|||||||
local key = k
|
local key = k
|
||||||
if width > maxw then
|
if width > maxw then
|
||||||
table.remove(self.formattedtext, k)
|
table.remove(self.formattedtext, k)
|
||||||
for n=1, string.len(data) do
|
for n=1, loveframes.utf8.len(data) do
|
||||||
local item = data:sub(n, n)
|
local item = loveframes.utf8.sub(data, n, n)
|
||||||
local itemw = v.font:getWidth(item)
|
local itemw = v.font:getWidth(item)
|
||||||
if n ~= string.len(data) then
|
if n ~= loveframes.utf8.len(data) then
|
||||||
if (curw + itemw) > maxw then
|
if (curw + itemw) > maxw then
|
||||||
table.insert(inserts, {
|
table.insert(inserts, {
|
||||||
key = key,
|
key = key,
|
||||||
@ -353,7 +353,7 @@ function newobject:SetText(t)
|
|||||||
local text = v.text
|
local text = v.text
|
||||||
local color = v.color
|
local color = v.color
|
||||||
if detectlinks then
|
if detectlinks then
|
||||||
if string.len(text) > 7 and (text:sub(1, 7) == "http://" or text:sub(1, 8) == "https://") then
|
if loveframes.utf8.len(text) > 7 and (loveframes.utf8.sub(text, 1, 7) == "http://" or loveframes.utf8.sub(text, 1, 8) == "https://") then
|
||||||
v.link = true
|
v.link = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -154,7 +154,7 @@ function newobject:update(dt)
|
|||||||
for k, v in ipairs(lines) do
|
for k, v in ipairs(lines) do
|
||||||
local linewidth = 0
|
local linewidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
linewidth = font:getWidth(v:gsub(".", maskchar))
|
linewidth = font:getWidth(loveframes.utf8.gsub(v, ".", maskchar))
|
||||||
else
|
else
|
||||||
linewidth = font:getWidth(v)
|
linewidth = font:getWidth(v)
|
||||||
end
|
end
|
||||||
@ -537,8 +537,8 @@ end
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:textinput(text)
|
function newobject:textinput(text)
|
||||||
|
|
||||||
if text:find("kp.") then
|
if loveframes.utf8.find(text, "kp.") then
|
||||||
text = text:gsub("kp", "")
|
text = loveframes.utf8.gsub(text, "kp", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
self:RunKey(text, true)
|
self:RunKey(text, true)
|
||||||
@ -588,7 +588,7 @@ function newobject:RunKey(key, istext)
|
|||||||
self:MoveIndicator(-1)
|
self:MoveIndicator(-1)
|
||||||
local indicatorx = self.indicatorx
|
local indicatorx = self.indicatorx
|
||||||
if indicatorx <= x and indicatornum ~= 0 then
|
if indicatorx <= x and indicatornum ~= 0 then
|
||||||
local width = font:getWidth(text:sub(indicatornum, indicatornum + 1))
|
local width = font:getWidth(loveframes.utf8.sub(text, indicatornum, indicatornum + 1))
|
||||||
self.offsetx = offsetx - width
|
self.offsetx = offsetx - width
|
||||||
elseif indicatornum == 0 and offsetx ~= 0 then
|
elseif indicatornum == 0 and offsetx ~= 0 then
|
||||||
self.offsetx = 0
|
self.offsetx = 0
|
||||||
@ -616,7 +616,7 @@ function newobject:RunKey(key, istext)
|
|||||||
self:MoveIndicator(1)
|
self:MoveIndicator(1)
|
||||||
local indicatorx = self.indicatorx
|
local indicatorx = self.indicatorx
|
||||||
if indicatorx >= (x + swidth) and indicatornum ~= utf8.len(text) then
|
if indicatorx >= (x + swidth) and indicatornum ~= utf8.len(text) then
|
||||||
local width = font:getWidth(text:sub(indicatornum, indicatornum))
|
local width = font:getWidth(loveframes.utf8.sub(text, indicatornum, indicatornum))
|
||||||
self.offsetx = offsetx + width
|
self.offsetx = offsetx + width
|
||||||
elseif indicatornum == utf8.len(text) and offsetx ~= ((font:getWidth(text)) - swidth + 10) and font:getWidth(text) + textoffsetx > swidth then
|
elseif indicatornum == utf8.len(text) and offsetx ~= ((font:getWidth(text)) - swidth + 10) and font:getWidth(text) + textoffsetx > swidth then
|
||||||
self.offsetx = ((font:getWidth(text)) - swidth + 10)
|
self.offsetx = ((font:getWidth(text)) - swidth + 10)
|
||||||
@ -695,7 +695,7 @@ function newobject:RunKey(key, istext)
|
|||||||
local cwidth = 0
|
local cwidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = self.maskchar
|
local maskchar = self.maskchar
|
||||||
cwidth = font:getWidth(text:gsub(".", maskchar))
|
cwidth = font:getWidth(loveframes.utf8.gsub(text, ".", maskchar))
|
||||||
else
|
else
|
||||||
cwidth = font:getWidth(text)
|
cwidth = font:getWidth(text)
|
||||||
end
|
end
|
||||||
@ -747,8 +747,8 @@ function newobject:RunKey(key, istext)
|
|||||||
newtext = self.lines[line]
|
newtext = self.lines[line]
|
||||||
self.lines[line] = ""
|
self.lines[line] = ""
|
||||||
elseif indicatornum > 0 and indicatornum < utf8.len(self.lines[line]) then
|
elseif indicatornum > 0 and indicatornum < utf8.len(self.lines[line]) then
|
||||||
newtext = self.lines[line]:sub(indicatornum + 1, utf8.len(self.lines[line]))
|
newtext = loveframes.utf8.sub(self.lines[line], indicatornum + 1, utf8.len(self.lines[line]))
|
||||||
self.lines[line] = self.lines[line]:sub(1, indicatornum)
|
self.lines[line] = loveframes.utf8.sub(self.lines[line], 1, indicatornum)
|
||||||
end
|
end
|
||||||
if line ~= #lines then
|
if line ~= #lines then
|
||||||
table.insert(self.lines, line + 1, newtext)
|
table.insert(self.lines, line + 1, newtext)
|
||||||
@ -834,8 +834,8 @@ function newobject:RunKey(key, istext)
|
|||||||
local cwidth = 0
|
local cwidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = self.maskchar
|
local maskchar = self.maskchar
|
||||||
twidth = font:getWidth(text:gsub(".", maskchar))
|
twidth = font:getWidth(loveframes.utf8.gsub(text, ".", maskchar))
|
||||||
cwidth = font:getWidth(key:gsub(".", maskchar))
|
cwidth = font:getWidth(loveframes.utf8.gsub(key, ".", maskchar))
|
||||||
else
|
else
|
||||||
twidth = font:getWidth(text)
|
twidth = font:getWidth(text)
|
||||||
cwidth = font:getWidth(key)
|
cwidth = font:getWidth(key)
|
||||||
@ -937,7 +937,7 @@ function newobject:UpdateIndicator()
|
|||||||
elseif indicatornum >= utf8.len(text) then
|
elseif indicatornum >= utf8.len(text) then
|
||||||
width = font:getWidth(text)
|
width = font:getWidth(text)
|
||||||
else
|
else
|
||||||
width = font:getWidth(text:sub(1, utf8.offset (text, indicatornum + 1) - 1))
|
width = font:getWidth(loveframes.utf8.sub(text, 1, indicatornum))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -966,7 +966,7 @@ function newobject:UpdateIndicator()
|
|||||||
for k, v in ipairs(lines) do
|
for k, v in ipairs(lines) do
|
||||||
local linewidth = 0
|
local linewidth = 0
|
||||||
if self.masked then
|
if self.masked then
|
||||||
linewidth = font:getWidth(v:gsub(".", self.maskchar))
|
linewidth = font:getWidth(loveframes.utf8.gsub(v, ".", self.maskchar))
|
||||||
else
|
else
|
||||||
linewidth = font:getWidth(v)
|
linewidth = font:getWidth(v)
|
||||||
end
|
end
|
||||||
@ -1013,8 +1013,8 @@ function newobject:AddIntoText(t, p)
|
|||||||
local line = self.line
|
local line = self.line
|
||||||
local curline = lines[line]
|
local curline = lines[line]
|
||||||
local text = curline
|
local text = curline
|
||||||
local part1 = text:sub(1, utf8.offset(text, p + 1) - 1)
|
local part1 = loveframes.utf8.sub(text, 1, p)
|
||||||
local part2 = text:sub(utf8.offset(text, p + 1))
|
local part2 = loveframes.utf8.sub(text, p + 1)
|
||||||
local new = part1 .. t .. part2
|
local new = part1 .. t .. part2
|
||||||
|
|
||||||
return new
|
return new
|
||||||
@ -1032,8 +1032,8 @@ function newobject:RemoveFromText(p)
|
|||||||
local line = self.line
|
local line = self.line
|
||||||
local curline = lines[line]
|
local curline = lines[line]
|
||||||
local text = curline
|
local text = curline
|
||||||
local part1 = text:sub(1, utf8.offset(text, p) - 1)
|
local part1 = loveframes.utf8.sub(text, 1, p - 1)
|
||||||
local part2 = text:sub(utf8.offset(text, p + 1))
|
local part2 = loveframes.utf8.sub(text, p + 1)
|
||||||
local new = part1 .. part2
|
local new = part1 .. part2
|
||||||
return new
|
return new
|
||||||
|
|
||||||
@ -1087,7 +1087,7 @@ function newobject:GetTextCollisions(x, y)
|
|||||||
local line = self.line
|
local line = self.line
|
||||||
local curline = lines[line]
|
local curline = lines[line]
|
||||||
for i=1, utf8.len(curline) do
|
for i=1, utf8.len(curline) do
|
||||||
local char = text:sub(i, i)
|
local char = loveframes.utf8.sub(text, i, i)
|
||||||
local width = 0
|
local width = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = self.maskchar
|
local maskchar = self.maskchar
|
||||||
@ -1365,11 +1365,11 @@ function newobject:SetText(text)
|
|||||||
local multiline = self.multiline
|
local multiline = self.multiline
|
||||||
|
|
||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
text = text:gsub(string.char(9), tabreplacement)
|
text = loveframes.utf8.gsub(text, string.char(9), tabreplacement)
|
||||||
text = text:gsub(string.char(13), "")
|
text = loveframes.utf8.gsub(text, string.char(13), "")
|
||||||
|
|
||||||
if multiline then
|
if multiline then
|
||||||
text = text:gsub(string.char(92) .. string.char(110), string.char(10))
|
text = loveframes.utf8.gsub(text, string.char(92) .. string.char(110), string.char(10))
|
||||||
local t = loveframes.SplitString(text, string.char(10))
|
local t = loveframes.SplitString(text, string.char(10))
|
||||||
if #t > 0 then
|
if #t > 0 then
|
||||||
self.lines = t
|
self.lines = t
|
||||||
@ -1379,8 +1379,8 @@ function newobject:SetText(text)
|
|||||||
self.line = #self.lines
|
self.line = #self.lines
|
||||||
self.indicatornum = utf8.len(self.lines[#self.lines])
|
self.indicatornum = utf8.len(self.lines[#self.lines])
|
||||||
else
|
else
|
||||||
text = text:gsub(string.char(92) .. string.char(110), "")
|
text = loveframes.utf8.gsub(text, string.char(92) .. string.char(110), "")
|
||||||
text = text:gsub(string.char(10), "")
|
text = loveframes.utf8.gsub(text, string.char(10), "")
|
||||||
self.lines = {text}
|
self.lines = {text}
|
||||||
self.line = 1
|
self.line = 1
|
||||||
self.indicatornum = utf8.len(text)
|
self.indicatornum = utf8.len(text)
|
||||||
@ -1899,13 +1899,13 @@ function newobject:Paste()
|
|||||||
|
|
||||||
if limit > 0 then
|
if limit > 0 then
|
||||||
local curtext = self:GetText()
|
local curtext = self:GetText()
|
||||||
local curlength = curtext:len()
|
local curlength = utf8.len(curtext)
|
||||||
if curlength == limit then
|
if curlength == limit then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local inputlimit = limit - curlength
|
local inputlimit = limit - curlength
|
||||||
if text:len() > inputlimit then
|
if utf8.len(text) > inputlimit then
|
||||||
text = text:sub(1, inputlimit)
|
text = loveframes.utf8.sub(text, 1, inputlimit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1921,7 +1921,7 @@ function newobject:Paste()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #usable > 0 or #unusable > 0 then
|
if #usable > 0 or #unusable > 0 then
|
||||||
text = text:gsub(".", charcheck)
|
text = loveframes.utf8.gsub(text, ".", charcheck)
|
||||||
end
|
end
|
||||||
if alltextselected then
|
if alltextselected then
|
||||||
self:SetText(text)
|
self:SetText(text)
|
||||||
@ -1939,17 +1939,17 @@ function newobject:Paste()
|
|||||||
local numparts = #parts
|
local numparts = #parts
|
||||||
local oldlinedata = {}
|
local oldlinedata = {}
|
||||||
local line = self.line
|
local line = self.line
|
||||||
local first = lines[line]:sub(0, indicatornum)
|
local first = loveframes.utf8.sub(lines[line], 0, indicatornum)
|
||||||
local last = lines[line]:sub(indicatornum + 1)
|
local last = loveframes.utf8.sub(lines[line], indicatornum + 1)
|
||||||
if numparts > 1 then
|
if numparts > 1 then
|
||||||
for i=1, numparts do
|
for i=1, numparts do
|
||||||
local part = parts[i]:gsub(string.char(13), "")
|
local part = loveframes.utf8.gsub(parts[i], string.char(13), "")
|
||||||
part = part:gsub(string.char(9), " ")
|
part = loveframes.utf8.gsub(part, string.char(9), " ")
|
||||||
if i ~= 1 then
|
if i ~= 1 then
|
||||||
table.insert(oldlinedata, lines[line])
|
table.insert(oldlinedata, lines[line])
|
||||||
lines[line] = part
|
lines[line] = part
|
||||||
if i == numparts then
|
if i == numparts then
|
||||||
self.indicatornum = part:len()
|
self.indicatornum = utf8.len(part)
|
||||||
lines[line] = lines[line] .. last
|
lines[line] = lines[line] .. last
|
||||||
self.line = line
|
self.line = line
|
||||||
end
|
end
|
||||||
@ -1966,10 +1966,10 @@ function newobject:Paste()
|
|||||||
ontextchanged(self, text)
|
ontextchanged(self, text)
|
||||||
end
|
end
|
||||||
elseif numparts == 1 then
|
elseif numparts == 1 then
|
||||||
text = text:gsub(string.char(10), " ")
|
text = loveframes.utf8.gsub(text, string.char(10), " ")
|
||||||
text = text:gsub(string.char(13), " ")
|
text = loveframes.utf8.gsub(text, string.char(13), " ")
|
||||||
text = text:gsub(string.char(9), tabreplacement)
|
text = loveframes.utf8.gsub(text, string.char(9), tabreplacement)
|
||||||
local length = text:len()
|
local length = utf8.len(text)
|
||||||
local new = first .. text .. last
|
local new = first .. text .. last
|
||||||
lines[line] = new
|
lines[line] = new
|
||||||
self.indicatornum = indicatornum + length
|
self.indicatornum = indicatornum + length
|
||||||
@ -1978,13 +1978,13 @@ function newobject:Paste()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
text = text:gsub(string.char(10), " ")
|
text = loveframes.utf8.gsub(text, string.char(10), " ")
|
||||||
text = text:gsub(string.char(13), " ")
|
text = loveframes.utf8.gsub(text, string.char(13), " ")
|
||||||
text = text:gsub(string.char(9), tabreplacement)
|
text = loveframes.utf8.gsub(text, string.char(9), tabreplacement)
|
||||||
local length = text:len()
|
local length = utf8.len(text)
|
||||||
local linetext = lines[1]
|
local linetext = lines[1]
|
||||||
local part1 = linetext:sub(1, indicatornum)
|
local part1 = loveframes.utf8.sub(linetext, 1, indicatornum)
|
||||||
local part2 = linetext:sub(indicatornum + 1)
|
local part2 = loveframes.utf8.sub(linetext, indicatornum + 1)
|
||||||
local new = part1 .. text .. part2
|
local new = part1 .. text .. part2
|
||||||
lines[1] = new
|
lines[1] = new
|
||||||
self.indicatornum = indicatornum + length
|
self.indicatornum = indicatornum + length
|
||||||
|
@ -165,7 +165,7 @@ local function ParseHeaderText(str, hx, hwidth, tx)
|
|||||||
|
|
||||||
if (tx + twidth) - hwidth/2 > hx + hwidth then
|
if (tx + twidth) - hwidth/2 > hx + hwidth then
|
||||||
if #str > 1 then
|
if #str > 1 then
|
||||||
return ParseHeaderText(str:sub(1, #str - 1), hx, hwidth, tx, twidth)
|
return ParseHeaderText(loveframes.utf8.sub(str, 1, #str - 1), hx, hwidth, tx, twidth)
|
||||||
else
|
else
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
@ -181,7 +181,7 @@ local function ParseRowText(str, rx, rwidth, tx1, tx2)
|
|||||||
|
|
||||||
if (tx1 + tx2) + twidth > rx + rwidth then
|
if (tx1 + tx2) + twidth > rx + rwidth then
|
||||||
if #str > 1 then
|
if #str > 1 then
|
||||||
return ParseRowText(str:sub(1, #str - 1), rx, rwidth, tx1, tx2)
|
return ParseRowText(loveframes.utf8.sub(str, 1, #str - 1), rx, rwidth, tx1, tx2)
|
||||||
else
|
else
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
@ -405,8 +405,8 @@ function skin.button(object)
|
|||||||
local text = object.text
|
local text = object.text
|
||||||
local font = skin.controls.button_text_font
|
local font = skin.controls.button_text_font
|
||||||
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
||||||
text =text:sub(2)
|
text =loveframes.utf8.sub(text, 2)
|
||||||
while text:byte(1, 1) > 127 do text = text:sub(2) end
|
while text:byte(1, 1) > 127 do text = loveframes.utf8.sub(text, 2) end
|
||||||
end
|
end
|
||||||
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
||||||
else
|
else
|
||||||
@ -429,8 +429,8 @@ function skin.button(object)
|
|||||||
local text = object.text
|
local text = object.text
|
||||||
local font = skin.controls.button_text_font
|
local font = skin.controls.button_text_font
|
||||||
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
||||||
text =text:sub(2)
|
text =loveframes.utf8.sub(text, 2)
|
||||||
while text:byte(1, 1) > 127 do text = text:sub(2) end
|
while text:byte(1, 1) > 127 do text = loveframes.utf8.sub(text, 2) end
|
||||||
end
|
end
|
||||||
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
||||||
else
|
else
|
||||||
@ -453,8 +453,8 @@ function skin.button(object)
|
|||||||
local text = object.text
|
local text = object.text
|
||||||
local font = skin.controls.button_text_font
|
local font = skin.controls.button_text_font
|
||||||
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
while font:getWidth(text) > width - object.image:getWidth() - 10 do
|
||||||
text =text:sub(2)
|
text =loveframes.utf8.sub(text, 2)
|
||||||
while text:byte(1, 1) > 127 do text = text:sub(2) end
|
while text:byte(1, 1) > 127 do text = loveframes.utf8.sub(text, 2) end
|
||||||
end
|
end
|
||||||
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
skin.PrintText(text, x + object.image:getWidth() + 4, y + height/2 - theight/2)
|
||||||
else
|
else
|
||||||
@ -1170,7 +1170,7 @@ function skin.textinput(object)
|
|||||||
for i=1, #lines do
|
for i=1, #lines do
|
||||||
local str = lines[i]
|
local str = lines[i]
|
||||||
if masked then
|
if masked then
|
||||||
str = str:gsub(".", "*")
|
str = loveframes.utf8.gsub(str, ".", "*")
|
||||||
end
|
end
|
||||||
local twidth = font:getWidth(str)
|
local twidth = font:getWidth(str)
|
||||||
if twidth == 0 then
|
if twidth == 0 then
|
||||||
@ -1184,7 +1184,7 @@ function skin.textinput(object)
|
|||||||
local twidth = 0
|
local twidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
twidth = font:getWidth(text:gsub(".", maskchar))
|
twidth = font:getWidth(loveframes.utf8.gsub(text, ".", maskchar))
|
||||||
else
|
else
|
||||||
twidth = font:getWidth(text)
|
twidth = font:getWidth(text)
|
||||||
end
|
end
|
||||||
@ -1264,7 +1264,7 @@ function skin.textinput(object)
|
|||||||
str = lines[i]
|
str = lines[i]
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
str = str:gsub(".", maskchar)
|
str = loveframes.utf8.gsub(str, ".", maskchar)
|
||||||
end
|
end
|
||||||
skin.PrintText(#str > 0 and str or (#lines == 1 and placeholder or ""), textx, texty + theight * i - theight)
|
skin.PrintText(#str > 0 and str or (#lines == 1 and placeholder or ""), textx, texty + theight * i - theight)
|
||||||
end
|
end
|
||||||
@ -1272,7 +1272,7 @@ function skin.textinput(object)
|
|||||||
str = lines[1]
|
str = lines[1]
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
str = str:gsub(".", maskchar)
|
str = loveframes.utf8.gsub(str, ".", maskchar)
|
||||||
end
|
end
|
||||||
skin.PrintText(#str > 0 and str or placeholder, textx, texty)
|
skin.PrintText(#str > 0 and str or placeholder, textx, texty)
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ local function ParseHeaderText(str, hx, hwidth, tx)
|
|||||||
|
|
||||||
if (tx + twidth) - hwidth/2 > hx + hwidth then
|
if (tx + twidth) - hwidth/2 > hx + hwidth then
|
||||||
if #str > 1 then
|
if #str > 1 then
|
||||||
return ParseHeaderText(str:sub(1, #str - 1), hx, hwidth, tx, twidth)
|
return ParseHeaderText(loveframes.utf8.sub(str, 1, #str - 1), hx, hwidth, tx, twidth)
|
||||||
else
|
else
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
@ -61,7 +61,7 @@ local function ParseRowText(str, rx, rwidth, tx1, tx2)
|
|||||||
|
|
||||||
if (tx1 + tx2) + twidth > rx + rwidth then
|
if (tx1 + tx2) + twidth > rx + rwidth then
|
||||||
if #str > 1 then
|
if #str > 1 then
|
||||||
return ParseRowText(str:sub(1, #str - 1), rx, rwidth, tx1, tx2)
|
return ParseRowText(loveframes.utf8.sub(str, 1, #str - 1), rx, rwidth, tx1, tx2)
|
||||||
else
|
else
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
@ -1059,7 +1059,7 @@ function skin.textinput(object)
|
|||||||
for i=1, #lines do
|
for i=1, #lines do
|
||||||
local str = lines[i]
|
local str = lines[i]
|
||||||
if masked then
|
if masked then
|
||||||
str = str:gsub(".", "*")
|
str = loveframes.utf8.gsub(str, ".", "*")
|
||||||
end
|
end
|
||||||
local twidth = font:getWidth(str)
|
local twidth = font:getWidth(str)
|
||||||
if twidth == 0 then
|
if twidth == 0 then
|
||||||
@ -1073,7 +1073,7 @@ function skin.textinput(object)
|
|||||||
local twidth = 0
|
local twidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
twidth = font:getWidth(text:gsub(".", maskchar))
|
twidth = font:getWidth(loveframes.utf8.gsub(text, ".", maskchar))
|
||||||
else
|
else
|
||||||
twidth = font:getWidth(text)
|
twidth = font:getWidth(text)
|
||||||
end
|
end
|
||||||
@ -1153,7 +1153,7 @@ function skin.textinput(object)
|
|||||||
str = lines[i]
|
str = lines[i]
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
str = str:gsub(".", maskchar)
|
str = loveframes.utf8.gsub(str, ".", maskchar)
|
||||||
end
|
end
|
||||||
skin.PrintText(#str > 0 and str or (#lines == 1 and placeholder or ""), textx, texty + theight * i - theight)
|
skin.PrintText(#str > 0 and str or (#lines == 1 and placeholder or ""), textx, texty + theight * i - theight)
|
||||||
end
|
end
|
||||||
@ -1161,7 +1161,7 @@ function skin.textinput(object)
|
|||||||
str = lines[1]
|
str = lines[1]
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = object:GetMaskChar()
|
local maskchar = object:GetMaskChar()
|
||||||
str = str:gsub(".", maskchar)
|
str = loveframes.utf8.gsub(str, ".", maskchar)
|
||||||
end
|
end
|
||||||
skin.PrintText(#str > 0 and str or placeholder, textx, texty)
|
skin.PrintText(#str > 0 and str or placeholder, textx, texty)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user