refactorings

This commit is contained in:
Manuel Simon Hirsig
2016-05-08 18:04:45 +02:00
parent a49bdd8317
commit aec237e162
5 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -15,8 +15,8 @@ function m:complete()
current_modifier = current_modifier or '' current_modifier = current_modifier or ''
for _, suggestion in ipairs(suggestions) do for _, suggestion in ipairs(suggestions) do
if string.sub(strupper(suggestion), 1, strlen(current_modifier)) == strupper(current_modifier) then if strsub(strupper(suggestion), 1, strlen(current_modifier)) == strupper(current_modifier) then
this:SetText(strlower(string.sub(filter_string, 1, start_index - 1).. suggestion)) this:SetText(strlower(strsub(filter_string, 1, start_index - 1).. suggestion))
this:HighlightText(strlen(filter_string), -1) this:HighlightText(strlen(filter_string), -1)
return return
end end
@@ -32,7 +32,7 @@ function m.completor(options)
local text = self:GetText() local text = self:GetText()
for _, item_name in ipairs(options()) do for _, item_name in ipairs(options()) do
if string.sub(strupper(item_name), 1, strlen(text)) == strupper(text) then if strsub(strupper(item_name), 1, strlen(text)) == strupper(text) then
self:SetText(strlower(item_name)) self:SetText(strlower(item_name))
self:HighlightText(strlen(text), -1) self:HighlightText(strlen(text), -1)
return return
+1 -1
View File
@@ -370,7 +370,7 @@ function public.item_key(hyperlink)
end end
function public.parse_hyperlink(hyperlink) function public.parse_hyperlink(hyperlink)
local _, _, item_id, enchant_id, suffix_id, unique_id, name = strfind(hyperlink, '|c%x%x%x%x%x%x%x%x|Hitem:(%d*):(%d*):(%d*):(%d*)[:0-9]*|h%[([^]]+)%]|h|r') local _, _, item_id, enchant_id, suffix_id, unique_id, name = strfind(hyperlink, '|c%x%x%x%x%x%x%x%x|Hitem:(%d*):(%d*):(%d*):(%d*)[:0-9]*|h%[(.-)%]|h|r')
return tonumber(item_id) or 0, tonumber(suffix_id) or 0, tonumber(unique_id) or 0, tonumber(enchant_id) or 0, name return tonumber(item_id) or 0, tonumber(suffix_id) or 0, tonumber(unique_id) or 0, tonumber(enchant_id) or 0, name
end end
+5 -5
View File
@@ -122,16 +122,16 @@ function public.deserialize(data_string, separator, compactor)
local part local part
if start_index then if start_index then
part = string.sub(data_string, 1, start_index - 1) part = strsub(data_string, 1, start_index - 1)
data_string = string.sub(data_string, start_index + 1, strlen(data_string)) data_string = strsub(data_string, start_index + 1)
else else
part = string.sub(data_string, 1, strlen(data_string)) part = strsub(data_string, 1)
end end
if compactor and strfind(part, compactor, 1, true) then if compactor and strfind(part, compactor, 1, true) then
local compactor_index, _ = strfind(part, compactor, 1, true) local compactor_index, _ = strfind(part, compactor, 1, true)
for i=1, tonumber(string.sub(part, compactor_index + 1, strlen(part))) do for i=1, tonumber(strsub(part, compactor_index + 1)) do
tinsert(data, string.sub(part, 1, compactor_index - 1)) tinsert(data, strsub(part, 1, compactor_index - 1))
end end
else else
tinsert(data, part) tinsert(data, part)
+1 -1
View File
@@ -536,7 +536,7 @@ function public.on_load()
local function add_modifier(...) local function add_modifier(...)
local current_filter_string = private.search_box:GetText() local current_filter_string = private.search_box:GetText()
for i=1,arg.n do for i=1,arg.n do
if current_filter_string ~= '' and string.sub(current_filter_string, strlen(current_filter_string), strlen(current_filter_string)) ~= '/' then if current_filter_string ~= '' and strsub(current_filter_string, -1) ~= '/' then
current_filter_string = current_filter_string..'/' current_filter_string = current_filter_string..'/'
end end
current_filter_string = current_filter_string..arg[i] current_filter_string = current_filter_string..arg[i]
+3 -3
View File
@@ -341,11 +341,11 @@ function public.split(str, separator)
local start_index, _ = strfind(str, separator, 1, true) local start_index, _ = strfind(str, separator, 1, true)
if start_index then if start_index then
local part = string.sub(str, 1, start_index - 1) local part = strsub(str, 1, start_index - 1)
tinsert(array, part) tinsert(array, part)
str = string.sub(str, start_index + 1, strlen(str)) str = strsub(str, start_index + 1)
else else
local part = string.sub(str, 1, strlen(str)) local part = strsub(str, 1)
tinsert(array, part) tinsert(array, part)
return array return array
end end