remove pl library
This commit is contained in:
@@ -129,12 +129,13 @@ AIO Launcher включает в себя интерпретатор LuaJ 3.0.1
|
||||
* `string:split(delimeter)` - разделяет строку с помощью указанного разделителя и возвращает таблицу;
|
||||
* `string:replace(regexp, string)` - заменяет текст, найденный регулярным выражением, на другой текст;
|
||||
* `get_index(table, value)` - возвращает индекс элемента таблицы;
|
||||
* `get_key(table, value)` - возвращает ключ элемента таблицы;
|
||||
* `round(x, n)` - округляет число;
|
||||
* `md_colors` - таблица цветов Material Design (исходник есть в этом репозитории, [справка](https://materialui.co/colors));
|
||||
|
||||
В комплект также входят:
|
||||
|
||||
* [Penlight](http://stevedonovan.github.io/Penlight/api/manual/01-introduction.md.html) - набор портированных из Python функций и структур данных;
|
||||
* url - функции для кодирования/декодирования строки в URL из библиотеки Lua Penlight;
|
||||
* [luaDate](https://github.com/Tieske/date) - функции для работы со временем;
|
||||
* [json.lua](https://github.com/rxi/json.lua) - парзер JSON;
|
||||
* [SLAXDOM](https://github.com/Phrogz/SLAXML) - парзер XML;
|
||||
|
||||
46
lib/utils.lua
Normal file
46
lib/utils.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
-- Standard AIO Launcher library
|
||||
|
||||
function string:split(sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
|
||||
local t={}
|
||||
|
||||
for str in string.gmatch(self, "([^"..sep.."]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
function string:replace(from, to)
|
||||
return self:gsub(from, to)
|
||||
end
|
||||
|
||||
function get_index(tab, val)
|
||||
for index, value in ipairs(tab) do
|
||||
if value == val then
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function get_key(tab, val)
|
||||
for index, value in pairs(tab) do
|
||||
if value == val then
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function round(x, n)
|
||||
local n = math.pow(10, n or 0)
|
||||
local x = x * n
|
||||
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
|
||||
return x / n
|
||||
end
|
||||
@@ -6,7 +6,7 @@
|
||||
-- version = "1.0"
|
||||
|
||||
json = require "json"
|
||||
url = require "pl.url"
|
||||
url = require "url"
|
||||
|
||||
-- constants
|
||||
local lang = system:get_lang()
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
-- arguments_help = "Введите список виджетов и кнопок в формате bitcoin:Биткойн timer:Таймер"
|
||||
-- arguments_default = "bitcoin:Битк. timer:Тайм. stopwatch:Секунд. recorder:Дикт. calculator:Кальк."
|
||||
|
||||
sx = require 'pl.stringx'
|
||||
|
||||
function on_resume()
|
||||
local args = get_args_kv()
|
||||
|
||||
@@ -46,7 +44,7 @@ function get_args_kv()
|
||||
local args = aio:get_args()
|
||||
|
||||
for idx = 1, #args, 1 do
|
||||
local arg = sx.split(args[idx], ":")
|
||||
local arg = args[idx]:split(":")
|
||||
keys[idx] = arg[1]
|
||||
values[idx] = arg[2]
|
||||
end
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
sx = require 'pl.stringx'
|
||||
|
||||
function on_resume()
|
||||
local string = "String with spaces"
|
||||
local s_list = sx.split(string, " ")
|
||||
ui:show_text(s_list[3])
|
||||
end
|
||||
Reference in New Issue
Block a user